index.vue
24.1 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
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
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
<!--
* 功能:变量列表
* 作者:曹晓桐
* 日期:2023-11-7
-->
<template>
<div>
<a-card class="content">
<a-row>
<a-col>
<!-- tab 切换 -->
<a-tabs v-model:active-key="tabsActiveKey" @change="handleTabsChange">
<a-tab-pane v-for="(item, index) in tabsList" :key="item.key" :title="item.title">
</a-tab-pane>
</a-tabs>
</a-col>
</a-row>
<!-- 搜索条件 -->
<a-row>
<a-col :flex="1">
<a-form :model="searchModel" :label-col-props="{ span: 6 }" :wrapper-col-props="{ span: 18 }"
label-align="left" auto-label-width>
<a-row :gutter="16">
<a-col :span="6">
<a-form-item field="catalogId" label="设备名称">
<a-tree-select allow-clear allow-search v-model="searchModel.deviceId"
:fieldNames="catalogIdFieldNames" :data="deviceData" placeholder="请选择设备"></a-tree-select>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item field="deviceName" label="变量名称">
<a-input v-model="searchModel.varName" placeholder="变量名称,支持模糊查询" allow-clear />
</a-form-item>
</a-col>
<a-col :span="6">
<a-space direction="vertical" :size="18">
<a-button type="primary" @click="search">
<template #icon>
<icon-search />
</template>
搜索
</a-button>
</a-space>
</a-col>
</a-row>
</a-form>
</a-col>
</a-row>
<!-- 分割线 -->
<a-divider style="margin-top: 0" />
<!-- 按钮 -->
<a-row style="margin-bottom: 20px">
<a-col :span="12">
<a-space>
<a-button type="primary" @click="handleDeviceVarAdd">
<template #icon>
<icon-plus />
</template>
添加变量
</a-button>
<a-button type="primary" style="background-color:rgb(var(--arcoblue-4))" @click="handleExport">
<template #icon>
<icon-download />
</template>
变量导出
</a-button>
<a-upload :show-file-list="false" :action="(`${baseUrl}/system/device-var/importData`)"
@success="handleUploadSuccess" :on-before-upload="handleBeforeUpload" :headers="headers"
accept=".xlsx, .xls">
<template #upload-button>
<a-button type="primary" style="background-color: rgb(var(--red-5));">
<template #icon>
<icon-upload />
</template>
变量导入
</a-button>
</template>
</a-upload>
</a-space>
</a-col>
</a-row>
<!-- 表格 start -->
<a-table size="medium" row-key="id" :loading="loading" :bordered="{ wrapper: true, cell: true }"
:pagination="pagination" :columns="tabColumns" :scroll="{ x: 2450 }" :data="renderData"
@page-change="onPageChange" @page-size-change="onPageSizeChange">
<!-- 是否监控 -->
<template #isMonitor="{ record }">
<a-tag v-if="record.isMonitor == 0" color="rgb(var(--primary-6))">否</a-tag>
<a-tag v-else color="rgb(var(--red-6))">是</a-tag>
</template>
<!-- 是否累积 -->
<template #isAccumulation="{ record }">
<a-tag v-if="record.isAccumulation == 0" color="rgb(var(--primary-6))">否</a-tag>
<a-tag v-else color="rgb(var(--red-6))">是</a-tag>
</template>
<!-- 数据来源-->
<template #origin="{ record }">
<dict-tag :options="sys_data_origin" :value="record.origin" />
</template>
<!-- 数据类型-->
<template #dataType="{ record }">
<dict-tag :options="sys_data_type" :value="record.dataType" />
</template>
<!-- 存盘周期-->
<template #saveCycle="{ record }">
<dict-tag :options="sys_save_cycle" :value="record.saveCycle" />
</template>
<!-- 状态 -->
<template #stopFlag="{ record }">
<stop-flag :value="record.stopFlag" />
</template>
<template #operate="{ record }">
<a-button size="small" type="text" @click="handleMonitor(record)"
:status="record.isMonitor == 0 ? 'normal' : 'warning'">
{{ record.isMonitor == 0 ? '开启监控' : '关闭监控' }}
</a-button>
<a-button size="small" type="text" @click="handleStopFlag(record)"
:status="record.stopFlag == 1 ? 'normal' : 'warning'">
{{ record.stopFlag == 0 ? $t('global.forbidden') : $t('global.enable') }}
</a-button>
<a-button size="small" type="text" @click="handleDeviceVarUpdate(record.id)">编辑</a-button>
<a-button size="small" type="text" status="danger" @click="handleDelete(record)">删除 </a-button>
<a-button size="small" type="text" @click="handleDeviceDetail(record)">详情</a-button>
</template>
</a-table>
<!-- 表格 end -->
<!-- 操作弹框 start -->
<a-modal width="450px" v-model:visible="operateModalModel.visible">
<template #title>
<icon-close-circle v-if="operateModalModel.type == 1" size="18"
style="color: rgb(var(--red-6)); margin-right: 5px" />
<icon-exclamation-circle v-else size="18" style="color: rgb(var(--orange-6)); margin-right: 5px" />
确认提示
</template>
<div v-if="operateModalModel.type < 2" style="text-align: center;">是否确认{{ operateModalModel.title }}名称为【{{
operateModalModel.name }}】的数据项?</div>
<div v-if="operateModalModel.type == 2" style="text-align: center;">是否确认为【{{ operateModalModel.name }}】数据{{
operateModalModel.title }}?</div>
<template #footer>
<div style="text-align: center">
<a-space>
<a-button type="primary" status="danger" @click="handleOperateModelCancle">取消</a-button>
<a-button type="primary" @click="handleOperateModelOk">确认</a-button>
</a-space>
</div>
</template>
</a-modal>
<!-- 操作弹框 end -->
<!-- 详情右弹层 start -->
<a-drawer :width="1000" :title="formDrawer.title" :visible="formDrawer.visible" hide-cancel
@cancel="handleDrawerCancel" @ok="handleDrawerCancel" unmountOnClose :mask-closable="false">
<a-row :gutter="24" style="padding: 0 20px;">
<a-col :span="12">
<a-divider orientation="left">变量信息</a-divider>
<a-descriptions :align="{ label: 'right' }" :label-style="{
color: 'rgb(var(--color-neutral-10))',
}" :data="formDrawer.varInfo" :column="1" size="large">
<template #value="{ value }">
<a-skeleton v-if="formDrawer.loading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ value }}</span>
</template>
</a-descriptions>
<a-divider orientation="left">数据来源</a-divider>
<a-descriptions :align="{ label: 'right' }" :label-style="{ color: 'rgb(var(--color-neutral-10))' }"
:data="formDrawer.dataSource" :column="1" size="large">
<template #value="{ value }">
<a-skeleton v-if="formDrawer.loading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ value }}</span>
</template>
</a-descriptions>
</a-col>
<a-col :span="12">
<a-divider orientation="left">数据处理</a-divider>
<a-descriptions :align="{ label: 'right' }" :label-style="{ color: 'rgb(var(--color-neutral-10))' }"
:data="formDrawer.dataHandle" :column="1" size="large">
<template #value="{ value }">
<a-skeleton v-if="formDrawer.loading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ value }}</span>
</template>
</a-descriptions>
<a-divider orientation="left">数据过滤</a-divider>
<a-descriptions :align="{ label: 'right' }" :label-style="{ color: 'rgb(var(--color-neutral-10))' }"
:data="formDrawer.dataFilter" :column="1" size="large">
<template #value="{ value }">
<a-skeleton v-if="formDrawer.loading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ value }}</span>
</template>
</a-descriptions>
<a-divider orientation="left">系统信息</a-divider>
<a-descriptions :align="{ label: 'right' }" :label-style="{ color: 'rgb(var(--color-neutral-10))' }"
:data="formDrawer.systemInfo" :column="1" size="large">
<template #value="{ value }">
<a-skeleton v-if="formDrawer.loading" :animation="true">
<a-skeleton-line :rows="1" />
</a-skeleton>
<span v-else>{{ value }}</span>
</template>
</a-descriptions>
</a-col>
</a-row>
</a-drawer>
<!-- 详情右弹层 end -->
<a-modal width="450px" v-model:visible="uploadResultVisible" :hide-cancel="true">
<template #title>
<icon-check-circle-fill size="18" style="color: rgb(var(--primary-6)); margin-right: 5px" />
上传成功
</template>
<div style="height: 200px;" v-html="uploadResult"></div>
<template #footer>
<div style="text-align: center">
<a-space>
<a-button type="primary" @click="closeUploadResult">确认</a-button>
</a-space>
</div>
</template>
</a-modal>
</a-card>
</div>
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { computed, getCurrentInstance, reactive, ref } from 'vue';
import { StationTypeEnum, listFusionGroup } from '@/api/system/device';
import { processSelectable } from '@/utils/ruoyi';
import { onMounted } from 'vue';
import useLoading from '@/hooks/loading';
import { BasePagination } from '@/api/common';
import { notification } from "@/hooks/my-design";
import { FileItem, Message } from "@arco-design/web-vue";
import { changeDeviceVarStatus, changeMonitorStatus, delDeviceVar, getDeviceVar, listDeviceVar } from '@/api/system/device-var';
import { getDictLabel } from '@/utils/dict';
import { getChannelDevice } from '@/api/system/channel-device';
import { download } from '@/api/download';
import { getToken } from '@/utils/auth';
import dayjs from 'dayjs';
//******* 这里编写动态获取下拉列表 start ******
const proxy = getCurrentInstance()?.appContext.config.globalProperties;
const { sys_data_type, sys_data_origin, sys_save_cycle } = proxy?.useDict("sys_data_type", "sys_data_origin", "sys_save_cycle");
//******* 这里编写动态获取下拉列表 end ******
/*************************** 变量区域 begin ***************************/
//路由
const router = useRouter();
//tab切换选中值
const tabsActiveKey = ref<number>(1);
//组件参数
const props = defineProps({
stationType: {
type: Number,
default: StationTypeEnum.power,
}
})
//tab切换
const tabsList = ref<any>([
{
key: 1,
title: "模拟量",
},
{
key: 2,
title: "状态量",
}
])
const catalogIdFieldNames = ref<any>({
key: 'key', title: 'deviceName', children: 'children'
});
const deviceData = ref<any>([]);
//生成查询条件对象
const generateSearchModel = () => {
return {
varName: '',
deviceId: undefined
};
};
//生成表单模型
const generateFormDrawerModel = () => {
return {
visible: false,
loading: false,
title: '',
varInfo: [],
dataSource: [],
dataHandle: [],
dataFilter: [],
systemInfo: []
};
};
//表单模型
const formDrawer = ref(generateFormDrawerModel());
//查询表单对象
const searchModel = ref(generateSearchModel());
//表格数据
const renderData = ref<any>([]);
//加载中
const { loading, setLoading } = useLoading(true);
//表格分页参数
const pagination: any = reactive({ ...BasePagination() });
//设置表格列
const tabColumns = computed<any[]>(() => [
{
title: "变量名称",
dataIndex: "varName",
fixed: "left",
width: 250,
align: "left",
},
{
title: "变量编码",
fixed: "left",
width: 200,
dataIndex: "varSn",
align: "left",
ellipsis: true,
tooltip: { position: 'top' },
},
{
title: "变量属性",
width: 180,
dataIndex: "varMapName",
align: "left",
},
{
title: "索引变量编码",
width: 180,
dataIndex: "varMapSn",
align: "left",
ellipsis: true,
tooltip: { position: 'top' },
},
{
title: "是否监控",
width: 120,
dataIndex: "isMonitor",
slotName: "isMonitor",
align: "center",
},
{
title: "是否累积",
width: 120,
dataIndex: "isAccumulation",
slotName: "isAccumulation",
align: "center",
},
{
title: "监控设备",
width: 180,
dataIndex: "deviceName",
align: "left",
},
{
title: "所属通道",
width: 180,
dataIndex: "channelName",
align: "center",
},
{
title: "数据来源",
width: 120,
dataIndex: "origin",
slotName: "origin",
align: "center",
},
{
title: "数据地址",
width: 120,
dataIndex: "messageAddress",
align: "center",
},
{
title: "数据类型",
width: 180,
dataIndex: "dataType",
slotName: "dataType",
align: "center",
},
{
title: "系数",
width: 100,
dataIndex: "coefficient",
align: "center",
},
{
title: "存盘周期",
width: 120,
dataIndex: "saveCycle",
slotName: "saveCycle",
align: "center",
},
{
title: "启用状态",
width: 100,
dataIndex: "stopFlag",
slotName: "stopFlag",
align: "center",
fixed: "right",
},
{
title: "操作",
dataIndex: "operations",
width: 300,
slotName: "operate",
align: "center",
fixed: "right",
},
]);
//操作弹框
const generateOperateModalModel = () => {
return {
//0 状态 1删除
type: 0,
visible: false,
title: "",
id: 0,
value: 0,
name: ""
};
};
//操作弹框模型
const operateModalModel = ref(generateOperateModalModel());
//路径
const baseUrl = import.meta.env.VITE_API_BASE_URL;
//请求头
const headers: Record<string, string> = {
'Authorization': `Bearer ${getToken()}`
}
//上传结果显示状态
const uploadResultVisible = ref<boolean>(false);
const uploadResult = ref<String>('');
/*************************** 变量区域 end ***************************/
/*************************** 方法区域 begin ***************************/
/**
* 添加设备变量
*/
const handleDeviceVarAdd = () => {
router.push({
path: props.stationType == 1 ? "/power/energy/device/varCreate" : "/pv/device/varCreate",
query: {
...props,
varType: tabsActiveKey.value,
redirect: router.currentRoute.value.fullPath,
}
});
}
/** 导出按钮操作 */
const handleExport = () => {
download("/system/device-var/export?stationType=" + props.stationType, {
}, `${props.stationType == StationTypeEnum.power ? '用电' : props.stationType == StationTypeEnum.pv ? '光伏' : ""}设备-变量列表-${dayjs().format("YYYY-MM-DD HH:mm:ss")}.xlsx`);
}
const handleBeforeUpload = (file: File) => {
Message.loading({
content: "正在上传文件,请稍后",
duration: 6000 * 1000
});
return true;
}
/**
* 上传成功
* @param fileItem
*/
const handleUploadSuccess = (fileItem: FileItem) => {
Message.clear();
if (fileItem.response.code == 200) {
uploadResultVisible.value = true;
uploadResult.value = fileItem.response.msg
} else {
Message.error(fileItem.response.msg || "上传失败,请联系管理员");
}
}
/**
* 关闭上传成功提示谈框
*/
const closeUploadResult = async () => {
uploadResult.value = '';
uploadResultVisible.value = false;
await fetchData();
}
/**
* 修改设备变量
*/
const handleDeviceVarUpdate = (id: any) => {
router.push({
path: props.stationType == 1 ? "/power/energy/device/varUpdate" : "/pv/device/varUpdate",
query: {
...props,
bizId: id,
redirect: router.currentRoute.value.fullPath
}
});
}
/**
* 详情
* @param val
*/
const handleDeviceDetail = async (record: any) => {
formDrawer.value.visible = true;
formDrawer.value.loading = true;
try {
formDrawer.value.title = record.varName;
let res = await getDeviceVar(record.id);
if (res.code == 200) {
let channelDeviceRes = await getChannelDevice(res.data.comDeviceId);
let comDeviceInfo: any = {}
if (channelDeviceRes.code == 200) {
comDeviceInfo = channelDeviceRes.data;;
}
let varInfo: any = [
{
label: '所属站点:',
value: res.data.stationName || '-',
},
{
label: '电站类型:',
value: getDictLabel('sys_station_type', res.data.stationType) || '-',
},
{
label: '所属通道:',
value: res.data.channelName || '-',
},
{
label: '通讯设备:',
value: comDeviceInfo.deviceName || '-',
},
{
label: '用电设备:',
value: res.data.deviceName || '-',
},
{
label: '变量名称:',
value: res.data.varName || '-',
},
{
label: '变量编码:',
value: res.data.varMapSn || '-',
},
{
label: '变量属性:',
value: res.data.varSn || '-',
},
{
label: '变量单位:',
value: res.data.unit || '-',
},
{
label: '是否监控:',
value: getDictLabel('sys_yes_no', res.data.isMonitor) || '-',
},
{
label: '启用状态:',
value: res.data.stopFlag == 0 ? '停用' : '启用',
}
];
let dataSource: any = [{
label: '来源类型:',
value: getDictLabel('sys_data_origin', res.data.origin) || '-',
}, {
label: '通讯设备:',
value: comDeviceInfo.deviceName || '-',
},
// {
// label: '数据区域:',
// value: res.data.registerName || '-',
// },
{
label: '数据地址:',
value: res.data.messageAddress || '-',
}, {
label: '读写类型:',
value: getDictLabel('sys_rw', res.data.rw) || '-',
}, {
label: '计算公式:',
value: res.data.computeFormula || '-',
}, {
label: '缺失值处理:',
value: getDictLabel('sys_deletion_type', res.data.deletionHandle) || '-',
}];
let dataHandle: any = [{
label: '数据类型:',
value: getDictLabel('sys_data_type', res.data.dataType) || '-',
}, {
label: '初始赋值:',
value: res.data.initValue || '-',
}, {
label: '数据基值:',
value: res.data.baseValue || '-',
}, {
label: '数据系数:',
value: res.data.coefficient || '-',
}, {
label: '存盘周期:',
value: getDictLabel('sys_save_cycle', res.data.saveCycle) || '-',
}, {
label: '是否累积量:',
value: getDictLabel('sys_yes_no', res.data.isAccumulation) || '-',
}, {
label: '累积类型:',
value: getDictLabel('sys_accumulate_type', res.data.accumulationType) || '-'
}];
let dataFilter: any = [{
label: '数据过滤:',
value: getDictLabel('sys_yes_no', res.data.isDataFilter) || '-',
}, {
label: '绝对值小于:',
value: `${res.data.lessAbs} 替换为 ${res.data.replaceValueUpper}`,
}, {
label: '绝对值大于:',
value: `${res.data.moreAbs} 替换为 ${res.data.replaceValueLower}`,
}]
let systemInfo: any = [{
label: '创建人员:',
value: res.data.createBy || '-',
}, {
label: '创建时间:',
value: res.data.createTime || '-',
}, {
label: '更新人员:',
value: res.data.updateBy || '-',
}, {
label: '更新时间:',
value: res.data.updateTime || '-',
}];
formDrawer.value.varInfo = varInfo;
formDrawer.value.dataSource = dataSource;
formDrawer.value.dataHandle = dataHandle;
formDrawer.value.dataFilter = dataFilter;
formDrawer.value.systemInfo = systemInfo;
}
} catch (err) {
} finally {
formDrawer.value.loading = false;
}
}
/**
* table切换
*/
const handleTabsChange = async () => {
pagination.current = 1;
await fetchData();
}
/**
* 查询
*/
const search = async () => {
pagination.current = 1;
await fetchData();
}
/**
* 表格页码发生变化
* @param val
*/
const onPageChange = async (val: number) => {
pagination.current = val;
await fetchData();
}
/**
* 表格每页数量发生变化
* @param val 值
*/
const onPageSizeChange = async (val: number) => {
pagination.pageSize = val;
await fetchData();
}
/**
* 详情关闭
*/
const handleDrawerCancel = () => {
formDrawer.value = generateFormDrawerModel();
}
/**
* 停用
* @param record
*/
const handleStopFlag = (record: any) => {
operateModalModel.value = {
visible: true,
type: 0,
title: record.stopFlag == 0 ? "停用" : "启用",
id: record.id,
value: record.stopFlag == 0 ? 1 : 0,
name: record.varName
}
}
/**
* 监控
* @param record
*/
const handleMonitor = (record: any) => {
operateModalModel.value = {
visible: true,
type: 2,
title: record.isMonitor == 0 ? '开启监控' : '关闭监控',
id: record.id,
value: record.isMonitor == 0 ? 1 : 0,
name: record.varName
}
}
/**
* 删除数据
* @param record 数据行
*/
const handleDelete = (record: any) => {
operateModalModel.value = {
visible: true,
type: 1,
title: "删除",
id: record.id,
name: record.varName,
value: record.id
}
}
/**
* 删除提示弹框取消
*/
const handleOperateModelCancle = () => {
operateModalModel.value = generateOperateModalModel();
}
/**
* 删除提示弹框确认
*/
const handleOperateModelOk = async () => {
let result: any = { code: 201 };
if (operateModalModel.value.type == 0) {
result = await changeDeviceVarStatus(operateModalModel.value.id, operateModalModel.value.value);
} else if (operateModalModel.value.type == 1) {
result = await delDeviceVar(operateModalModel.value.id);
} else if (operateModalModel.value.type == 2) {
result = await changeMonitorStatus(operateModalModel.value.id, operateModalModel.value.value);
}
notification(result);
if (result.code == 200) {
handleOperateModelCancle();
await fetchData();
}
}
/**
* 获取设备列表
*/
const fetchDeviceData = async () => {
try {
const res = await listFusionGroup({
stationType: props.stationType,
});
processSelectable(res.data);
deviceData.value = res.data;
} catch (err) {
// you can report use errorHandler or other
} finally {
}
}
//查询数据
const fetchData = async () => {
setLoading(true);
try {
const data = await listDeviceVar({
pageSize: pagination.pageSize,
pageNum: pagination.current,
...searchModel.value,
...props,
varType: tabsActiveKey.value
});
renderData.value = data.rows;
pagination.total = data.total;
} catch (err) {
// you can report use errorHandler or other
} finally {
setLoading(false);
}
};
/*************************** 方法区域 end ***************************/
/**
* 首次加载
*/
onMounted(async () => {
let deviceId = router.currentRoute.value.query.deviceId
if (deviceId) {
searchModel.value.deviceId = Number(router.currentRoute.value.query.deviceId || 0);
}
await fetchDeviceData();
await fetchData();
})
</script>