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