列表中,相同id分一組

hello芳芳發表於2024-04-27
const commonItem = {}
this.mainForm.customermachinedetailList.forEach(item => {
if (commonItem[item.lngdetailid]) {
commonItem[item.lngdetailid].push(item)
} else {
this.$set(commonItem, item.lngdetailid, [item])
}
})
this.sumequal = true
Object.keys(commonItem).forEach((val, index) => {
this.sum = 0
commonItem[val].forEach(item => {
this.sum += item.dbldeliveryquantity * 1
})
if (commonItem[val][0].dblquantity !== this.sum) {
this.sumequal = false
}
})
if (!this.sumequal) {
this.$message.error('可配貨數量不等於申請數量')
return false
}

相關文章