[update] 修改标准选择跨页问题

This commit is contained in:
lideqin
2024-02-04 11:57:32 +08:00
parent 88af34ea16
commit cc3098c7a8
@@ -232,7 +232,7 @@ export default {
if (res.success) { if (res.success) {
this.dataList = res.result.records this.dataList = res.result.records
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.selectedRowKeys = this.value ? this.value.split(',') : [] this.selectedRowKeys = this.value ? this.value.split(',') : (this.selectedRowKeys || [])
} else { } else {
this.dataList = [] this.dataList = []
} }
@@ -253,9 +253,37 @@ export default {
this.replacePage(1) this.replacePage(1)
}, },
// 表格选择改变 // 表格选择改变
onSelectChange (value, row) { onSelectChange (selectedRowKeys, selectedRows) {
this.selectedRowKeys = value this.selectedRowKeys = selectedRowKeys
this.selectedRowList = row // this.selectedRowList = row
if (this.type === 'checkbox') {
if (selectedRowKeys.length > this.selectedRowList.length) {
// 说明是增加了数据
for (const rowIndex in selectedRows) {
if (!this.selectedRowList.find(item => item.standardNumber === selectedRows[rowIndex].standardNumber)) {
// 右侧不存在,追加到右侧表格
this.selectedRowList.push(selectedRows[rowIndex])
}
}
} else {
// 说明是删除了数据
if (selectedRowKeys && selectedRowKeys.length > 0) {
// 没有选中数据,说明这一页没有选中数据了
for (let i = 0; i < this.selectedRowList.length; i++) {
if (!selectedRowKeys.find(item => item === this.selectedRowList[i].standardNumber)) {
// 表格选中中没有找到这一条数据,说明已经被删了
this.selectedRowList.splice(i, 1)
i--
}
}
} else {
this.selectedRowList = []
}
}
console.log(this.selectedRowList)
} else {
this.selectedRowList = selectedRows
}
}, },
handleTableChange (pagination) { handleTableChange (pagination) {
// 分页、排序、筛选变化时触发 // 分页、排序、筛选变化时触发