This commit is contained in:
hayu 2025-11-16 22:01:33 +08:00
parent 58a2fb721b
commit d6a44fbb08
2 changed files with 50 additions and 13 deletions

View File

@ -95,10 +95,20 @@ export default {
},
methods: {
openDialog(applyId) {
// SelectToolDialog.vue openDialog
openDialog(applyId, externalSelectedRows = []) {
this.applyId = applyId
this.visible = true
this.getList() //
// selectedMap
this.selectedMap.clear()
externalSelectedRows.forEach(row => {
if (row.keyId) {
this.selectedMap.set(row.keyId, { ...row })
}
})
this.getList()
},
setFixNumToTableList(row, val) {
@ -133,23 +143,26 @@ export default {
this.tableList = rows.map(item => {
const key = item.keyId
const selected = this.selectedMap.get(key)
const isCodeManage = item.manageMode === "编码管理"
return {
...item,
keyId: key, // row-key selectedMap key
repairNum: selected ? selected.repairNum : isCodeManage ? 1 : ""
keyId: key,
repairNum: selected ? selected.repairNum : (isCodeManage ? 1 : "")
}
})
// selectedMap tableList keyId
// selectedMap tableList
const tableKeys = new Set(this.tableList.map(r => r.keyId))
Array.from(this.selectedMap.keys()).forEach(key => {
if (!tableKeys.has(key)) this.selectedMap.delete(key)
if (!tableKeys.has(key)) {
this.selectedMap.delete(key)
}
})
this.$nextTick(() => {
if (this.restoreSelection) this.restoreSelection()
this.restoreSelection()
})
} finally {
@ -157,11 +170,19 @@ export default {
}
},
//
restoreSelection() {
if (!this.$refs.multipleTable) return
//
this.$refs.multipleTable.clearSelection()
// selectedMap
this.tableList.forEach(row => {
if (this.selectedMap.has(row.keyId)) {
this.$refs.multipleTable.toggleRowSelection(row, true)
this.$nextTick(() => {
this.$refs.multipleTable.toggleRowSelection(row, true)
})
}
})
},
@ -204,8 +225,10 @@ export default {
this.visible = false
},
// handleClose
handleClose() {
this.selectedMap.clear()
// selectedMap便使
this.visible = false
}
}
}

View File

@ -348,20 +348,34 @@ export default {
this.isLoading = false
}
},
// handleDelete
handleDelete(row) {
this.$confirm('确定删除该条数据?', '提示', { type: 'warning' }).then(() => {
this.tableList = this.tableList.filter(item => item.keyId !== row.keyId)
// selectedMap
if (this.$refs.addNum) {
const dialog = this.$refs.addNum
dialog.selectedMap.delete(row.keyId)
dialog.tableList = dialog.tableList.filter(item => item.keyId !== row.keyId)
dialog.$nextTick(() => dialog.restoreSelection())
//
if (dialog.visible) {
dialog.tableList = dialog.tableList.filter(item => item.keyId !== row.keyId)
dialog.$nextTick(() => dialog.restoreSelection())
}
}
this.total = this.tableList.length
this.$message.success('删除成功')
})
},
handleNumDialog() { if (this.$refs.addNum) this.$refs.addNum.openDialog(this.queryParams.applyId) },
//
handleNumDialog() {
if (this.$refs.addNum) {
//
this.$refs.addNum.openDialog(this.queryParams.applyId, this.tableList)
}
},
handleAddFromDialog(rows) {
if (!rows || rows.length === 0) return
const existingKeys = new Set(this.tableList.map(item => item.keyId))