BUG 30910
This commit is contained in:
@@ -98,12 +98,11 @@
|
||||
|
||||
<el-form-item label="生效网格" :prop="form.validRangeType == 1 ? 'validRangeData' : ''"
|
||||
:rules="[{ required: true, message: '请选择生效网格', trigger: 'change' }, ]" v-if="form.validRangeType == 1">
|
||||
<ai-dialog-btn dialogTitle="选择网格" append-to-body @onConfirm="getCheckedTree" :customFooter="false">
|
||||
<el-button slot="btn" type="text">{{ girdInfoList.length ? "重新选择" : "请选择" }}</el-button>
|
||||
<ai-dialog-btn dialogTitle="选择网格" append-to-body @onConfirm="getCheckedTree" :customFooter="false" :text="girdInfoList.length ? '重新选择' : '请选择'">
|
||||
<div class="grid">
|
||||
<el-tree :data="treeObj.treeList" :props="treeObj.defaultProps" node-key="id" :expand-on-click-node="false">
|
||||
<template slot-scope="{data}">
|
||||
<el-row class="fill" type="flex" @click.native.stop="data.checked=!data.checked">
|
||||
<el-row class="fill" type="flex" @click.native.stop="handleTreeChecked(data)">
|
||||
<div class="fill" v-text="data.girdName"/>
|
||||
<div class="iconfont iconSuccess color-primary mar-r8" v-if="data.checked"/>
|
||||
</el-row>
|
||||
@@ -237,6 +236,7 @@ export default {
|
||||
isLeaf: 'leaf'
|
||||
},
|
||||
},
|
||||
treeSelected: {},
|
||||
girdInfoList: [],
|
||||
rulueType: "0",
|
||||
girdNameList: [],
|
||||
@@ -404,43 +404,35 @@ export default {
|
||||
return result;
|
||||
},
|
||||
getCheckedTree() {
|
||||
if (!this.$refs.tree.getCheckedNodes().length) {
|
||||
const selected = Object.values(this.treeSelected)
|
||||
if (!selected.length) {
|
||||
return this.$message.error("请选择网格");
|
||||
}
|
||||
|
||||
this.girdInfoList = this.$refs.tree.getCheckedNodes().map((item) => {
|
||||
this.girdInfoList = selected.map((item) => {
|
||||
return {...item, checkType: true};
|
||||
});
|
||||
|
||||
|
||||
let validRangeData = this.$refs.tree.getCheckedNodes().map((e) => {
|
||||
return {
|
||||
id: e.id,
|
||||
girdName: e.girdName
|
||||
}
|
||||
}
|
||||
)
|
||||
let validRangeData = selected.map((e) => ({id: e.id, girdName: e.girdName}))
|
||||
this.girdNameList = validRangeData.map(e => e.girdName)
|
||||
this.form.validRangeData = JSON.stringify(validRangeData)
|
||||
|
||||
},
|
||||
beforeSelectTree() {
|
||||
this.instance.post(`/app/appgirdinfo/listAll3`, null, null).then((res) => {
|
||||
if (res?.data) {
|
||||
res.data = res.data.map(e => ({...e, checked: !!this.girdInfoList.find(s => s.id == e.id)}))
|
||||
this.girdInfoList.map(e => this.treeSelected[e.id] = e)
|
||||
this.treeObj.treeList = this.$arr2tree(res.data, {parent: 'parentGirdId'})
|
||||
}
|
||||
});
|
||||
},
|
||||
onCheckChange(e) {
|
||||
this.girdInfoList?.forEach((item) => {
|
||||
if (item.id == e.id) {
|
||||
this.$refs.tree.setChecked(e.id, false);
|
||||
} else {
|
||||
this.$refs.tree.setChecked(e.id, true);
|
||||
}
|
||||
})
|
||||
},
|
||||
handleTreeChecked(data) {
|
||||
data.checked = !data.checked
|
||||
if (data.checked) {
|
||||
this.treeSelected[data.id] = data
|
||||
} else {
|
||||
delete this.treeSelected[data.id]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isEdit() {
|
||||
|
||||
Reference in New Issue
Block a user