819527061@qq.com
2024-11-18 34aedd9998b5572488e49db884b2f7966d960a57
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<template>
    <div>
        <div style="padding: 10px 10px 0px 10px;">
            <el-form :inline="true" :model="searchForm">
                <el-form-item label="车牌号">
                <el-input v-model="searchForm.carNo" clearable></el-input>
                </el-form-item>
              <el-form-item label="类型">
              <el-select  v-model="searchForm.type" placeholder="请选择" clearable>
                <el-option label="永久" :value="0"></el-option>
                <el-option label="月票" :value="1"></el-option>
              </el-select>
              </el-form-item>
              <el-form-item label="选择结束时间">
                <div class="date-box">
                  <el-date-picker type="date" value-format="yyyy-MM-dd" format="yyyy-MM-dd"
                                  v-model="searchForm.date" placeholder="" clearable>
                  </el-date-picker>
                </div>
              </el-form-item>
                <el-form-item>
                    <el-button type="primary" size="small" @click="onSearch" icon="el-icon-search">查询</el-button>
                    <el-button type="primary" size="small" @click="onAdd" icon="el-icon-plus">增加</el-button>
                </el-form-item>
            </el-form>
        </div>
 
        <el-table :height="tableHeight" :data="pageData.rows" v-loading="pageData.isLoading" border style="width:100%;border:1px solid #bcbec2;">
            <el-table-column type="index" width="50" label="序号" align="center"> </el-table-column>
            <el-table-column prop="carNo" label="车牌号" align="center" width="150"></el-table-column>
            <el-table-column prop="type" label="类型" align="center" width="100">
                <template slot-scope="scope">
                    <p v-if="scope.row.type==0">永久</p>
                    <p v-if="scope.row.type==1">月票</p>
                </template>
            </el-table-column>
            <el-table-column prop="startTime" label="月票开始日期" align="center"></el-table-column>
            <el-table-column prop="endTime" label="月票结束日期" align="center"></el-table-column>
            <el-table-column prop="name" label="停车场" align="center"></el-table-column>
            <el-table-column prop="createBy" label="操作人" align="center"></el-table-column>
            <el-table-column label="操作" fixed="right" width="150" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" @click="onEdit(scope.row)">编辑</el-button>
                    <el-button size="mini" type="danger" @click="onDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="onPageSizeChange" @current-change="onCurrentPageChange" :current-page="pageData.currentPage" :page-size="pageData.pageSize" :total="pageData.total" style="float: right"></el-pagination>
 
        <el-dialog title="编辑" :visible.sync="flag" width="40%">
            <el-form :model="formData" ref="formData" label-width="100px">
                <el-form-item label="车牌号" prop="carNo" :rules="[{ required: true, message: '请输入车牌号', trigger: 'change'}]">
                    <el-input v-model="formData.carNo"></el-input>
                </el-form-item>
                <el-form-item label="类型" prop="type" :rules="[{ required: true, message: '请选择类型', trigger: 'change'}]">
                    <el-select v-model="formData.type" @change="selectChange">
                        <el-option label="永久" :value=0></el-option>
                        <el-option label="月票" :value=1></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="月票开始日期" prop="startTime" v-if="flag2">
                    <el-date-picker type="date" placeholder="选择时间" v-model="formData.startTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="月票结束日期" prop="endTime" v-if="flag2">
                    <el-date-picker placeholder="选择时间" v-model="formData.endTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="停车场" prop="parkIds" v-if="flag2">
                    <el-select v-model="ids" multiple clearable>
                        <el-option v-for="item in table1" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="flag = false">取 消</el-button>
                <el-button type="primary" @click="onSave">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
 
<script>
    export default {
        name: "index",
        data: function () {
            return {
                flag:false,
                flag2:false,
                searchForm: {
                    name: '',
                    carNo:'',
                    type:null,
                    date: null
                },
                pageData: this.$byutil.defaultPageData(),
                formData: {
                    carNo: '',
                    type: 0,
                    endTime: '',
                    startTime: '',
                    parkIds: null,
                    name: '',
                    createBy:'',
                    updateBy:''
                },
                ids:[],
                urlPath:this.$systemconfig.basePath + '/ffzf/whiteList/',
                table1:[],
                userName:'',
              tableHeight:500,
            }
        },
        mounted() {
          let username = localStorage.getItem('name')
          this.formData.createBy = username
          this.userName = username
            this.loadData();
            this.$byutil.postData(this, this.$systemconfig.basePath+'/ffzf/park/findAll', this.formData, res => {
                this.table1 = res.data;
            })
          this.tableHeight = window.innerHeight - 260
        },
        methods: {
            selectChange(value){
                if(value==1){
                    this.flag2 = true;
                }else{
                    this.flag2 = false;
                }
            },
            onSave(){
                this.$refs['formData'].validate((valid) => {
                    if (valid) {
                      this.formData.parkIds = this.ids.join(",")
                        this.$byutil.postData(this, this.urlPath+'save', this.formData, res => {
                            this.$refs['formData'].resetFields();
                            this.flag=false;
                            this.$message({message:'保存成功', type: 'success'});
                            this.loadData();
                        })
                    } else {
                        return false;
                    }
                });
            },
            loadData() {
                this.$byutil.loadPageData(this, this.urlPath+'findPageNew', this.searchForm);
            },
            onSearch() {
                this.pageData = this.$byutil.defaultPageData();
                this.loadData();
            },
            onAdd() {
                this.flag=true;
                this.flag2=false;
                this.$refs['formData'].resetFields();
                this.formData = {
                    carNo: '',
                    type: 0,
                    endTime: '',
                    startTime: '',
                    parkIds: null
                }
            },
            onEdit(row) {
                this.flag=true;
                this.ids = []
                this.formData  = row;
                this.formData.updateBy = this.userName
                if(row.type==1){
                  this.ids = this.formData.parkIds.split(",")
                  this.ids = this.ids.map(function(data){
                    return +data;
                  });
                  this.flag2=true;
                }
            },
            onDelete(row) {
                this.$byutil.deleteData(this,this.urlPath+"delete",{id:row.id}, res => {
                    this.$message({message: '删除成功', type: 'success'});
                    this.loadData();
                })
            },
            onPageSizeChange(val) {
                this.pageData.pageSize = val;
                this.loadData();
            },
            onCurrentPageChange(val) {
                this.pageData.page = val;
                this.loadData();
            },
        }
    }
</script>
 
<style scoped>
 
</style>