|
|
|
@ -41,7 +41,6 @@ |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
import { getList } from "@/api/secondOrder/list.js"; |
|
|
|
import { getList } from "@/api/secondOrder/list.js"; |
|
|
|
import { getList as fetchDurableApi } from "@/api/materials/expend"; |
|
|
|
import { getList as fetchDurableApi } from "@/api/materials/expend"; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
export default { |
|
|
|
props: { |
|
|
|
props: { |
|
|
|
categoryVisible: { |
|
|
|
categoryVisible: { |
|
|
|
@ -53,7 +52,7 @@ export default { |
|
|
|
default: "", |
|
|
|
default: "", |
|
|
|
}, |
|
|
|
}, |
|
|
|
departmentId: { |
|
|
|
departmentId: { |
|
|
|
type: [String, Number], |
|
|
|
type: String, |
|
|
|
default: "", |
|
|
|
default: "", |
|
|
|
}, |
|
|
|
}, |
|
|
|
selectionData: { |
|
|
|
selectionData: { |
|
|
|
@ -196,26 +195,18 @@ export default { |
|
|
|
// 更新当前页面的勾选状态 |
|
|
|
// 更新当前页面的勾选状态 |
|
|
|
updateCurrentPageSelection() { |
|
|
|
updateCurrentPageSelection() { |
|
|
|
if (!this.$refs.crud || !this.data) return; |
|
|
|
if (!this.$refs.crud || !this.data) return; |
|
|
|
|
|
|
|
|
|
|
|
this.isUpdatingSelection = true; |
|
|
|
this.isUpdatingSelection = true; |
|
|
|
|
|
|
|
|
|
|
|
const currentPageData = this.data || []; |
|
|
|
const currentPageData = this.data || []; |
|
|
|
|
|
|
|
|
|
|
|
// 先清除所有选择 |
|
|
|
|
|
|
|
this.$refs.crud.toggleSelection(); |
|
|
|
this.$refs.crud.toggleSelection(); |
|
|
|
|
|
|
|
console.log(this.allSelectedList,'勾选状态数据') |
|
|
|
// 检查当前页面的数据中有哪些在 allSelectedList 中 |
|
|
|
|
|
|
|
currentPageData.forEach((item) => { |
|
|
|
currentPageData.forEach((item) => { |
|
|
|
const isSelected = this.allSelectedList.some( |
|
|
|
const isSelected = this.allSelectedList.some( |
|
|
|
(selectedItem) => selectedItem.id === item.id |
|
|
|
(selectedItem) => selectedItem.id === item.id |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (isSelected) { |
|
|
|
if (isSelected) { |
|
|
|
this.$refs.crud.toggleRowSelection(item, true); |
|
|
|
this.$refs.crud.toggleRowSelection(item, true); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// 延迟 确保选择状态已完全更新 |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
this.$nextTick(() => { |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
this.isUpdatingSelection = false; |
|
|
|
this.isUpdatingSelection = false; |
|
|
|
@ -225,66 +216,55 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
//勾选选中 |
|
|
|
//勾选选中 |
|
|
|
selectionChange(selection,row) { |
|
|
|
selectionChange(selection,row) { |
|
|
|
|
|
|
|
|
|
|
|
let isSelectedInfo = selection.filter( |
|
|
|
let isSelectedInfo = selection.filter( |
|
|
|
(item) => item.id==row.id |
|
|
|
(item) => item.id==row.id |
|
|
|
); |
|
|
|
); |
|
|
|
if (this.isUpdatingSelection) { |
|
|
|
if (this.isUpdatingSelection) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 获取当前页面的数据ID |
|
|
|
|
|
|
|
const currentPageIds = this.data.map((item) => item.id); |
|
|
|
const currentPageIds = this.data.map((item) => item.id); |
|
|
|
|
|
|
|
|
|
|
|
const otherPageSelected = this.allSelectedList.filter( |
|
|
|
const otherPageSelected = this.allSelectedList.filter( |
|
|
|
(item) => !currentPageIds.includes(item.id) |
|
|
|
(item) => !currentPageIds.includes(item.id) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const currentSelected = selection.map((item) => ({ |
|
|
|
const currentSelected = selection.map((item) => ({ |
|
|
|
...item, |
|
|
|
...item, |
|
|
|
twoInventoryId: item.id, |
|
|
|
twoInventoryId: item.id, |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
// 组合所有勾选数据 |
|
|
|
|
|
|
|
const combinedSelection = [ |
|
|
|
const combinedSelection = [ |
|
|
|
...otherPageSelected, // 其他页面的数据 |
|
|
|
...otherPageSelected, |
|
|
|
...currentSelected, // 当前页面新勾选的数据 |
|
|
|
...currentSelected, |
|
|
|
]; |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
// 去重并更新 allSelectedList |
|
|
|
|
|
|
|
this.allSelectedList = this.uniqueById(combinedSelection); |
|
|
|
this.allSelectedList = this.uniqueById(combinedSelection); |
|
|
|
|
|
|
|
if(isSelectedInfo.length <= 0){ |
|
|
|
if(isSelectedInfo.length<=0){ |
|
|
|
this.allSelectedList = this.allSelectedList.filter( |
|
|
|
this.allSelectedList=this.allSelectedList.filter( |
|
|
|
(item) => item.id !== row.id |
|
|
|
(item) => item.id!==row.id |
|
|
|
|
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('isSelectedInfo', this.allSelectedList); |
|
|
|
|
|
|
|
this.allSelectedList.forEach(item=>{ |
|
|
|
this.allSelectedList.forEach(item=>{ |
|
|
|
item.num = 0 |
|
|
|
item.num = 1 |
|
|
|
}) |
|
|
|
}) |
|
|
|
// console.log("更新后的allSelectedList:", this.allSelectedList); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//去重 |
|
|
|
//去重 |
|
|
|
uniqueById(arr) { |
|
|
|
uniqueById(arr) { |
|
|
|
const uniqueObj = {}; |
|
|
|
const uniqueObj = {}; |
|
|
|
arr.forEach((item) => { |
|
|
|
arr.forEach((item) => { |
|
|
|
if (item.id && !uniqueObj[item.id]) { |
|
|
|
if (item.id && !uniqueObj[item.id]) { |
|
|
|
uniqueObj[item.id] = item; |
|
|
|
uniqueObj[item.id] = item |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}) |
|
|
|
return Object.values(uniqueObj); |
|
|
|
return Object.values(uniqueObj) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
//点击确定 |
|
|
|
//点击确定 |
|
|
|
handleConfirm() { |
|
|
|
handleConfirm() { |
|
|
|
const uniqueList = this.uniqueById(this.allSelectedList); |
|
|
|
const uniqueList = this.uniqueById(this.allSelectedList); |
|
|
|
this.$emit("confirm", uniqueList); |
|
|
|
this.$emit("confirm", uniqueList); |
|
|
|
|
|
|
|
this.allSelectedList = [] |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectionClear() { |
|
|
|
selectionClear() { |
|
|
|
this.allSelectedList = []; |
|
|
|
this.allSelectedList = []; |
|
|
|
if (this.$refs.crud) { |
|
|
|
if (this.$refs.crud) { |
|
|
|
@ -336,7 +316,7 @@ export default { |
|
|
|
}) |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
.finally(() => { |
|
|
|
this.loading = false; |
|
|
|
this.loading = false; |
|
|
|
}); |
|
|
|
}) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
handleCancel() { |
|
|
|
handleCancel() { |
|
|
|
|