优化网格选择组件

This commit is contained in:
yanran200730
2022-08-24 16:06:50 +08:00
parent 64d2edd2cd
commit 883aca74e1

View File

@@ -197,18 +197,18 @@
</template>
</ai-card>
</el-form>
<ai-dialog title="选择网格" :visible.sync="showGrid" :customFooter="true" :destroyOnClose="true" border width="720px">
<ai-dialog title="选择网格" :visible.sync="showGrid" :customFooter="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="currCheckedKeys"
default-expand-all
@check="onCheckChange">
:data="treeList"
:props="defaultProps"
node-key="id"
ref="tree"
:check-strictly="true"
show-checkbox
:default-expanded-keys="currCheckedKeys"
:default-checked-keys="currCheckedKeys"
@check="onCheckChange">
</el-tree>
</div>
<div class="dialog-footer" slot="footer">
@@ -266,13 +266,14 @@ export default {
}],
showGrid: false,
treeObj: {
treeList: [],
defaultProps: {
children: "girdList",
label: "girdName",
},
checkedKeys: [],
},
treeList: [],
defaultProps: {
children: "children",
label: "girdName",
},
defaultExpandedKeys: [],
girdInfoStr: '',
photoList: [],
title: "添加网格员",
@@ -391,12 +392,26 @@ export default {
},
beforeSelectTree() {
this.treeObj.checkedKeys = [];
this.instance.post(`/app/appgirdinfo/listAll`, null, null).then((res) => {
this.instance.post(`/app/appgirdinfo/listAll3`, null, null).then((res) => {
if (res.code == 0) {
this.treeObj.treeList = res.data;
this.forms.girdInfoList.map((e) => {
this.treeObj.checkedKeys.push(e.id);
});
this.treeList = res.data.filter(e => !e.parentGirdId)
const parentGirdId = this.treeList[0].id
this.treeList.map(p => this.addChild(p, res.data.map(v => {
if (v.id === parentGirdId) {
this.defaultExpandedKeys.push(v.id)
}
return {
...v
}
}), {
parent: 'parentGirdId'
}))
}
});
},