From de2202e360c3c1fd6182ade456fb7e2c8edc9ebd Mon Sep 17 00:00:00 2001 From: fks-yangshouda Date: Tue, 9 Jul 2024 17:35:45 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=9B=91=E6=8E=A7=E4=B8=AD=E5=BF=83=20-=20?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=9B=91=E6=B5=8B=20=E5=AF=B9=E6=8E=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/view/monitor/deviceMonitor/tree/index.vue | 168 ++++++++++++--------- 1 file changed, 93 insertions(+), 75 deletions(-) diff --git a/hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue b/hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue index 105f7f5..9b858e9 100644 --- a/hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue +++ b/hx-ai-intelligent/src/view/monitor/deviceMonitor/tree/index.vue @@ -9,12 +9,7 @@ style="width: 100%" :tree-line="treeLine && { showLeafIcon }" :tree-data="treeData1" - @change=""> - - + @change="changeDeviceType" /> ([ - { - title: '3.电梯', - value: '3', - children: [ - { - title: '301.扶梯', - value: '301', - }, - { - title: '302.直梯', - value: '302', - }, - ], - }, - { - title: '4.冷热源', - value: '4', - children: [ - { - title: '401.冷水机组', - value: '401', - }, - { - title: '402.热泵机组', - value: '402', - }, - { - title: '403.锅炉', - value: '403', - }, - { - title: '404.水处理机组', - value: '404', - }, - ], - }, + // { + // title: '3.电梯', + // value: '3', + // children: [ + // { + // title: '301.扶梯', + // value: '301', + // }, + // { + // title: '302.直梯', + // value: '302', + // }, + // ], + // }, + // { + // title: '4.冷热源', + // value: '4', + // children: [ + // { + // title: '401.冷水机组', + // value: '401', + // }, + // { + // title: '402.热泵机组', + // value: '402', + // }, + // { + // title: '403.锅炉', + // value: '403', + // }, + // { + // title: '404.水处理机组', + // value: '404', + // }, + // ], + // }, ]); http.post(device.queryDeviceTree, { orgId: orgId.value }).then((res) => { @@ -156,14 +122,64 @@ const formatTreeData = (data) => { return data.map((item) => ({ title: item.code + '.' + item.deviceType, - value: item.id, + value: item.code, children: item.children ? formatTreeData(item.children) : [], })); }; - const expandedKeys = ref(['0-0-0', '0-0-1']); - const selectedKeys = ref(['0-0-0', '0-0-1']); - const checkedKeys = ref(['0-0-0', '0-0-1']); + // const treeData2: TreeProps['treeData'] = [ + const treeData2 = ref([ + // { + // title: 'AC_001(总电表)', + // key: '1', + // children: [ + // { + // title: 'AC_002(暖通电表)', + // key: '2', + // }, + // { + // title: 'AC_003(照明电表)', + // key: '3', + // }, + // { + // title: 'AC_004(给排水电表)', + // key: '4', + // }, + // { + // title: 'AC_005(通风电表)', + // key: '5', + // }, + // { + // title: 'AC_006(电动门电表)', + // key: '6', + // }, + // ], + // }, + ]); + + const changeDeviceType = (val, label, extra) => { + http + .post(device.queryDevicePage, { code: val, orgId: orgId.value, pageNum: 1, pageSize: 10 }) + .then((res) => { + if (!val) { + val = '999999999'; + } + if (!label) { + label = ['所有设备']; + } + let records = res.data.records; + records.forEach((item: any) => { + (item.title = item.deviceModel + ' ' + item.deviceName), (item.key = item.id); + }); + let a: TreeSelectProps['treeData'] = [{ title: label[0], key: val, children: records }]; + treeData2.value = a; + expandedKeys.value = [val]; + }); + }; + + const expandedKeys = ref([]); + const selectedKeys = ref([]); + const checkedKeys = ref([]); const options1 = ref([]); const options2 = ref([ @@ -515,6 +531,7 @@ onMounted(() => { getDianWeiList(); + changeDeviceType(); }); // const dateFormat = 'YYYY-MM-DD'; @@ -542,6 +559,7 @@ onChange, hackValue, pageData, + changeDeviceType, }; }, });