基础设施记住已选择
This commit is contained in:
parent
8a0ac98824
commit
0400fdbbb1
|
@ -44,6 +44,11 @@
|
||||||
<el-button type="primary" style="margin-left:10px;margin-top:4px" size="small" @click="clear">
|
<el-button type="primary" style="margin-left:10px;margin-top:4px" size="small" @click="clear">
|
||||||
重置
|
重置
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button type="primary" style="margin-left:10px;margin-top:4px" size="small"
|
||||||
|
@click="clearSelectArray">
|
||||||
|
清空已选择
|
||||||
|
</el-button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -115,6 +120,7 @@ export default {
|
||||||
showKey: 0,
|
showKey: 0,
|
||||||
showModal: false,
|
showModal: false,
|
||||||
selectedArray: [], // 已选择的数据id
|
selectedArray: [], // 已选择的数据id
|
||||||
|
selectedArrayCopy: [],
|
||||||
displayList: [], // 用于展示的list
|
displayList: [], // 用于展示的list
|
||||||
btnList: ['视频资源', '云资源', '感知资源'],
|
btnList: ['视频资源', '云资源', '感知资源'],
|
||||||
showText: {
|
showText: {
|
||||||
|
@ -210,6 +216,8 @@ export default {
|
||||||
this.displayList = JSON.parse(JSON.stringify(arr));
|
this.displayList = JSON.parse(JSON.stringify(arr));
|
||||||
// 已选中
|
// 已选中
|
||||||
this.selectedArray = arr.map(v => v.idtCameraChannel);
|
this.selectedArray = arr.map(v => v.idtCameraChannel);
|
||||||
|
this.selectedArrayCopy = JSON.parse(JSON.stringify(arr));
|
||||||
|
|
||||||
this.dataList = JSON.parse(JSON.stringify(arr));
|
this.dataList = JSON.parse(JSON.stringify(arr));
|
||||||
this.pageData.total = arr.length;
|
this.pageData.total = arr.length;
|
||||||
// 默认选中复选框
|
// 默认选中复选框
|
||||||
|
@ -303,24 +311,38 @@ export default {
|
||||||
this.searchData.parentId = parentId;
|
this.searchData.parentId = parentId;
|
||||||
this.getData(parentId)
|
this.getData(parentId)
|
||||||
},
|
},
|
||||||
|
clearSelectArray() {
|
||||||
|
this.selectedArrayCopy = []
|
||||||
|
this.selectedArray = []
|
||||||
|
this.getData()
|
||||||
|
},
|
||||||
confirmSubmitHandle() {
|
confirmSubmitHandle() {
|
||||||
if (this.selectedArray.length > this.maxNum) {
|
// 新选择的
|
||||||
|
let idtCameraChannelArray = this.selectedArray.map(v => v.idtCameraChannel)
|
||||||
|
// 选过的
|
||||||
|
let newIdArray = this.selectedArrayCopy.map(v => v.idtCameraChannel)
|
||||||
|
let idArray = [...new Set(newIdArray.concat(idtCameraChannelArray))]
|
||||||
|
if (idArray.length > this.maxNum) {
|
||||||
return this.$message.error('最多选择十条数据!');
|
return this.$message.error('最多选择十条数据!');
|
||||||
}
|
}
|
||||||
this.showModal = false;
|
|
||||||
this.displayList = []
|
let listArray = [].concat(this.selectedArrayCopy, this.dataList);
|
||||||
let idtCameraChannelArray = this.selectedArray.map(v => v.idtCameraChannel)
|
this.displayList = [];
|
||||||
this.dataList.map(v => {
|
idArray.map(v => {
|
||||||
if (idtCameraChannelArray.includes(v.idtCameraChannel)) {
|
let obj = listArray.find(k => k.idtCameraChannel === v)
|
||||||
|
if (obj) {
|
||||||
this.displayList.push({
|
this.displayList.push({
|
||||||
channelName: v.channelName
|
channelName: obj.channelName
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.$emit('update', {
|
this.$emit('update', {
|
||||||
title: this.type,
|
title: this.type,
|
||||||
list: idtCameraChannelArray
|
list: idArray,
|
||||||
})
|
})
|
||||||
|
this.showModal = false;
|
||||||
},
|
},
|
||||||
close() {
|
close() {
|
||||||
this.showModal = false;
|
this.showModal = false;
|
||||||
|
|
Loading…
Reference in New Issue