From 3ffb11defaa7207c58158456187662c021e07d34 Mon Sep 17 00:00:00 2001 From: guanj Date: Fri, 3 Apr 2026 14:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=B0=E8=B4=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/form/mac/MacAddressInput.vue | 199 +++++++++--------- src/views/govern/cloudDeviceEntry/index.vue | 101 ++++++--- src/views/govern/device/fileService/index.vue | 26 +-- src/views/govern/device/fileService/popup.vue | 3 +- .../govern/manage/programVersion/index.vue | 3 +- 5 files changed, 183 insertions(+), 149 deletions(-) diff --git a/src/components/form/mac/MacAddressInput.vue b/src/components/form/mac/MacAddressInput.vue index 8f82f18..897dfd8 100644 --- a/src/components/form/mac/MacAddressInput.vue +++ b/src/components/form/mac/MacAddressInput.vue @@ -1,35 +1,36 @@ \ No newline at end of file + diff --git a/src/views/govern/cloudDeviceEntry/index.vue b/src/views/govern/cloudDeviceEntry/index.vue index 235abc2..4038f9f 100644 --- a/src/views/govern/cloudDeviceEntry/index.vue +++ b/src/views/govern/cloudDeviceEntry/index.vue @@ -193,7 +193,10 @@ -
+
- + - - + + + + +
@@ -1476,6 +1506,7 @@ const loading = ref(false) const nextfalg = ref(false) const dictData = useDictData() const nodeLevel = ref(0) +const nodeLevelCopy = ref(0) const pageStatus = ref(1) const titleList: any = ref([]) const nodeData: any = ref([]) @@ -1941,7 +1972,7 @@ const add = () => { return } pageStatus.value = 2 - + nodeLevelCopy.value = nodeLevel.value // 根据当前节点层级添加对应的tab页 switch (nodeLevel.value) { case 0: // 新增工程,不需要添加tab @@ -2243,8 +2274,8 @@ const remove = () => { type: 'warning' }) .then(() => { - switch (nodeLevel.value) { - case 1: + switch (nodeData.value.level) { + case 0: let data = { id: nodeData.value.id, status: '0' @@ -2262,7 +2293,7 @@ const remove = () => { }) break - case 2: // 项目层级 + case 1: // 项目层级 // 删除项目后选中工程节点 const engineeringId = nodeData.value.pids ? nodeData.value.pids.split(',')[1] : null deleteProject(nodeData.value.id, '', '', '', 0, '', '').then((res: any) => { @@ -2282,7 +2313,7 @@ const remove = () => { }) break - case 3: // 设备层级 + case 2: // 设备层级 // 删除设备后选中项目节点 const projectId = nodeData.value.pids ? nodeData.value.pids.split(',')[2] : null deleteEquipment(nodeData.value.id).then((res: any) => { @@ -2302,7 +2333,7 @@ const remove = () => { }) break - case 4: // 监测点层级 + case 3: // 监测点层级 const deviceId = nodeData.value.pids ? nodeData.value.pids.split(',')[3] : null deleteLine(nodeData.value.id).then((res: any) => { @@ -2502,21 +2533,21 @@ const submitAllLevelData = async () => { const engineeringData = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam } // 项目信息 - const projectData = + const projectData: any = tempAllLevelData.value.projects.length > 0 ? tempAllLevelData.value.projects.find(project => project !== undefined) || {} : formData.value.projectInfoList[0] || {} // 如果是从根节点开始新增工程和项目 - if (nodeData.value.level === 0) { + if (nodeData.value.level === -1) { submitData = { engineering: engineeringData, - project: projectData + project: { ...projectData, topoIds: [projectData.topoId] } } } else { // 如果是从工程节点开始新增项目 submitData = { engineeringIndex: nodeData.value?.id || '', - project: projectData + project: { ...projectData, topoIds: [projectData.topoId] } } } break @@ -2541,10 +2572,10 @@ const submitAllLevelData = async () => { } // 如果是从根节点开始新增 - if (nodeData.value.level === 0) { + if (nodeData.value.level === -1) { submitData = { engineering: engineeringData2, - project: projectData2, + project: { ...projectData2, topoIds: [projectData2.topoId] }, device: devices.map((device: any) => ({ ...device, ndid: device.mac ? device.mac.replace(/:/g, '') : '' @@ -2552,10 +2583,10 @@ const submitAllLevelData = async () => { } } // 如果是从工程节点开始新增 - else if (nodeData.value.level === 1) { + else if (nodeData.value.level === 0) { submitData = { engineeringIndex: nodeData.value?.id || '', - project: projectData2, + project: { ...projectData2, topoIds: [projectData2.topoId] }, device: devices.map((device: any) => ({ ...device, ndid: device.mac ? device.mac.replace(/:/g, '') : '' @@ -2563,7 +2594,7 @@ const submitAllLevelData = async () => { } } // 如果是从项目节点开始新增 - else if (nodeData.value.level === 2) { + else if (nodeData.value.level === 1) { const pidsArray = nodeData.value?.pids ? nodeData.value.pids.split(',') : [] const engineeringId = pidsArray.length >= 2 ? pidsArray[1] : '' @@ -2578,8 +2609,8 @@ const submitAllLevelData = async () => { } break - case 3: // 工程 + 项目 + 设备 + 监测点 - case 4: + // case 3: // 工程 + 项目 + 设备 + 监测点 + case 3: // 工程信息 const engineeringData3 = tempAllLevelData.value.engineering || { ...formData.value.engineeringParam @@ -2608,10 +2639,10 @@ const submitAllLevelData = async () => { } // 如果是从根节点开始新增 - if (nodeData.value.level === 0) { + if (nodeData.value.level === -1) { submitData = { engineering: engineeringData3, - project: projectData3, + project: { ...projectData3, topoIds: [projectData3.topoId] }, device: devices2.map((device: any) => ({ ...device, ndid: device.mac ? device.mac.replace(/:/g, '') : '' @@ -2638,7 +2669,7 @@ const submitAllLevelData = async () => { } } // 如果是从工程节点开始新增 - else if (nodeData.value.level === 1) { + else if (nodeData.value.level === 0) { submitData = { engineeringIndex: nodeData.value?.id || '', project: projectData3, @@ -2668,7 +2699,7 @@ const submitAllLevelData = async () => { } } // 如果是从项目节点开始新增 - else if (nodeData.value.level === 2) { + else if (nodeData.value.level === 1) { const pidsArray = nodeData.value?.pids ? nodeData.value.pids.split(',') : [] const engineeringId = pidsArray.length >= 2 ? pidsArray[1] : '' @@ -2701,7 +2732,7 @@ const submitAllLevelData = async () => { } } // 如果是从设备节点开始新增 - else if (nodeData.value.level === 3) { + else if (nodeData.value.level === 2) { const pidsArray2 = nodeData.value?.pids ? nodeData.value.pids.split(',') : [] const engineeringId2 = pidsArray2.length >= 2 ? pidsArray2[1] : '' const projectId = pidsArray2.length >= 3 ? pidsArray2[2] : '' diff --git a/src/views/govern/device/fileService/index.vue b/src/views/govern/device/fileService/index.vue index 1a2cf61..4308f49 100644 --- a/src/views/govern/device/fileService/index.vue +++ b/src/views/govern/device/fileService/index.vue @@ -746,26 +746,28 @@ const mqttMessage = ref({}) const status: any = ref() function parseStringToObject(str: string) { const content = str.replace(/^{|}$/g, '') - const pairs = content.split(',') const result: any = {} - pairs.forEach(pair => { - const [key, value] = pair.split(':') - // 尝试将数字转换为Number类型 - result[key.trim()] = isNaN(Number(value)) ? value.trim() : Number(value) - }) + + // 正则匹配:key:value 格式,支持 value 里带 : / 等字符 + const regex = /([^,:]+):([^,]+)(?=,|$)/g + let match + + while ((match = regex.exec(content)) !== null) { + const key = match[1].trim() + const value = match[2].trim() + // 数字自动转 Number + result[key] = isNaN(Number(value)) ? value : Number(value) + } + return result } mqttRef.value.on('message', (topic: any, message: any) => { // console.log('mqtt接收到消息', JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))) let str = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) - - let regex = /fileName:(.*?),allStep/ - let regex1 = /allStep:(.*?),nowStep/ - let regex2 = /nowStep:(.*?),userId/ - let regex3 = /userId:(.*?)}/ - mqttMessage.value = parseStringToObject(str) + if (adminInfo.id != mqttMessage.value.userId) return + // console.log("🚀 ~ str.match(regex3)[1]:", str.match(regex3)[1]) status.value = parseInt(Number((mqttMessage.value.nowStep / mqttMessage.value.allStep) * 100)) fileRef.value.setStatus(mqttMessage.value) diff --git a/src/views/govern/device/fileService/popup.vue b/src/views/govern/device/fileService/popup.vue index fc6cbc1..ef3389d 100644 --- a/src/views/govern/device/fileService/popup.vue +++ b/src/views/govern/device/fileService/popup.vue @@ -3,6 +3,7 @@
+
{ // 版本维护 const maintenance = () => { push({ - path: '/versionMaintenance' + // path: '/versionMaintenance' + path: '/govern/manage/basic/version' }) }