|
|
@@ -55,7 +55,8 @@
|
|
|
</view>
|
|
|
|
|
|
<view class="item ww20 ">
|
|
|
- <text>{{Number(it.quantity) - Number(it.sampleNum) + Number((it.reuseNum || 0)) }}</text>
|
|
|
+ <!-- <text>{{Number(it.quantity) - Number(it.sampleNum) + Number((it.reuseNum || 0)) }}</text> -->
|
|
|
+ <text>{{Number(it.quantity) - Number(it.sampleNum) }}</text>
|
|
|
</view>
|
|
|
|
|
|
<view class="item ww20">
|
|
|
@@ -178,25 +179,40 @@
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+
|
|
|
reuseTurn(list) {
|
|
|
|
|
|
- list.forEach(a => {
|
|
|
- if (Object.prototype.hasOwnProperty.call(a, 'selectType') && a.selectType == 1 && !a.isSel) {
|
|
|
- console.log(this.newList)
|
|
|
- this.newList.forEach(f => {
|
|
|
- if (f.extInfo && f.extInfo.positionList && f.extInfo.positionList.length > 0) {
|
|
|
- f.extInfo.positionList.forEach(o => {
|
|
|
- if (a.selectType == 1 && a.code == o.code) {
|
|
|
- a.isSel = 1
|
|
|
- o.reuseNum = Number(o.reuseNum) + 1
|
|
|
- }
|
|
|
- })
|
|
|
|
|
|
- }
|
|
|
+ let obj = list.reduce((accumulator, currentValue) => {
|
|
|
+ // 如果当前 code 已经在 accumulator 中,则递增其计数
|
|
|
+ // 否则,在 accumulator 中添加新的键值对
|
|
|
+ if (currentValue.code in accumulator) {
|
|
|
+ if (currentValue.selectType == 1) {
|
|
|
+ accumulator[currentValue.code]++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (currentValue.selectType == 1) {
|
|
|
+ accumulator[currentValue.code] = 1;
|
|
|
+ } else {
|
|
|
+ accumulator[currentValue.code] = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return accumulator;
|
|
|
+ }, {}); // 初始的 accumulator 是一个空对象
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.newList.forEach(f => {
|
|
|
+ if (f.extInfo && f.extInfo.positionList && f.extInfo.positionList.length > 0) {
|
|
|
+ f.extInfo.positionList.forEach(o => {
|
|
|
+ o.reuseNum = obj[o.code] || 0
|
|
|
})
|
|
|
|
|
|
}
|
|
|
})
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|