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

View File

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