This commit is contained in:
yanran200730
2022-08-25 09:34:40 +08:00
parent ff973bf62f
commit 8fa7e9c083

View File

@@ -37,17 +37,20 @@
</el-form-item>
</el-form>
</div>
<ai-dialog title="选择网格" :visible.sync="showGrid" :customFooter="true" :destroyOnClose="true"
@opened="beforeSelectTree" border width="720px">
<ai-dialog title="选择网格" :visible.sync="showGrid" :customFooter="true" :destroyOnClose="true" border width="720px">
<div class="grid">
<el-tree :data="treeObj.treeList" :props="treeObj.defaultProps" node-key="id" ref="tree"
:check-strictly="true" show-checkbox
:default-checked-keys="treeObj.checkedKeys" default-expand-all
@check="onCheckChange">
<template slot-scope="{node,data}">
<el-tooltip :content="node.label">
<div class="el-tree-node__label" v-text="node.label"/>
</el-tooltip>
<el-tree
:data="treeObj.treeList"
:props="treeObj.defaultProps"
node-key="id"
ref="tree"
:check-strictly="true"
show-checkbox
:default-checked-keys="treeObj.checkedKeys"
:default-expanded-keys="treeObj.checkedKeys"
@check="onCheckChange">
<template slot-scope="{node}">
<div class="el-tree-node__label" :title="node.label" v-text="node.label"/>
</template>
</el-tree>
</div>
@@ -98,7 +101,7 @@ export default {
treeObj: {
treeList: [],
defaultProps: {
children: "girdList",
children: "children",
label: "girdName",
},
checkedKeys: [],
@@ -115,6 +118,7 @@ export default {
},
created() {
this.beforeSelectTree()
this.dict.load('cardType', 'sex', 'nation').then(() => {
if (this.params && this.params.id) {
this.getInfo(this.params.id)
@@ -123,15 +127,23 @@ export default {
},
methods: {
beforeSelectTree() {
this.treeObj.checkedKeys = [];
this.instance.post(`/app/appgirdinfo/listAll`, null, null).then((res) => {
this.instance.post(`/app/appgirdinfo/listAll3`).then((res) => {
if (res.code == 0) {
this.treeObj.treeList = this.format(res.data)
this.treeObj.checkedKeys = []
if (this.form.girdInfoList.length) {
this.form.girdInfoList.map((e) => {
this.treeObj.checkedKeys.push(e.id);
});
}
this.treeObj.treeList = res.data.filter(e => !e.parentGirdId)
this.treeObj.treeList.map(p => this.addChild(p, res.data.map(v => {
return {
...v
}
}), {
parent: 'parentGirdId'
}))
}
});
},