ysy 2 gadi atpakaļ
vecāks
revīzija
9b23aec667

+ 29 - 13
pages/pda/sample/components/reuseTurnoverBom.vue

@@ -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
 						})
 
 					}
 				})
+
 			},
 
 

+ 2 - 0
pages/pda/sample/components/sampleBom.vue

@@ -322,6 +322,7 @@
 			},
 
 			hendleReuseNum() {
+			
 				let count = 0
 				if (this.item.sampleList.length > 0) {
 					this.item.sampleList.forEach(f => {
@@ -334,6 +335,7 @@
 				if (count > 0) {
 					this.$set(this.item, 'reuseNum', count)
 					this.$emit('showReuseTurnover', true)
+					
 					this.$forceUpdate()
 
 				}

+ 1 - 1
pages/pda/sample/components/turnoverBom.vue

@@ -58,7 +58,7 @@
 
 							<view class="item ww20">
 							<input class="uni-input content_num" 
-								v-model="it.sampleNum" type="digit"   @blur="Number(it.sampleNum) > Number(it.quantity) ? it.sampleNum = Number(it.quantity) : ''"></input>
+								v-model="it.sampleNum" type="digit"  :disabled="it.quantity <= 0"  @blur="Number(it.sampleNum) > Number(it.quantity) ? it.sampleNum = Number(it.quantity) : ''"></input>
 							</view>
 						</view>
 					</u-list>