| | |
| | | > |
| | | <template #default="{ node, data }"> |
| | | <span v-if="!data.children" class="device-tree-item"> |
| | | <div class="device-item-icon"></div> |
| | | <!-- <div class="device-item-icon"></div> --> |
| | | <span class="device-item-text">{{ node.label }}</span> |
| | | </span> |
| | | <span v-else class="device-tree-category"> |
| | |
| | | |
| | | const devicetList = ref([ |
| | | { |
| | | deviceCode: "303A9016", |
| | | deviceId: "1821067878870257666", |
| | | deviceName: "孙胡沟(墒情)", |
| | | dictDeviceType: "1437295822", |
| | | latitude: 40.56476666, |
| | | longitude: 116.5955361, |
| | | }, |
| | | { |
| | | deviceCode: "01303A9016", |
| | | deviceId: "1821067850122498049", |
| | | deviceName: "孙胡沟(墒情)", |
| | | dictDeviceType: "14372958380", |
| | | latitude: 40.56476666, |
| | | longitude: 116.5955361, |
| | | }, |
| | | { |
| | | deviceCode: "303A9016", |
| | | deviceId: "1821067878870257666", |
| | | deviceName: "孙胡沟(墒情)", |
| | | dictDeviceType: "1437295822", |
| | | latitude: 40.56476666, |
| | | longitude: 116.5955361, |
| | | }, |
| | |
| | | }; |
| | | |
| | | // 计算属性:将设备列表转换为树形结构 |
| | | // 计算属性:将设备列表转换为树形结构 |
| | | const deviceTree = computed(() => { |
| | | const typeMap = {}; |
| | | |
| | | // 先按设备类型分组 |
| | | devicetList.value.forEach((device) => { |
| | | const typeName = getDictName(deviceDictList, device.dictDeviceType); |
| | | |
| | | if (!typeName) { |
| | | console.warn("未找到设备类型:", device); |
| | | return; |
| | | } |
| | | |
| | | if (!typeMap[typeName]) { |
| | | typeMap[typeName] = []; |
| | | } |
| | | // 直接使用原始的设备名称,不进行任何替换操作 |
| | | typeMap[typeName].push({ |
| | | ...device, |
| | | deviceName: device.deviceName.replace(`${typeName})`, ")"), // 移除重复的类型名 |
| | | deviceName: device.deviceName.trim(), // 只去除首尾空格 |
| | | }); |
| | | }); |
| | | |
| | |
| | | children: typeMap[typeName], |
| | | })); |
| | | }); |
| | | |
| | | function handleTreeNodeClick(data) { |
| | | // 只有设备节点才处理点击事件 |
| | | if (!data.children) { |
| | |
| | | .device-content { |
| | | padding: 10px; |
| | | overflow-y: auto; |
| | | height: calc(100% - 40px); |
| | | height: calc(100% - 70px); |
| | | } |
| | | |
| | | .device-tree { |
| | |
| | | background: transparent; |
| | | color: white; |
| | | margin-top: 10px; |
| | | width: 100%; |
| | | overflow-x: auto; |
| | | |
| | | :deep(.el-tree-node__content) { |
| | | height: 30px; |
| | |
| | | color: white !important; |
| | | background-color: rgb(38, 124, 124, 0.5); |
| | | } |
| | | :deep(.el-tree-node__content) { |
| | | padding-left: 0px !important ; |
| | | } |
| | | </style> |