|
|
|
|
@ -11,7 +11,7 @@ |
|
|
|
|
@refresh-change="refreshChange" @on-load="onLoad" @row-change="handleRowChange"> |
|
|
|
|
</avue-crud> |
|
|
|
|
<div slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button @click="handleCancel">取消</el-button> |
|
|
|
|
<el-button @click="handleCloseDetail">取消</el-button> |
|
|
|
|
<el-button type="primary" @click="handleConfirm">确定</el-button> |
|
|
|
|
</div> |
|
|
|
|
</el-dialog> |
|
|
|
|
@ -31,7 +31,7 @@ export default { |
|
|
|
|
default: '' |
|
|
|
|
}, |
|
|
|
|
departmentId: { |
|
|
|
|
type: [String, Number], |
|
|
|
|
type: String, |
|
|
|
|
default: '' |
|
|
|
|
}, |
|
|
|
|
selectionData: { |
|
|
|
|
@ -174,11 +174,8 @@ export default { |
|
|
|
|
// 更新当前页面的勾选状态 |
|
|
|
|
updateCurrentPageSelection() { |
|
|
|
|
if (!this.$refs.crud || !this.data) return; |
|
|
|
|
|
|
|
|
|
this.isUpdatingSelection = true; |
|
|
|
|
|
|
|
|
|
const currentPageData = this.data || []; |
|
|
|
|
|
|
|
|
|
const currentPageData = this.data |
|
|
|
|
// 先清除所有选择 |
|
|
|
|
this.$refs.crud.toggleSelection(); |
|
|
|
|
|
|
|
|
|
@ -191,6 +188,7 @@ export default { |
|
|
|
|
if (isSelected) { |
|
|
|
|
this.$refs.crud.toggleRowSelection(item, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 延迟 确保选择状态已完全更新 |
|
|
|
|
@ -201,40 +199,19 @@ export default { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//勾选选中 |
|
|
|
|
selectionChange(selection) { |
|
|
|
|
if (this.isUpdatingSelection) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log('当前选择:', selection) |
|
|
|
|
console.log('当前页面数据:', this.data) |
|
|
|
|
console.log('当前全部勾选:', this.allSelectedList) |
|
|
|
|
|
|
|
|
|
// 获取当前页面的数据ID |
|
|
|
|
const currentPageIds = this.data.map(item => item.id); |
|
|
|
|
|
|
|
|
|
const otherPageSelected = this.allSelectedList.filter(item => |
|
|
|
|
!currentPageIds.includes(item.id) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const currentSelected = selection.map(item => ({ |
|
|
|
|
selectionChange(selection) { |
|
|
|
|
console.log(selection,'selection-------') |
|
|
|
|
console.log(this.selectionData, '---selectionData') |
|
|
|
|
const currentPageIds = this.selectionData.map(item => item.id) |
|
|
|
|
let arr = selection.filter(item => !currentPageIds.includes(item.id)) //未选择的数据 |
|
|
|
|
const selectionWithTwoInventoryId = arr.map(item => ({ |
|
|
|
|
...item, |
|
|
|
|
twoInventoryId: item.id |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
// 组合所有勾选数据 |
|
|
|
|
const combinedSelection = [ |
|
|
|
|
...otherPageSelected, // 其他页面的数据 |
|
|
|
|
...currentSelected // 当前页面新勾选的数据 |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// 去重并更新 allSelectedList |
|
|
|
|
this.allSelectedList = this.uniqueById(combinedSelection) |
|
|
|
|
|
|
|
|
|
console.log('更新后的allSelectedList:', this.allSelectedList) |
|
|
|
|
})) |
|
|
|
|
this.allSelectedList.push(...selectionWithTwoInventoryId); |
|
|
|
|
this.allSelectedList = this.uniqueById(this.allSelectedList); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//去重 |
|
|
|
|
uniqueById(arr) { |
|
|
|
|
const uniqueObj = {}; |
|
|
|
|
|