feat(energyManagement): 添加水电气树接口

This commit is contained in:
2025-08-27 20:44:00 +08:00
parent e8d2650f9a
commit 8e61d61fdd
3 changed files with 38 additions and 26 deletions

View File

@@ -4,8 +4,8 @@ import type { PropType } from 'vue'
import { onMounted, ref } from 'vue'
import { handleNode } from '@vben/utils'
import { Empty, Skeleton, Tree } from 'ant-design-vue'
import { communityTree } from "#/api/property/community"
import type { CommunityVO } from "#/api/property/community/model"
import { queryTree } from "#/api/property/energyManagement/meterInfo"
import type { TreeNode } from '#/api/common'
defineOptions({ inheritAttrs: false })
@@ -31,26 +31,31 @@ const searchValue = defineModel('searchValue', {
default: '',
})
type TreeArray = CommunityVO[]
const treeArray = ref<TreeArray>([])
const treeArray = ref<TreeNode[]>([])
/** 骨架屏加载 */
const showTreeSkeleton = ref<boolean>(true)
async function loadTree() {
showTreeSkeleton.value = true
searchValue.value = ''
selectFloorId.value = []
const ret = await communityTree(3)
const splitStr = '/'
handleNode(ret, 'label', splitStr, function (node: any) {
if (node.level != 3) {
node.disabled = true
}
})
const ret = await queryTree(1)
handleNode(ret, 3)
treeArray.value = ret
showTreeSkeleton.value = false
}
function handleNode(nodes: any[], level: number) {
nodes.forEach((node) => {
node.key = node.id
if (node.level < level) {
node.disabled = true
}
if (node.children) {
handleNode(node.children, level)
}
})
}
onMounted(loadTree);
</script>
@@ -59,8 +64,7 @@ onMounted(loadTree);
<Skeleton :loading="showTreeSkeleton" :paragraph="{ rows: 8 }" active class="p-[8px] flex-1 min-h-0">
<div class="bg-background flex h-full flex-col overflow-y-auto rounded-lg">
<div class="h-full overflow-x-hidden px-[8px]">
<Tree v-bind="$attrs" v-if="treeArray.length > 0" v-model:selected-keys="selectFloorId"
:field-names="{ title: 'label', key: 'id' }" :show-line="{ showLeafIcon: false }" :tree-data="treeArray"
<Tree v-bind="$attrs" v-if="treeArray.length > 0" :show-line="{ showLeafIcon: false }" :tree-data="treeArray"
:virtual="false" default-expand-all @select="$emit('select')">
<template #title="{ label }">
<span v-if="label.indexOf(searchValue) > -1">

View File

@@ -257,7 +257,7 @@ function handleSelectFloor() {
<template>
<Page :auto-content-height="true">
<div class="flex h-full gap-[8px]">
<FloorTree class="w-[260px]" @select="handleSelectFloor" v-model:select-floor-id="selectFloorId"></FloorTree>
<FloorTree class="w-[260px]"></FloorTree>
<div class="flex-1 overflow-hidden">
<div class="row">
<div class="comparison-section-container">