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