From 3e7aa4a57d088826ac78f6c3478395b478c378d1 Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 16 Mar 2026 10:55:35 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E5=8F=AF=E8=A7=86=E5=8C=96?= =?UTF-8?q?=E5=A4=A7=E5=B1=8F=E5=88=97=E8=A1=A8-=E7=BC=96=E8=BE=91-?= =?UTF-8?q?=E4=BA=A7=E7=BA=BF=E5=AD=97=E6=AE=B5=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/report/dashboardList/index.vue | 37 +++++++++++++++++++----- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/views/report/dashboardList/index.vue b/src/views/report/dashboardList/index.vue index 9b82150e..e670de80 100644 --- a/src/views/report/dashboardList/index.vue +++ b/src/views/report/dashboardList/index.vue @@ -97,7 +97,7 @@ v-for="dict in getStrDictOptions('mes_goview_type')" :key="dict.value" :label="d @@ -229,7 +229,7 @@ const organizationTree = ref([]) const lineTreeProps = { label: 'name', children: 'children', - value: 'id' + value: 'name' } const deviceList = ref([]) @@ -345,6 +345,10 @@ const openEditDialog = (item: DashboardItem) => { createForm.type = item.type || '' createForm.orgId = item.orgId || undefined createForm.orgName = item.orgName || '' + if (!createForm.orgName && createForm.orgId) { + const org = findOrgNode(organizationTree.value || [], createForm.orgId) + createForm.orgName = org?.name || '' + } const fromNew = Array.isArray(item.deviceIdsList) && item.deviceIdsList.length ? normalizeDeviceIdsList(item.deviceIdsList) : [] @@ -398,11 +402,14 @@ const submitDialog = async () => { } else { createForm.deviceIdsList = [] } + if (!createForm.orgId && createForm.orgName) { + const org = findOrgNodeByName(organizationTree.value || [], createForm.orgName) + createForm.orgId = org?.id ?? undefined + createForm.orgName = org?.name || createForm.orgName + } if (createForm.orgId) { const org = findOrgNode(organizationTree.value || [], createForm.orgId) - createForm.orgName = org?.name || '' - } else { - createForm.orgName = '' + createForm.orgName = org?.name || createForm.orgName } const route = getRouteByType(createForm.type) if (route) { @@ -464,13 +471,27 @@ const findOrgNode = (nodes: any[], id: any): any | undefined => { return undefined } +const findOrgNodeByName = (nodes: any[], name: any): any | undefined => { + const target = String(name ?? '').trim() + if (!target) return undefined + for (const node of nodes) { + if (String(node.name) === target) return node + const children = Array.isArray(node.children) ? node.children : [] + const found = findOrgNodeByName(children, target) + if (found) return found + } + return undefined +} + const handleOrgChange = () => { - if (!createForm.orgId) { + if (!createForm.orgName) { + createForm.orgId = undefined createForm.orgName = '' return } - const org = findOrgNode(organizationTree.value || [], createForm.orgId) - createForm.orgName = org?.name || '' + const org = findOrgNodeByName(organizationTree.value || [], createForm.orgName) + createForm.orgId = org?.id ?? undefined + createForm.orgName = org?.name || createForm.orgName } const loadDeviceList = async () => {