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, }; }, });