From b19dffa3cfd5de74633d9657895006ceb4da69ef Mon Sep 17 00:00:00 2001 From: shaoleiliu-netizen123 <480188199@qq.com> Date: Mon, 3 Aug 2026 15:05:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=8D=E4=BA=A4?= =?UTF-8?q?=E6=8E=A5=E9=A1=B5=E9=9D=A2=E8=8E=B7=E5=8F=96=E5=B7=A5=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index.vue | 42 ++++++++++++------- 1 file changed, 28 insertions(+), 14 deletions(-) rename src/views/biz/{stationhandover => stationHandover}/index.vue (94%) diff --git a/src/views/biz/stationhandover/index.vue b/src/views/biz/stationHandover/index.vue similarity index 94% rename from src/views/biz/stationhandover/index.vue rename to src/views/biz/stationHandover/index.vue index 7f00221..1c1ac86 100644 --- a/src/views/biz/stationhandover/index.vue +++ b/src/views/biz/stationHandover/index.vue @@ -6,14 +6,13 @@
- + /> { - return { - label:n.sectionName, - value:n.id - } - }) + const data = await deptApi.tree() + sectionList.value = buildOptions(data); } function handleUpdateValue(key:any) { @@ -420,6 +417,23 @@ function handleUpdateValue(key:any) { loadDevice(key) } + +function buildOptions(d: any[]): TreeNode[] { + return d.map(item => { + // 安全id转换:0也能正常转为数字,不会被||过滤 + const idNum = Number(item.id); + const key = !isNaN(idNum) ? idNum : item.id; + return { + label: item.deptName, + key, + // 子节点存在且为数组才递归处理 + children: Array.isArray(item.children) && item.children.length + ? buildOptions(item.children) + : undefined + }; + }); +} + //加载设备/工位 async function loadDevice(sectionIdList:number[]) { const sectionIds = sectionIdList != null ?JSON.stringify(sectionIdList) :null