仓库送料筛选逻辑
This commit is contained in:
@@ -62,22 +62,19 @@
|
||||
this.title = options.title
|
||||
},
|
||||
onShow () {
|
||||
this.pointCode = this.$store.getters.publicObj
|
||||
if (this.$store.getters.publicArr.length) {
|
||||
const newItems = this.$store.getters.publicArr;
|
||||
const existingCodes = new Set(this.dataList.map(item => item.material_code));
|
||||
newItems.forEach(item => {
|
||||
// 若物料编码不存在于现有集合中,则添加
|
||||
if (!existingCodes.has(item.material_code)) {
|
||||
item.point_code = this.pointCode
|
||||
item.pcsn = ''
|
||||
item.qty = ''
|
||||
this.dataList.push(item)
|
||||
existingCodes.add(item.material_code)
|
||||
}
|
||||
const combined = [...this.dataList, ...this.$store.getters.publicArr];
|
||||
const map = new Map();
|
||||
combined.forEach(item => {
|
||||
const key = `${item.material_code}_${item.point_code}`;
|
||||
// 仅当键不存在时才添加,这样先出现的记录会被保留
|
||||
if (!map.has(key)) {
|
||||
map.set(key, item);
|
||||
}
|
||||
});
|
||||
this.dataList = Array.from(map.values());
|
||||
|
||||
this.$store.dispatch('setPublicArr', '')
|
||||
console.log(90)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user