|
@@ -0,0 +1,511 @@
|
|
1
|
+<template>
|
|
2
|
+ <div class="main_root">
|
|
3
|
+ <div class="search_header">
|
|
4
|
+ <div class="search_left">
|
|
5
|
+ <Select
|
|
6
|
+ v-model="searchForm.regionid"
|
|
7
|
+ style="margin-right: 16px; width: 150px"
|
|
8
|
+ >
|
|
9
|
+ <Option :value="0">所有区域</Option>
|
|
10
|
+ <Option
|
|
11
|
+ v-for="regionItem in searchForm.regionList"
|
|
12
|
+ :value="regionItem.regionid"
|
|
13
|
+ :key="regionItem.regionid"
|
|
14
|
+ >{{ regionItem.regionName }}</Option
|
|
15
|
+ >
|
|
16
|
+ </Select>
|
|
17
|
+ <Input
|
|
18
|
+ v-model="searchForm.sn"
|
|
19
|
+ placeholder="请输入序列号模糊搜索"
|
|
20
|
+ search
|
|
21
|
+ @on-search="searchList()"
|
|
22
|
+ style="width: 200px"
|
|
23
|
+ />
|
|
24
|
+ </div>
|
|
25
|
+ <div class="search_right">
|
|
26
|
+ <Button type="primary" class="primary_btn" @click="toImport()"
|
|
27
|
+ >导入</Button
|
|
28
|
+ >
|
|
29
|
+ <Button type="primary" class="primary_btn" @click="toAdd()"
|
|
30
|
+ >新建</Button
|
|
31
|
+ >
|
|
32
|
+ <Button type="primary" class="primary_btn" @click="toBatchDelete()"
|
|
33
|
+ >批量删除</Button
|
|
34
|
+ >
|
|
35
|
+ </div>
|
|
36
|
+ </div>
|
|
37
|
+ <div class="table_wrap">
|
|
38
|
+ <Table
|
|
39
|
+ :columns="columns"
|
|
40
|
+ :data="searchForm.list"
|
|
41
|
+ @on-selection-change="tableSelectionChange"
|
|
42
|
+ >
|
|
43
|
+ <template slot-scope="{ row }" slot="snStateSlot">
|
|
44
|
+ <div class="action_list">
|
|
45
|
+ <div class="action_success" v-if="row.snState === 0">正常</div>
|
|
46
|
+ <div class="action_error" v-else-if="row.snState === 1">注销</div>
|
|
47
|
+ </div>
|
|
48
|
+ </template>
|
|
49
|
+ <template slot-scope="{ row }" slot="actionSlot">
|
|
50
|
+ <div class="action_list">
|
|
51
|
+ <div @click="toEdit(row)">编辑</div>
|
|
52
|
+ <div class="action_del" @click="toDel(row)">删除</div>
|
|
53
|
+ </div>
|
|
54
|
+ </template>
|
|
55
|
+ </Table>
|
|
56
|
+ </div>
|
|
57
|
+ <div class="page_wrap">
|
|
58
|
+ <Page
|
|
59
|
+ :transfer="true"
|
|
60
|
+ :total="searchForm.total"
|
|
61
|
+ :current="searchForm.page"
|
|
62
|
+ :page-size="searchForm.size"
|
|
63
|
+ :page-size-opts="[10, 20, 40, 60]"
|
|
64
|
+ @on-change="pageChange"
|
|
65
|
+ @on-page-size-change="pageSizeChange"
|
|
66
|
+ show-total
|
|
67
|
+ show-sizer
|
|
68
|
+ ></Page>
|
|
69
|
+ </div>
|
|
70
|
+ <!-- 新建/编辑 -->
|
|
71
|
+ <Modal
|
|
72
|
+ class="modal1"
|
|
73
|
+ :mask-closable="false"
|
|
74
|
+ v-model="addInfo.show"
|
|
75
|
+ :title="addInfo.daid ? '编辑' : '新建'"
|
|
76
|
+ >
|
|
77
|
+ <Form
|
|
78
|
+ v-if="addInfo.show"
|
|
79
|
+ ref="addForm"
|
|
80
|
+ :model="addInfo"
|
|
81
|
+ :rules="rules"
|
|
82
|
+ :label-width="100"
|
|
83
|
+ >
|
|
84
|
+ <FormItem label="所属区域" prop="regionid">
|
|
85
|
+ <Select
|
|
86
|
+ :transfer="true"
|
|
87
|
+ v-model="addInfo.regionid"
|
|
88
|
+ placeholder="请选择所属区域"
|
|
89
|
+ >
|
|
90
|
+ <Option
|
|
91
|
+ v-for="regionItem in searchForm.regionList"
|
|
92
|
+ :value="regionItem.regionid"
|
|
93
|
+ :key="regionItem.regionid"
|
|
94
|
+ >{{ regionItem.regionName }}</Option
|
|
95
|
+ >
|
|
96
|
+ </Select>
|
|
97
|
+ </FormItem>
|
|
98
|
+ <FormItem label="SN序列号" prop="sn">
|
|
99
|
+ <Input v-model="addInfo.sn" placeholder="请输入SN序列号"></Input>
|
|
100
|
+ </FormItem>
|
|
101
|
+ <FormItem v-if="addInfo.daid" label="所属状态" prop="snState">
|
|
102
|
+ <RadioGroup v-model="addInfo.snState">
|
|
103
|
+ <Radio :label="0">正常</Radio>
|
|
104
|
+ <Radio :label="1">注销</Radio>
|
|
105
|
+ </RadioGroup>
|
|
106
|
+ </FormItem>
|
|
107
|
+ </Form>
|
|
108
|
+ <div slot="footer">
|
|
109
|
+ <Button @click="addInfo.show = false">取消</Button>
|
|
110
|
+ <Button @click="saveAddInfo()" type="primary" class="primary_btn"
|
|
111
|
+ >保存</Button
|
|
112
|
+ >
|
|
113
|
+ </div>
|
|
114
|
+ </Modal>
|
|
115
|
+ <Modal
|
|
116
|
+ class="modal1"
|
|
117
|
+ :mask-closable="false"
|
|
118
|
+ v-model="importInfo.show"
|
|
119
|
+ title="导入"
|
|
120
|
+ >
|
|
121
|
+ <Form
|
|
122
|
+ v-if="importInfo.show"
|
|
123
|
+ ref="importForm"
|
|
124
|
+ :model="importInfo"
|
|
125
|
+ :rules="rules"
|
|
126
|
+ :label-width="100"
|
|
127
|
+ >
|
|
128
|
+ <FormItem label="所属区域" prop="regionid">
|
|
129
|
+ <Select
|
|
130
|
+ :transfer="true"
|
|
131
|
+ v-model="importInfo.regionid"
|
|
132
|
+ placeholder="请选择所属区域"
|
|
133
|
+ >
|
|
134
|
+ <Option
|
|
135
|
+ v-for="regionItem in searchForm.regionList"
|
|
136
|
+ :value="regionItem.regionid"
|
|
137
|
+ :key="regionItem.regionid"
|
|
138
|
+ >{{ regionItem.regionName }}</Option
|
|
139
|
+ >
|
|
140
|
+ </Select>
|
|
141
|
+ </FormItem>
|
|
142
|
+ <FormItem label="上传文件" class="require">
|
|
143
|
+ <div style="display: flex">
|
|
144
|
+ <Upload
|
|
145
|
+ action
|
|
146
|
+ :show-upload-list="false"
|
|
147
|
+ :before-upload="
|
|
148
|
+ (file) => {
|
|
149
|
+ upLoadExcel(file);
|
|
150
|
+ return false;
|
|
151
|
+ }
|
|
152
|
+ "
|
|
153
|
+ accept=".xlsx,.xls"
|
|
154
|
+ >
|
|
155
|
+ <Button type="primary" class="primary_btn">上传excel</Button>
|
|
156
|
+ </Upload>
|
|
157
|
+ <div style="margin-left: 16px; color: #7c8db5">
|
|
158
|
+ 支持格式:xlsx/xls文件
|
|
159
|
+ </div>
|
|
160
|
+ </div>
|
|
161
|
+ <div v-if="importInfo.file">{{ importInfo.file.name }}</div>
|
|
162
|
+ </FormItem>
|
|
163
|
+ </Form>
|
|
164
|
+ <div slot="footer">
|
|
165
|
+ <Button @click="importInfo.show = false">取消</Button>
|
|
166
|
+ <Button @click="saveFileInfo()" type="primary" class="primary_btn"
|
|
167
|
+ >保存</Button
|
|
168
|
+ >
|
|
169
|
+ </div>
|
|
170
|
+ </Modal>
|
|
171
|
+ </div>
|
|
172
|
+</template>
|
|
173
|
+
|
|
174
|
+<script>
|
|
175
|
+import { region_list_sel_pt } from "@/api/region";
|
|
176
|
+import {
|
|
177
|
+ deviceAuth_list,
|
|
178
|
+ deviceAuth_add,
|
|
179
|
+ deviceAuth_edit,
|
|
180
|
+ deviceAuth_delete,
|
|
181
|
+ deviceAuth_batch_delete,
|
|
182
|
+ deviceAuth_import
|
|
183
|
+} from "@/api/device_manager";
|
|
184
|
+export default {
|
|
185
|
+ data() {
|
|
186
|
+ return {
|
|
187
|
+ rules: {
|
|
188
|
+ regionid: [
|
|
189
|
+ {
|
|
190
|
+ required: true,
|
|
191
|
+ type: "number",
|
|
192
|
+ message: "请选择所属区域",
|
|
193
|
+ trigger: "change"
|
|
194
|
+ }
|
|
195
|
+ ],
|
|
196
|
+ sn: [
|
|
197
|
+ {
|
|
198
|
+ required: true,
|
|
199
|
+ message: "请输入SN序列号",
|
|
200
|
+ trigger: "change"
|
|
201
|
+ }
|
|
202
|
+ ],
|
|
203
|
+ snState: [
|
|
204
|
+ {
|
|
205
|
+ required: true,
|
|
206
|
+ type: "number",
|
|
207
|
+ message: "请选择所属状态",
|
|
208
|
+ trigger: "change"
|
|
209
|
+ }
|
|
210
|
+ ]
|
|
211
|
+ },
|
|
212
|
+ addInfo: {
|
|
213
|
+ daid: null,
|
|
214
|
+ rversion: null,
|
|
215
|
+ show: false,
|
|
216
|
+ regionid: null,
|
|
217
|
+ sn: null,
|
|
218
|
+ snState: null
|
|
219
|
+ },
|
|
220
|
+ searchForm: {
|
|
221
|
+ regionid: 0,
|
|
222
|
+ regionList: [],
|
|
223
|
+ sn: "",
|
|
224
|
+ page: 1,
|
|
225
|
+ size: 10,
|
|
226
|
+ list: [],
|
|
227
|
+ total: 0
|
|
228
|
+ },
|
|
229
|
+ importInfo: {
|
|
230
|
+ show: false,
|
|
231
|
+ regionid: null,
|
|
232
|
+ file: null
|
|
233
|
+ },
|
|
234
|
+ // 批量删除
|
|
235
|
+ batchDeleteList: [],
|
|
236
|
+ columns: [
|
|
237
|
+ {
|
|
238
|
+ type: "selection",
|
|
239
|
+ width: 60,
|
|
240
|
+ align: "center"
|
|
241
|
+ },
|
|
242
|
+ {
|
|
243
|
+ title: "序号",
|
|
244
|
+ align: "center",
|
|
245
|
+ width: 70,
|
|
246
|
+ render: (h, params) => {
|
|
247
|
+ return h(
|
|
248
|
+ "span",
|
|
249
|
+ params.index +
|
|
250
|
+ (this.searchForm.page - 1) * this.searchForm.size +
|
|
251
|
+ 1
|
|
252
|
+ );
|
|
253
|
+ }
|
|
254
|
+ },
|
|
255
|
+ {
|
|
256
|
+ title: "所属区域",
|
|
257
|
+ key: "regionName",
|
|
258
|
+ align: "center"
|
|
259
|
+ },
|
|
260
|
+ {
|
|
261
|
+ title: "SN",
|
|
262
|
+ key: "sn",
|
|
263
|
+ align: "center"
|
|
264
|
+ },
|
|
265
|
+ {
|
|
266
|
+ title: "状态",
|
|
267
|
+ slot: "snStateSlot",
|
|
268
|
+ width: 90,
|
|
269
|
+ align: "center"
|
|
270
|
+ },
|
|
271
|
+ {
|
|
272
|
+ title: "创建人",
|
|
273
|
+ key: "createname",
|
|
274
|
+ align: "center"
|
|
275
|
+ },
|
|
276
|
+ {
|
|
277
|
+ title: "创建时间",
|
|
278
|
+ key: "createtime",
|
|
279
|
+ width: 190,
|
|
280
|
+ align: "center"
|
|
281
|
+ },
|
|
282
|
+ {
|
|
283
|
+ title: "操作",
|
|
284
|
+ slot: "actionSlot",
|
|
285
|
+ width: 130,
|
|
286
|
+ align: "center"
|
|
287
|
+ }
|
|
288
|
+ ]
|
|
289
|
+ };
|
|
290
|
+ },
|
|
291
|
+ created() {
|
|
292
|
+ this.getRegionList();
|
|
293
|
+ this.searchList();
|
|
294
|
+ },
|
|
295
|
+ computed: {
|
|
296
|
+ powerParams() {
|
|
297
|
+ return this.$store.getters.powerParams;
|
|
298
|
+ }
|
|
299
|
+ },
|
|
300
|
+ methods: {
|
|
301
|
+ // 获取搜索区域列表
|
|
302
|
+ getRegionList() {
|
|
303
|
+ region_list_sel_pt({}).then((data) => {
|
|
304
|
+ if (data.code === 0) {
|
|
305
|
+ this.searchForm.regionList = data.obj;
|
|
306
|
+ } else {
|
|
307
|
+ this.$Message.error(data.msg);
|
|
308
|
+ }
|
|
309
|
+ });
|
|
310
|
+ },
|
|
311
|
+ // 搜索
|
|
312
|
+ searchList() {
|
|
313
|
+ this.searchForm.page = 1;
|
|
314
|
+ this.getList();
|
|
315
|
+ },
|
|
316
|
+ // 页码改变
|
|
317
|
+ pageChange(page) {
|
|
318
|
+ this.searchForm.page = page;
|
|
319
|
+ this.getList();
|
|
320
|
+ },
|
|
321
|
+ // 每页显示数量改变
|
|
322
|
+ pageSizeChange(size) {
|
|
323
|
+ this.searchForm.size = size;
|
|
324
|
+ this.searchForm.page = 1;
|
|
325
|
+ this.getList();
|
|
326
|
+ },
|
|
327
|
+ tableSelectionChange(list) {
|
|
328
|
+ this.batchDeleteList = list.map((item) => {
|
|
329
|
+ return {
|
|
330
|
+ daid: item.daid
|
|
331
|
+ };
|
|
332
|
+ });
|
|
333
|
+ },
|
|
334
|
+ // 获取列表
|
|
335
|
+ getList() {
|
|
336
|
+ this.batchDeleteList = [];
|
|
337
|
+ deviceAuth_list({
|
|
338
|
+ rtype: this.powerParams.rtype,
|
|
339
|
+ objectid: this.powerParams.objectid,
|
|
340
|
+ regionid: this.searchForm.regionid,
|
|
341
|
+ page: this.searchForm.page,
|
|
342
|
+ size: this.searchForm.size,
|
|
343
|
+ sn: this.searchForm.sn
|
|
344
|
+ }).then((data) => {
|
|
345
|
+ if (data.code === 0) {
|
|
346
|
+ this.searchForm.list = data.obj.data;
|
|
347
|
+ this.searchForm.total = data.obj.total;
|
|
348
|
+ } else {
|
|
349
|
+ this.$Message.error(data.msg);
|
|
350
|
+ }
|
|
351
|
+ });
|
|
352
|
+ },
|
|
353
|
+ toImport() {
|
|
354
|
+ this.importInfo = {
|
|
355
|
+ show: true,
|
|
356
|
+ regionid: null,
|
|
357
|
+ file: null
|
|
358
|
+ };
|
|
359
|
+ },
|
|
360
|
+ upLoadExcel(file) {
|
|
361
|
+ this.importInfo.file = null;
|
|
362
|
+ let str = file.name.split(".");
|
|
363
|
+ let suffix = str[str.length - 1];
|
|
364
|
+ suffix = suffix.toLowerCase();
|
|
365
|
+ if (suffix !== "xlsx" && suffix !== "xls") {
|
|
366
|
+ this.$Message.warning("文件格式不正确");
|
|
367
|
+ return;
|
|
368
|
+ }
|
|
369
|
+ this.importInfo.file = file;
|
|
370
|
+ },
|
|
371
|
+ saveFileInfo() {
|
|
372
|
+ this.$refs.importForm.validate((valid) => {
|
|
373
|
+ if (valid) {
|
|
374
|
+ if (!this.importInfo.file) {
|
|
375
|
+ this.$Message.error("请上传文件");
|
|
376
|
+ return;
|
|
377
|
+ }
|
|
378
|
+ this.importInfo.show = false;
|
|
379
|
+ let formData = new FormData();
|
|
380
|
+ formData.append("file", this.importInfo.file);
|
|
381
|
+ formData.append("regionid", this.importInfo.regionid);
|
|
382
|
+ deviceAuth_import(formData).then((data) => {
|
|
383
|
+ if (data.code === 0) {
|
|
384
|
+ this.searchList();
|
|
385
|
+ this.$Message.success(data.msg);
|
|
386
|
+ } else {
|
|
387
|
+ this.$Message.error(data.msg);
|
|
388
|
+ }
|
|
389
|
+ });
|
|
390
|
+ }
|
|
391
|
+ });
|
|
392
|
+ },
|
|
393
|
+ toAdd() {
|
|
394
|
+ this.addInfo = {
|
|
395
|
+ daid: null,
|
|
396
|
+ rversion: null,
|
|
397
|
+ show: true,
|
|
398
|
+ regionid: null,
|
|
399
|
+ sn: null,
|
|
400
|
+ snState: null
|
|
401
|
+ };
|
|
402
|
+ },
|
|
403
|
+ saveAddInfo() {
|
|
404
|
+ this.$refs.addForm.validate((valid) => {
|
|
405
|
+ if (valid) {
|
|
406
|
+ this.addInfo.show = false;
|
|
407
|
+ let api =
|
|
408
|
+ this.addInfo.daid && this.addInfo.rversion
|
|
409
|
+ ? deviceAuth_edit
|
|
410
|
+ : deviceAuth_add;
|
|
411
|
+ let form = {
|
|
412
|
+ rtype: this.powerParams.rtype,
|
|
413
|
+ objectid: this.powerParams.objectid,
|
|
414
|
+ regionid: this.addInfo.regionid,
|
|
415
|
+ sn: this.addInfo.sn
|
|
416
|
+ };
|
|
417
|
+ if (this.addInfo.daid && this.addInfo.rversion) {
|
|
418
|
+ form.daid = this.addInfo.daid;
|
|
419
|
+ form.snState = this.addInfo.snState;
|
|
420
|
+ form.rversion = this.addInfo.rversion;
|
|
421
|
+ }
|
|
422
|
+ api(form).then((data) => {
|
|
423
|
+ if (data.code === 0) {
|
|
424
|
+ this.searchList();
|
|
425
|
+ this.$Message.success(data.msg);
|
|
426
|
+ } else {
|
|
427
|
+ this.$Message.error(data.msg);
|
|
428
|
+ }
|
|
429
|
+ });
|
|
430
|
+ }
|
|
431
|
+ });
|
|
432
|
+ },
|
|
433
|
+ toEdit(row) {
|
|
434
|
+ this.addInfo = {
|
|
435
|
+ daid: row.daid,
|
|
436
|
+ rversion: row.rversion,
|
|
437
|
+ show: true,
|
|
438
|
+ regionid: row.regionid,
|
|
439
|
+ sn: row.sn,
|
|
440
|
+ snState: row.snState
|
|
441
|
+ };
|
|
442
|
+ },
|
|
443
|
+ // 删除
|
|
444
|
+ toDel(row) {
|
|
445
|
+ this.$Modal.confirm({
|
|
446
|
+ title: "提示",
|
|
447
|
+ content: `您确定删除【${row.sn}】吗?`,
|
|
448
|
+ onOk: () => {
|
|
449
|
+ deviceAuth_delete({
|
|
450
|
+ rtype: this.powerParams.rtype,
|
|
451
|
+ objectid: this.powerParams.objectid,
|
|
452
|
+ daid: row.daid,
|
|
453
|
+ rversion: row.rversion
|
|
454
|
+ }).then((data) => {
|
|
455
|
+ if (data.code === 0) {
|
|
456
|
+ this.searchList();
|
|
457
|
+ this.$Message.success(data.msg);
|
|
458
|
+ } else {
|
|
459
|
+ this.$Message.error(data.msg);
|
|
460
|
+ }
|
|
461
|
+ });
|
|
462
|
+ },
|
|
463
|
+ onCancel: () => {}
|
|
464
|
+ });
|
|
465
|
+ },
|
|
466
|
+ toBatchDelete() {
|
|
467
|
+ if (this.batchDeleteList.length === 0) {
|
|
468
|
+ this.$Message.error("请选择数据");
|
|
469
|
+ return;
|
|
470
|
+ }
|
|
471
|
+ this.$Modal.confirm({
|
|
472
|
+ title: "提示",
|
|
473
|
+ content: `您确定删除选中数据吗?`,
|
|
474
|
+ onOk: () => {
|
|
475
|
+ deviceAuth_batch_delete(this.batchDeleteList).then((data) => {
|
|
476
|
+ if (data.code === 0) {
|
|
477
|
+ this.searchList();
|
|
478
|
+ this.$Message.success(data.msg);
|
|
479
|
+ } else {
|
|
480
|
+ this.$Message.error(data.msg);
|
|
481
|
+ }
|
|
482
|
+ });
|
|
483
|
+ },
|
|
484
|
+ onCancel: () => {}
|
|
485
|
+ });
|
|
486
|
+ }
|
|
487
|
+ }
|
|
488
|
+};
|
|
489
|
+</script>
|
|
490
|
+
|
|
491
|
+<style lang="less" scoped>
|
|
492
|
+.search_header {
|
|
493
|
+ display: flex;
|
|
494
|
+ justify-content: space-between;
|
|
495
|
+ align-items: center;
|
|
496
|
+ margin: 16px 16px;
|
|
497
|
+ .search_left {
|
|
498
|
+ display: flex;
|
|
499
|
+ justify-content: flex-start;
|
|
500
|
+ align-items: center;
|
|
501
|
+ }
|
|
502
|
+ .search_right {
|
|
503
|
+ display: flex;
|
|
504
|
+ justify-content: flex-start;
|
|
505
|
+ align-items: center;
|
|
506
|
+ .primary_btn {
|
|
507
|
+ margin-left: 16px;
|
|
508
|
+ }
|
|
509
|
+ }
|
|
510
|
+}
|
|
511
|
+</style>
|