security_inspection.vue
19.3 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<template>
<section>
<!--工具条-->
<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
<el-form :inline="true" :model="filters">
<el-form-item>
<el-input v-model="filters.securityInspectionName" placeholder="安全巡视员"></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" v-on:click="getSecurityInspectionList()">查询</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="companyAdd">新增</el-button>
</el-form-item>
</el-form>
</el-col>
<!--列表-->
<el-table :data="securityInspectionList" highlight-current-row v-loading="listLoading" @selection-change="selsChange" style="width: 100%;">
<el-table-column type="selection" width="55">
</el-table-column>
<el-table-column type="index">
</el-table-column>
<el-table-column prop="securityInspectionId" v-if="false" label="ID" sortable>
</el-table-column>
<el-table-column prop="securityInspectionName" label="安检巡视员" sortable>
</el-table-column>
<el-table-column prop="fireName" label="消防通道及隔离设备" sortable>
</el-table-column>
<el-table-column prop="securityElectro" label="安全用电" sortable>
</el-table-column>
<el-table-column prop="fireproofing" label="防火防盗" sortable>
</el-table-column>
<el-table-column prop="doubtfulPerson" label="可疑人员" sortable>
</el-table-column>
<el-table-column prop="violationsCar" label="违规停放车辆" sortable>
</el-table-column>
<el-table-column prop="builders" label="施工人员" sortable>
</el-table-column>
<el-table-column prop="builders" label="其他情况" sortable>
</el-table-column>
<el-table-column prop="optTime" label="操作时间" sortable>
</el-table-column>
<el-table-column label="操作" min-width="150">
<template slot-scope="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button type="danger" size="small" @click="handleDel(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<!--工具条-->
<el-col :span="24" class="toolbar">
<el-button type="danger" @click="batchRemove" :disabled="this.sels.length===0">批量删除</el-button>
<el-pagination layout="total, prev, pager, next" @current-change="handleCurrentChange" :page-size="5" :total="total" style="float:right;">
</el-pagination>
</el-col>
<!--编辑界面-->
<el-dialog title="编辑" :visible.sync="editFormVisible" :close-on-click-modal="false">
<el-form :model="editForm" label-width="80px" :rules="editFormRules" ref="editForm">
<el-form-item label="ID">
<span>{{editForm.securityInspectionId}}</span>
</el-form-item>
<el-form-item label="安检巡视员" prop="securityInspectionName">
<el-input v-model="editForm.securityInspectionName" auto-complete="off" placeholder="请输入安检巡视员"></el-input>
</el-form-item>
<el-form-item label="消防通道及隔离设备" prop="fireName">
<el-input v-model="editForm.fireName" auto-complete="off" placeholder="请输入消防通道及隔离设备"></el-input>
</el-form-item>
<el-form-item label="安全用电" prop="securityElectro">
<el-input v-model="editForm.securityElectro" auto-complete="off" placeholder="请输入安全用电"></el-input>
</el-form-item>
<el-form-item label="防火防盗" prop="fireproofing">
<el-input v-model="editForm.fireproofing" auto-complete="off" placeholder="请输入防火防盗"></el-input>
</el-form-item>
<el-form-item label="可疑人员" prop="doubtfulPerson">
<el-input v-model="editForm.doubtfulPerson" auto-complete="off" placeholder="请输入可疑人员"></el-input>
</el-form-item>
<el-form-item label="违规停放车辆" prop="violationsCar">
<el-input v-model="editForm.violationsCar" auto-complete="off" placeholder="请输入违规停放车辆"></el-input>
</el-form-item>
<el-form-item label="施工人员" prop="builders">
<el-input v-model="editForm.builders" auto-complete="off" placeholder="请输入施工人员"></el-input>
</el-form-item>
<el-form-item label="其他情况" prop="otherSituations">
<el-input v-model="editForm.otherSituations" auto-complete="off" placeholder="请输入其他情况"></el-input>
</el-form-item>
<el-form-item label="操作时间" prop="securityInspectionDate">
<span class="demonstration">默认</span>
<el-date-picker
v-model="editForm.securityInspectionDate"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click.native="editFormVisible = false">取消</el-button>
<el-button type="primary" @click.native="editSubmit" :loading="editLoading">提交</el-button>
</div>
</el-dialog>
<!--新增界面-->
<el-dialog title="新增" :visible.sync="addFormVisible" :close-on-click-modal="false">
<el-form :model="addForm" label-width="80px" :rules="addFormRules" ref="addForm">
<el-form-item label="安检巡视员" prop="securityInspectionName">
<el-input v-model="addForm.securityInspectionName" auto-complete="off" placeholder="请输入安检巡视员"></el-input>
</el-form-item>
<el-form-item label="消防通道及隔离设备" prop="fireName">
<el-input v-model="addForm.fireName" auto-complete="off" placeholder="请输入消防通道及隔离设备"></el-input>
</el-form-item>
<el-form-item label="安全用电" prop="securityElectro">
<el-input v-model="addForm.securityElectro" auto-complete="off" placeholder="请输入安全用电"></el-input>
</el-form-item>
<el-form-item label="防火防盗" prop="fireproofing">
<el-input v-model="addForm.fireproofing" auto-complete="off" placeholder="请输入防火防盗"></el-input>
</el-form-item>
<el-form-item label="可疑人员" prop="doubtfulPerson">
<el-input v-model="addForm.doubtfulPerson" auto-complete="off" placeholder="请输入可疑人员"></el-input>
</el-form-item>
<el-form-item label="违规停放车辆" prop="violationsCar">
<el-input v-model="addForm.violationsCar" auto-complete="off" placeholder="请输入违规停放车辆"></el-input>
</el-form-item>
<el-form-item label="施工人员" prop="builders">
<el-input v-model="addForm.builders" auto-complete="off" placeholder="请输入施工人员"></el-input>
</el-form-item>
<el-form-item label="其他情况" prop="otherSituations">
<el-input v-model="addForm.otherSituations" auto-complete="off" placeholder="请输入其他情况"></el-input>
</el-form-item>
<el-form-item label="操作时间" prop="securityInspectionDate">
<el-date-picker
v-model="addForm.securityInspectionDate"
type="datetime"
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间">
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click.native="addFormVisible = false">取消</el-button>
<el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
</div>
</el-dialog>
</section>
</template>
<script>
import util from '../../common/js/util'
import NProgress from 'nprogress'
import { getList, remove, batchRemove, edit, add } from '../../api/staff/security_inspection';
import moment from 'moment'
export default {
data() {
return {
filters: {
securityInspectionName: ''
},
userId: '',
securityInspectionList: [],
total: 0,
pageNum: 1,
pageSize: 5,
listLoading: false,
sels: [],//列表选中列
//编辑界面是否显示
editFormVisible: false,
editLoading: false,
editFormRules: {
securityInspectionName: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
securityInspectionDate: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
fireName: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
securityElectro: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
fireproofing: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
doubtfulPerson: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
violationsCar: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
builders: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
otherSituations: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
},
//编辑界面数据
editForm: {
securityInspectionId: '',
securityInspectionName: '',
securityInspectionDate: '',
fireName: '',
securityElectro: '',
fireproofing: '',
doubtfulPerson: '',
violationsCar: '',
builders: '',
otherSituations: ''
},
//新增界面是否显示
addFormVisible: false,
addLoading: false,
addFormRules: {
securityInspectionName: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
fireName: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
securityElectro: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
fireproofing: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
doubtfulPerson: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
violationsCar: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
builders: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
otherSituations: [
{ required: true, message: '不能为空!!!', trigger: 'blur' }
],
},
//新增界面数据
addForm: {
securityInspectionName: '',
// securityInspectionDate: '',
fireName: '',
securityElectro: '',
fireproofing: '',
doubtfulPerson: '',
violationsCar: '',
builders: '',
otherSituations: '',
optTime:'',
realname:'',
userId: this.userId
}
}
},
mounted() {
this.userId = JSON.parse(sessionStorage.getItem('user')).userId;
console.log(this.userId);
this.getSecurityInspectionList();
},
methods: {
handleCurrentChange(val) {
this.pageNum = val;
this.getSecurityInspectionList();
},
//获取公司列表
getSecurityInspectionList() {
let para = {
pageNum: this.pageNum,
pageSize: this.pageSize,
securityInspectionName: this.filters.securityInspectionName
};
this.listLoading = true;
//NProgress.start();
getList(para).then((res) => {
this.total = res.data.total;
this.securityInspectionList = res.data.list;
this.listLoading = false;
//NProgress.done();
}).catch((error) => {
this.listLoading = false;
if(null!= error.response && error.response!==undefined){
let status= error.response.status;
let msg = error.response.statusText;
alert(status+msg);
}else {
alert(error);
}
});
},
//删除
handleDel: function (index, row) {
this.$confirm('确认删除该记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.listLoading = true;
//NProgress.start();
let para = { securityInspectionId: row.securityInspectionId };
remove(para).then((res) => {
this.listLoading = false;
//NProgress.done();
this.$message({
message: '删除成功',
type: 'success'
});
this.getSecurityInspectionList();
}).catch((error) => {
this.listLoading = false;
alert(error);
});
}).catch();
},
/**
* 显示编辑界面
* @param index
* @param row 为这行的数据对象
*/
handleEdit: function (index, row) {
this.editFormVisible = true;
this.editForm = Object.assign({}, row);
this.getSecurityInspectionList();
},
//显示新增界面,每次点开初始化数据
companyAdd: function () {
this.addFormVisible = true;
this.addForm = {
userId: this.userId
};
this.getSecurityInspectionList();
},
//新增
addSubmit: function () {
this.$refs.addForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
//NProgress.start();
this.listLoading = true;
let para = Object.assign({}, this.addForm);
add(para).then((res) => {
this.addLoading = false;
//NProgress.done();
this.$message({
message: '提交成功',
type: 'success'
});
this.$refs['addForm'].resetFields();
this.addFormVisible = false;
this.getSecurityInspectionList();
}).catch(error => alert(error));
});
}
});
},
//编辑
editSubmit: function () {
this.$refs.editForm.validate((valid) => {
if (valid) {
this.$confirm('确认提交吗?', '提示', {}).then(() => {
this.editLoading = true;
let para = Object.assign({}, this.editForm);
this.editLoading = true;
edit(para).then((res) => {
this.$message({
message: '提交成功',
type: 'success'
});
this.$refs['editForm'].resetFields();
this.editFormVisible = false;
this.getSecurityInspectionList();
}).catch(error => alert(error));
});
}
});
},
selsChange: function (sels) {
this.sels = sels;
},
//批量删除
batchRemove: function () {
var ids = this.sels.map(item => item.securityInspectionId).toString();
this.$confirm('确认删除选中记录吗?', '提示', {
type: 'warning'
}).then(() => {
this.listLoading = true;
//NProgress.start();
let para = { ids: ids };
batchRemove(para).then((res) => {
this.listLoading = false;
//NProgress.done();
this.$message({
message: '删除成功',
type: 'success'
});
this.getSecurityInspectionList();
});
}).catch(() => {
});
}
},
}
</script>