From 0400fdbbb1df42429bc11c4f4d082b9f485043a9 Mon Sep 17 00:00:00 2001 From: guoyue Date: Sat, 27 Aug 2022 15:03:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=BA=E7=A1=80=E8=AE=BE=E6=96=BD=E8=AE=B0?= =?UTF-8?q?=E4=BD=8F=E5=B7=B2=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/infrastructure-modal.vue | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/back/src/views/modules/ability/assignedScene/components/infrastructure-modal.vue b/back/src/views/modules/ability/assignedScene/components/infrastructure-modal.vue index ae7be4fe..caf3a71c 100644 --- a/back/src/views/modules/ability/assignedScene/components/infrastructure-modal.vue +++ b/back/src/views/modules/ability/assignedScene/components/infrastructure-modal.vue @@ -44,6 +44,11 @@ 重置 + + 清空已选择 + + @@ -115,6 +120,7 @@ export default { showKey: 0, showModal: false, selectedArray: [], // 已选择的数据id + selectedArrayCopy: [], displayList: [], // 用于展示的list btnList: ['视频资源', '云资源', '感知资源'], showText: { @@ -210,6 +216,8 @@ export default { this.displayList = JSON.parse(JSON.stringify(arr)); // 已选中 this.selectedArray = arr.map(v => v.idtCameraChannel); + this.selectedArrayCopy = JSON.parse(JSON.stringify(arr)); + this.dataList = JSON.parse(JSON.stringify(arr)); this.pageData.total = arr.length; // 默认选中复选框 @@ -303,24 +311,38 @@ export default { this.searchData.parentId = parentId; this.getData(parentId) }, + clearSelectArray() { + this.selectedArrayCopy = [] + this.selectedArray = [] + this.getData() + }, 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('最多选择十条数据!'); } - this.showModal = false; - this.displayList = [] - let idtCameraChannelArray = this.selectedArray.map(v => v.idtCameraChannel) - this.dataList.map(v => { - if (idtCameraChannelArray.includes(v.idtCameraChannel)) { + + let listArray = [].concat(this.selectedArrayCopy, this.dataList); + this.displayList = []; + idArray.map(v => { + let obj = listArray.find(k => k.idtCameraChannel === v) + if (obj) { this.displayList.push({ - channelName: v.channelName + channelName: obj.channelName }) } + }) + this.$emit('update', { title: this.type, - list: idtCameraChannelArray + list: idArray, }) + this.showModal = false; }, close() { this.showModal = false;