From d6b92db9c82a1bc3ce03f82e8b49ca9b26b1686d Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Mon, 24 Mar 2025 20:47:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=B0=E8=B4=A6=E5=BD=95?= =?UTF-8?q?=E5=85=A5=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device-boot/Business.ts | 8 ++ src/components/tree/pqs/Terminal.vue | 7 ++ .../pqs/business/terminal/deviceter/index.vue | 107 ++++++++++++++---- 3 files changed, 103 insertions(+), 19 deletions(-) diff --git a/src/api/device-boot/Business.ts b/src/api/device-boot/Business.ts index 7b94f40b..848c0ae2 100644 --- a/src/api/device-boot/Business.ts +++ b/src/api/device-boot/Business.ts @@ -118,3 +118,11 @@ export function queryAllByType(params: any) { params }) } +//获取用户 +export function selectUserList(data: any) { + return createAxios({ + url: '/supervision-boot/userReport/selectUserList', + method: 'post', + data + }) +} diff --git a/src/components/tree/pqs/Terminal.vue b/src/components/tree/pqs/Terminal.vue index d81e4ddc..c312c0db 100644 --- a/src/components/tree/pqs/Terminal.vue +++ b/src/components/tree/pqs/Terminal.vue @@ -72,16 +72,20 @@ const info = (id: any) => { } else { res.data.forEach((item: any) => { item.icon = 'el-icon-Menu' + item.plevel = item.level item.level = (item.level + 1) * 100 item.children.forEach((item2: any) => { item2.icon = 'el-icon-HomeFilled' + item2.plevel = item2.level item2.level = (item2.level + 1) * 100 expanded.value.push(item2.id) item2.children.forEach((item3: any) => { item3.icon = 'el-icon-CollectionTag' + item3.plevel = item3.level item3.level = (item3.level + 1) * 100 item3.children.forEach((item4: any) => { item4.icon = 'el-icon-Flag' + item4.plevel = item4.level item4.level = (item4.level + 1) * 100 item4.children.forEach((item5: any) => { item5.icon = 'el-icon-OfficeBuilding' @@ -89,12 +93,15 @@ const info = (id: any) => { item5.level = (item5.level == 7 ? 4 : item5.level) * 100 item5.children.forEach((item6: any) => { item6.icon = 'el-icon-Film' + item6.plevel = item6.level item6.level = (item6.level + 1) * 100 item6.children.forEach((item7: any) => { item7.icon = 'el-icon-Share' + item7.plevel = item7.level item7.level = (item7.level + 1) * 100 item7.children.forEach((item8: any) => { item8.icon = 'el-icon-Location' + item8.plevel = item8.level item8.level = (item8.level + 1) * 100 }) }) diff --git a/src/views/pqs/business/terminal/deviceter/index.vue b/src/views/pqs/business/terminal/deviceter/index.vue index 102ebd13..3f85f0c4 100644 --- a/src/views/pqs/business/terminal/deviceter/index.vue +++ b/src/views/pqs/business/terminal/deviceter/index.vue @@ -89,6 +89,7 @@ :rules="{ required: true, message: '请输入项目名称', trigger: 'blur' }" > @@ -1192,6 +1211,7 @@ :rules="{ required: true, message: '请选择测点间隔', trigger: 'blur' }" > - { nodeLevel.value = 100 AddProjectBO.value.projectParam = { name: '', sort: 0 } } +const category = () => { + queryAllByType({ type: 0, pid: 0 }).then(res => { + bigList.value = convertToTree(res.data) + }) +} +// 组装用户大小类 +const convertToTree = (data: any) => { + const nodeMap: any = {} + const roots: any = [] + + // 第一步:将所有节点存储到一个以id为键的映射中 + data.forEach(item => { + nodeMap[item.id] = { ...item, children: [] } + }) + + // 第二步:遍历数据,根据pid找到对应的父节点,并将当前节点添加到父节点的children数组中 + data.forEach(item => { + const parentId = item.pid + if (parentId === '0') { + roots.push(nodeMap[item.id]) + } else { + const parent = nodeMap[parentId] + if (parent) { + parent.children.push(nodeMap[item.id]) + } + } + }) + + return roots +} // 修改 const update = () => { if (Object.keys(nodeData.value).length == 0) { @@ -2127,6 +2190,11 @@ const update = () => { } pageStatus.value = 3 + // 使用 scrollTo 方法,并启用平滑滚动 + scrollBox.scrollTo({ + top: scrollBox.scrollHeight, // 滚动到内容的最底部 + behavior: 'smooth' // 启用平滑滚动动画 + }) } // 删除 const remove = () => { @@ -2424,7 +2492,7 @@ const queryNodeContent = () => { } let data = { id: nodeData.value.id, - level: nodeData.value.plevel == 7 ? '700' : nodeLevel.value + level: nodeData.value.plevel * 100 } queryTerminal(data).then(res => { // console.log("内容详情", res); @@ -2940,7 +3008,7 @@ const area = () => { deviceBODetail.value.nextTimeCheck = year + 1 + '-' + month + '-' + (day - 1 > 10 ? day - 1 : '0' + (day - 1)) } const setDown = () => { - selectDown().then(res => { + selectUserList({}).then(res => { newStationIdArr.value = res.data }) } @@ -2957,6 +3025,7 @@ onMounted(() => { } else { setDown() } + category() }) area()