累计次数
let batchIds = this.outStoreData.map(item=>item.batchId);
//判断是否选择了相同的批次
let countedNames = batchIds.reduce(function (allNames, name) {
if (name in allNames) {
allNames[name]++;
}else {
allNames[name] = 1;
}
return allNames;
}, {});
countedNames[val.batchId]
例:
let batchList = this.outStoreData.map(item=>(item.id+','+item.warehouseId));
let countedNames = batchList.reduce(function (allNames, name) {
if (name in allNames) {
allNames[name]++;
}else {
allNames[name] = 1;
}
return allNames;
}, {});
countedNames[this.outStoreData[index].id+','+val]