diff --git a/packages/grid/AppGridBlock/components/list.vue b/packages/grid/AppGridBlock/components/list.vue index 440227c4..97e411a9 100644 --- a/packages/grid/AppGridBlock/components/list.vue +++ b/packages/grid/AppGridBlock/components/list.vue @@ -217,8 +217,6 @@ export default { getTreeList() { this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => { if (res?.data) { - // this.treeObj.treeList = [res.data]; - // this.info = res.data this.$nextTick(() => { this.$refs.tree.setCurrentKey(res.data.id) }) diff --git a/packages/grid/AppGridMap/components/list.vue b/packages/grid/AppGridMap/components/list.vue index 0a5277f1..a22f1b33 100644 --- a/packages/grid/AppGridMap/components/list.vue +++ b/packages/grid/AppGridMap/components/list.vue @@ -13,19 +13,19 @@
+ :data="treeObj.treeList" + :props="treeObj.defaultProps" + @node-click="handleNodeClick" + node-key="id" + ref="tree" + :expand-on-click-node="false" + :filter-node-method="filterNode" + :default-expanded-keys="treeObj.defaultExpandedKeys" + highlight-current>
@@ -61,7 +61,7 @@ export default { treeObj: { treeList: [], defaultProps: { - children: "girdList", + children: "children", label: "girdName", }, defaultExpandedKeys: [], @@ -88,9 +88,7 @@ export default { }, created() { this.dict.load("onlineStatus") - this.getTreeList().then(() => { - this.getLeafNodes() - }) + this.getTreeList() }, watch: { filterText(val) { @@ -103,15 +101,29 @@ export default { return data.girdName.indexOf(value) !== -1; }, getTreeList() { - return this.instance.post(`/app/appgirdinfo/listAll`).then((res) => { - if (res.code == 0) { - this.treeObj.treeList = res.data; - + this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => { + if (res?.data) { 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() {