This commit is contained in:
yanran200730
2022-08-25 09:19:11 +08:00
parent d3c8292035
commit ff973bf62f
2 changed files with 34 additions and 24 deletions

View File

@@ -217,8 +217,6 @@ export default {
getTreeList() { getTreeList() {
this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => { this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => {
if (res?.data) { if (res?.data) {
// this.treeObj.treeList = [res.data];
// this.info = res.data
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.tree.setCurrentKey(res.data.id) this.$refs.tree.setCurrentKey(res.data.id)
}) })

View File

@@ -20,12 +20,12 @@
ref="tree" ref="tree"
:expand-on-click-node="false" :expand-on-click-node="false"
:filter-node-method="filterNode" :filter-node-method="filterNode"
default-expand-all :default-expanded-keys="treeObj.defaultExpandedKeys"
highlight-current> highlight-current>
<template slot-scope="{node,data}"> <template slot-scope="{node,data}">
<el-tooltip :content="node.label"> <!-- <el-tooltip :content="node.label"> -->
<div class="el-tree-node__label" v-text="node.label"/> <div class="el-tree-node__label" :title="node.label" v-text="node.label"/>
</el-tooltip> <!-- </el-tooltip> -->
</template> </template>
</el-tree> </el-tree>
</div> </div>
@@ -61,7 +61,7 @@ export default {
treeObj: { treeObj: {
treeList: [], treeList: [],
defaultProps: { defaultProps: {
children: "girdList", children: "children",
label: "girdName", label: "girdName",
}, },
defaultExpandedKeys: [], defaultExpandedKeys: [],
@@ -88,9 +88,7 @@ export default {
}, },
created() { created() {
this.dict.load("onlineStatus") this.dict.load("onlineStatus")
this.getTreeList().then(() => { this.getTreeList()
this.getLeafNodes()
})
}, },
watch: { watch: {
filterText(val) { filterText(val) {
@@ -103,15 +101,29 @@ export default {
return data.girdName.indexOf(value) !== -1; return data.girdName.indexOf(value) !== -1;
}, },
getTreeList() { getTreeList() {
return this.instance.post(`/app/appgirdinfo/listAll`).then((res) => { this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => {
if (res.code == 0) { if (res?.data) {
this.treeObj.treeList = res.data;
this.$nextTick(() => { this.$nextTick(() => {
res.data.length && this.$refs.tree.setCurrentKey(res.data[0].id) this.$refs.tree.setCurrentKey(res.data.id)
}) })
this.treeObj.treeList = res.data.filter(e => !e.parentGirdId)
const parentGirdId = this.treeObj.treeList[0].id
this.treeObj.treeList.map(p => this.addChild(p, res.data.map(v => {
if (v.id === parentGirdId) {
this.treeObj.defaultExpandedKeys.push(v.id)
} }
})
return {
...v
}
}), {
parent: 'parentGirdId'
}))
this.getLeafNodes()
}
});
}, },
onMapInit() { onMapInit() {