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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
<template>
<div class="page">
<div class="page-header">
<div>
<span style="font-size: 14px"
><b>设备列表</b> (
<span style="margin-right: 6px">{{ siteName }}</span> 站点编码:{{
siteCode
}}
)</span
>
<el-link
style="margin-left: 10px"
type="primary"
@click="switchMap"
:underline="false"
>地图模式
</el-link
>
</div>
<el-button style="margin-right: 10px" @click="$router.back()" size="small"
>返回上一级
</el-button
>
</div>
<el-divider></el-divider>
<LayoutTable :data="tableData" :config="tableConfig">
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="handleImport"
>导入
</el-button
>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="doExport"
:disabled="isExport"
>导出
</el-button
>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="batchActiveDevice"
>批量激活
</el-button
>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="batchUpdateHall"
>更新大厅
</el-button
>
<el-button
slot="table-head-left2"
style="margin-left: 10px"
icon="el-icon-tickets"
size="mini"
@click="batchRestartApp"
>批量重启
</el-button
>
<el-tag
slot="table-body-head"
size="mini"
class="cursord"
@click="changeStatAll()"
>设备总数:{{ tableData.totalCount }}台
</el-tag
>
<el-tag
slot="table-body-head"
size="mini"
style="margin: 5px"
type="success"
class="cursord"
@click="changeStat(2)"
>在线:{{ tableData.onlineCount }}台
</el-tag
>
<el-tag
slot="table-body-head"
size="mini"
style="margin: 5px"
type="danger"
class="cursord"
@click="changeStat(1)"
>离线:{{ tableData.offlineCount }}台
</el-tag
>
<el-tag
slot="table-body-head"
size="mini"
style="margin: 5px"
type="danger"
class="cursord"
@click="changeStatEnabled( 0)"
>停用:{{ tableData.stopCount }}台
</el-tag
>
<el-tag
slot="table-body-head"
size="mini"
style="margin: 5px"
type="danger"
class="cursord"
@click="changeStat(0)"
>未激活:{{ tableData.unActiveCount }}台
</el-tag
>
</LayoutTable>
<!-- 设备导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?siteId=' + siteId"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport"/>
是否更新已经存在的数据
<el-link
type="primary"
style="font-size: 14px"
@click="downloadTemplate"
>下载模板
</el-link
>
</div>
<div class="el-upload__tip" style="color: red" slot="tip">
提示:仅允许导入“xls”或“xlsx”格式文件!
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
<!-- 站点修改对话框 -->
<el-dialog
:title="tree.title"
:visible.sync="tree.open"
width="40%"
append-to-body
>
<span style="font-size: 13px"
><b>当前站点:</b> (<el-link
style="margin-left: 10px"
type="primary"
:underline="false"
>{{ siteName }}</el-link
>
站点编码:{{ siteCode }} )</span
>
<el-divider></el-divider>
<el-scrollbar style="height: 100%">
<el-tree
size="mini"
ref="siteTree"
:data="areaData"
id="el-tree"
node-key="id"
indent="4"
:props="treeProps"
:load="loadNode"
highlight-current
default-expand-all
:expand-on-click-node="false"
:render-content="renderContent"
@node-click="handleNodeClick"
>
</el-tree>
</el-scrollbar>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="updateSiteConform">确 定</el-button>
<el-button @click="tree.open = false">取 消</el-button>
</div>
</el-dialog>
<!-- 大厅修改对话框 -->
<el-dialog
:title="hallDialog.title"
:visible.sync="hallDialog.open"
width="40%"
append-to-body
>
<Field
label="站点大厅"
v-model="hallId"
type="select"
:enumData="tableData.dict.hallId"
placeholder="请选择所属大厅"
/>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="updateBatchHallConform">确 定</el-button>
<el-button @click="tree.open = false">取 消</el-button>
</div>
</el-dialog>
<!-- 查看二维码弹窗 -->
<el-dialog
title="设备二维码"
:visible.sync="qrCodeDialog.visible"
width="350px"
>
<img :src="qrCodeDialog.qrCode"/>
<p style="word-wrap: break-word">{{ qrCodeDialog.qrCodeUrl }}</p>
</el-dialog>
<!-- <dialog-show ref="dialogform" @ok="getData" /> -->
<drawer-show ref="drawerform" @ok="getData"/>
<drawer-view ref="drawerViewform" @ok="getData"/>
</div>
</template>
<script>
/** 表单弹出框模式需引入 */
import drawerView from "./drawerview";
import drawerShow from "./drawershow";
import table from "@/assets/mixins/table";
import tree from "@/assets/mixins/tree";
export default {
name: "Device",
components: {drawerShow, drawerView},
mixins: [table, tree],
created() {
this.siteId = this.$route.query.siteId;
this.info = this.$route.query;
this.query = {siteId: this.siteId};
this.$get("/sitestat/siteInfo", {
siteId: this.siteId,
})
.then((res) => {
if (res.code == 1) {
//this.info=res.data
this.siteName = res.data.siteName;
this.siteCode = res.data.siteCode;
}
})
.catch((error) => {
this.$message.error(error.message);
});
// this.$router.push({ query: {siteId:this.siteId } });
},
methods: {
switchMap() {
this.$router.push({
path: "/sitestat/mapDetail",
query: this.info,
});
},
/** 导入 */
handleImport() {
this.upload.title = "设备导入";
this.upload.open = true;
},
/** 下载模板操作 */
downloadTemplate() {
this.isExport = true;
this.$download(
"/device/downloadTemplate",
{},
{type: "excel", fileName: "设备导入模板"}
)
.then(() => (this.isExport = false))
.catch((error) => {
this.isExport = false;
this.$message.error(error.message);
});
},
/** 文件上传中处理 */
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
/** 文件上传成功处理 */
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
this.getData();
},
/** 提交上传文件 */
submitFileForm() {
this.$refs.upload.submit();
},
/** 导出Excel */
doExport() {
this.isExport = true;
this.$download(
"/device/exportExcel",
{
idList: this.selection,
deviceName: this.$route.query["deviceName"],
siteId: this.$route.query["siteId"],
},
{type: "excel", fileName: "设备表"}
)
.then(() => (this.isExport = false))
.catch((error) => {
this.isExport = false;
this.$message.error(error.message);
});
},
/** 重写新增方法 */
toAdd(row) {
//this.$refs.dialogform.add(row);
row.siteId = this.siteId;
row.siteName = this.siteName;
row.siteCode = this.siteCode;
this.$refs.drawerform.add(row);
},
/** 重写编辑方法 */
toEdit(row) {
row.siteName = this.siteName;
row.siteCode = this.siteCode;
this.$refs.drawerform.edit(row);
},
/** 重写查看方法 */
toView(row) {
this.$refs.drawerViewform.view(row);
},
changeStatAll() {
delete this.query["productId"]
delete this.query["deviceName"]
delete this.query["deviceCode"]
delete this.query["deviceStatus"]
this.query["page"] = 1
this.query = Object.assign(this.query, {
deviceStatusList: [1, 2],
enabled: 1,
});
this.getData();
},
changeStatEnabled(enabled) {
//去除其它条件
this.query["page"] = 1
this.query = Object.assign(this.query, {
deviceStatusList: [1, 2],
enabled: enabled,
});
this.getData();
},
changeStat(val) {
//去除其它条件
// delete this.query["productId"]
//delete this.query["deviceName"]
// delete this.query["deviceCode"]
this.query = Object.assign(this.query, {deviceStatus: val});
this.query["page"] = 1
this.getData();
},
activeDevice(row) {
this.$post("/device/active", {
deviceCode: row.deviceCode,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("激活设备成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
batchActiveDevice(row) {
this.$post("/device/batchActive", {
idList: this.selection,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("批量激活设备成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
batchUpdateHall() {
this.hallId=null;
this.hallName=""
this.hallDialog.title = "设备所属大厅设置";
this.hallDialog.open = true;
},
updateBatchHallConform(row) {
this.hallName=this.tableData.dict.hallId[this.hallId];
this.$post("/device/batchUpdateHall", {
idList: this.selection,
hallId: this.hallId,
hallName: this.hallName
})
.then((res) => {
if (res.code == 1) {
this.$message.success("批量更新大厅设备成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
batchRestartApp(row) {
this.$post("/device/batchRestartApp", {
idList: this.selection,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("批量重启设备应用成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
restartApp(row) {
this.$post("/device/batchRestartApp", {
idList: [row.id],
})
.then((res) => {
if (res.code == 1) {
this.$message.success("重启设备应用成功!");
this.getData();
}
})
.catch((error) => {
this.$message.error(error.message);
});
},
updateSite(row) {
this.$get("/sitestat/siteTree", {}).then(({data}) => {
this.areaData = data.siteTree;
this.tree.open = true;
this.tree.id = row.id;
});
},
handleNodeClick(node) {
this.currentNode = node;
},
updateSiteConform() {
if (this.currentNode.type != "site") {
this.$message.error("请选择正确的站点!");
return;
}
this.loading = true;
this.$post("/device/save", {
id: this.tree.id,
siteId: this.currentNode.id,
siteCode: this.currentNode.siteCode,
siteName: this.currentNode.label,
})
.then((res) => {
if (res.code == 1) {
this.$message.success("编辑站点成功!");
this.tree.open = false;
this.getData();
}
})
.catch((error) => {
this.loading = false;
this.$message.error(error.message);
});
},
// 操作菜单状态
changeStatus(row, column) {
return (
<device-switch
confirm
url="/device/enable"
row={row}
onChange={this.statusChange}
value={this.tableData.data}
onInput={(data) => {
this.tableData.data = data;
}}
/>
);
},
async viewQrCode(id) {
try {
const {qrCode, qrCodeUrl} = await this.$post("/device/viewQrCode", {
id: id,
});
this.qrCodeDialog.qrCode = qrCode;
this.qrCodeDialog.qrCodeUrl = qrCodeUrl;
this.qrCodeDialog.visible = true;
} catch (error) {
this.$message.error(error.message);
}
},
},
data() {
return {
//二维码
qrCodeDialog: {
visible: false,
qrCode: "",
qrCodeUrl: "",
},
// 用户导入参数
upload: {
// 是否显示弹出层(设备导入)
open: false,
// 弹出层标题(设备导入)
title: "导入设备数据",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的数据
updateSupport: 0,
// 上传的地址
url: "/m/device/importData",
},
hallDialog: {
// 是否显示弹出层(设备导入)
open: false,
// 弹出层标题(设备导入)
title: "所属大厅选择",
},
info: {},
// 站点树
tree: {
// 是否显示弹出层(设备导入)
open: false,
// 弹出层标题(设备导入)
title: "修改站点",
},
isExport: false,
siteId: null,
siteName: "",
siteCode: "",
updateSiteId: null,
updateSiteName: "",
updateSiteCode: "",
hallId: null,
hallName: "",
config: {
getsocketData: null,
search: [
{
name: "deviceName",
type: "text",
label: "设备名称",
fuzzy: true,
},
{
name: "deviceCode",
type: "text",
label: "设备编码",
fuzzy: true,
},
{
name: "productId",
type: "select",
label: "设备类型",
},
],
columns: [
{
type: "selection",
align: "center",
reserveSelection: true,
width: 60,
},
{type: "index", label: "序号", align: "center", width: 50},
{label: "设备名称", align: "center", prop: "deviceName"},
{
label: "设备类型",
align: "center",
prop: "productId",
formatter: this.formatter,
},
{label: "设备编码", align: "center", prop: "deviceCode"},
{ label: "所属大厅", prop: "hallName"},
{
label: "设备生产商",
align: "center",
prop: "deviceFirmId",
formatter: this.formatter,
width: 250,
},
{label: "负责人", align: "center", prop: "leadingOfficial"},
{
label: "联系电话",
align: "center",
prop: "leadingOfficialTelephone",
},
{
label: "状态 ",
align: "center",
prop: "deviceStatus",
formatter: this.formatterStatus,
},
{
label: "利旧设备",
align: "center",
prop: "source",
formatter: this.formatterYES,
},
{
prop: "enabled",
align: "center",
label: "启用/停用",
width: 100,
formatter: this.changeStatus,
},
{
label: "创建时间",
align: "center",
prop: "createTime",
formatter: this.formatterDate,
},
{
label: "操作",
align: "center",
width: 240,
formatter: (row) => {
return (
<div>
<table-buttons
noAdd
row={row}
onEdit={this.toEdit}
onView={this.toView}
onDel={this.toDel}
/>
<span> </span>
{row.deviceStatus === 0 ? (
<el-button
size="mini"
type="text"
icon="el-icon-open"
onClick={() => {
this.activeDevice(row);
}}
>
激活
</el-button>
) : (
""
)}
<span> </span>
<el-button
type="text"
size="mini"
onClick={() => this.viewQrCode(row.id)}
>
二维码
</el-button>
<span> </span>
<el-button
type="text"
size="mini"
onClick={() => this.restartApp(row)}
>
重启
</el-button>
</div>
);
},
},
],
},
};
},
};
</script>
<style lang="less" scoped>
.page-header {
height: 40px;
display: flex;
justify-content: space-between;
align-items: center;
}
.el-divider--horizontal {
margin: 2px 0;
background: 0 0;
border-top: 1px solid #e8eaec;
}
.cursord {
cursor: pointer;
}
</style>