列表中,相同id分一组

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
}
posted @ 2024-04-27 11:56  hello芳芳  阅读(1)  评论(0编辑  收藏  举报