Sfoglia il codice sorgente

报工重量统计解决

longfenglin 1 anno fa
parent
commit
01f2699ad4

+ 83 - 6
pages/pda/jobBooking/components/jobBom.vue

@@ -50,7 +50,7 @@
 					<view class="rx ww55 ">
 						<view class="lable lable150 rx-cc ">合格品数量</view>
 						<view class="content content_num">
-							<input class="uni-input" v-model="item.workReportInfo.formedNum" :disabled="isDetails"
+							<input class="uni-input" v-model="formedNum" :disabled="isDetails"
 								@input="blurNum(item.workReportInfo)" type="digit"></input>
 							<view class="unit">{{ item.unit }}</view>
 						</view>
@@ -60,7 +60,7 @@
 						<view class="lable rx-cc ww80">重量</view>
 						<view class="content content_num">
 							<input class="uni-input" v-model="formedWeight" type="digit"
-								:disabled="isDetails"></input>
+								:disabled="isDetails" @input="blurWeight()"></input>
 							<view class="unit">{{ item.weightUnit }}</view>
 						</view>
 					</view>
@@ -80,9 +80,9 @@
 							v-if="isDetails"
 								@input="changeNum"></input>
 								
-							<input class="uni-input" v-model="not.notFormedNum" type="number" 
+							<input class="uni-input" v-model="notFormedNum" type="number" 
 							v-else
-								@input="changeNum(not)"></input>	
+								@input="blurNum2(item.workReportInfo)"></input>	
 							<view class="unit">{{ item.unit }}</view>
 						</view>
 					</view>
@@ -92,8 +92,8 @@
 						<view class="content content_num">
 							<input class="uni-input" v-model="item.workReportInfo.notFormedWeight" type="digit"
 								:disabled="isDetails" v-if="isDetails"></input>
-							<input class="uni-input" v-model="not.notFormedWeight" type="digit"
-								:disabled="isDetails" v-else></input>	
+							<input class="uni-input" v-model="notFormedWeight" type="digit"
+								:disabled="isDetails" v-else @input="blurWeight2()"></input>	
 							<view class="unit">{{ item.weightUnit }}</view>
 
 							<!-- <view class="penalize" v-if='!isDetails'
@@ -179,7 +179,10 @@ export default {
 			notFormedList: [],
 			clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo")
 				.clientEnvironmentId, // *1 主环境-601环境   2 soll-索尔环境    3 tg-碳谷环境
+			formedNum:'',
 			formedWeight:'',
+			notFormedNum:'',
+			notFormedWeight:'',
 		}
 	},
 	created() {
@@ -204,6 +207,13 @@ export default {
 				this.formedWeight=formedWeight
 				this.$forceUpdate()
 		},
+		formedTotal(formedNumCount,formedWeightCount,notFormedNumCount,notFormedWeightCount){
+			this.formedNum=formedNumCount
+			this.formedWeight=formedWeightCount
+			this.notFormedNum=notFormedNumCount,
+			this.notFormedWeight=notFormedWeightCount,
+			this.$forceUpdate()
+		},
 		batchNoNew(e){
 
 			this.item.workReportInfo.batchNo = this.item.batchNo+e.target.value;
@@ -243,6 +253,7 @@ export default {
 		},
 
 		blurNum(value) {
+			this.$set(this.item.workReportInfo, 'formedNum', this.formedNum)
 			let total = 0;
 			//匹配非数字
 			let val=value.formedNum;
@@ -268,6 +279,8 @@ export default {
 				if (value.formedNum > this.item.formingNum) {
 					this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
 					this.$set(this.notFormedList[0], 'notFormedNum', 0)
+					this.formedNum=0
+					this.$forceUpdate()
 					this.notForme()
 					return uni.showToast({
 						icon: 'none',
@@ -281,6 +294,8 @@ export default {
 						console.log(this.item.product[0].feedQuantity);
 						this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
 						this.$set(this.notFormedList[0], 'notFormedNum', 0)
+						this.formedNum=0
+						this.$forceUpdate()
 						this.notForme()
 						return uni.showToast({
 							icon: 'none',
@@ -322,6 +337,68 @@ export default {
 			this.$forceUpdate()
 
 		},
+		blurNum2(value) {
+			this.$set(this.item.workReportInfo, 'notFormedNum', this.notFormedNum)
+			
+			let total = 0;
+			//匹配非数字
+			let val=value.notFormedNum;
+			let reg = new RegExp("([^0-9]*)","g");
+			let ma = val.match(reg);
+			//如果有非数字,替换成""
+			if(ma.length>0){
+				for(let k in ma){
+					if(ma[k]!=""){
+						val = val.replace(ma[k],0);
+					}
+				}
+			}
+			//可以为0,但不能以0开头
+			if(val.startsWith("0")&&val.length>1){
+				val = val.substring(1,val.length);
+			}
+			value.notFormedNum=val;
+			
+			if (this.item.currentTaskDiagram.isFirstTask) {
+			
+				// formingNum 生产数量  feedQuantity   this.item.product[0] //投料数量
+				if (value.notFormedNum > this.item.formingNum) {
+					this.$set(this.item.workReportInfo, 'workReportInfo', this.item.formingNum)
+					this.$set(this.notFormedList[0], 'notFormedNum', 0)
+					this.notFormedNum=0
+					this.$forceUpdate()
+					this.notForme()
+					return uni.showToast({
+						icon: 'none',
+						title: '不合格品数量不能大于要求生产数量'
+					})
+				}
+			} else {
+				if (this.item.product.length) {
+			
+					if (value.formedNum > this.item.product[0].feedQuantity) {
+						console.log(this.item.product[0].feedQuantity);
+						this.$set(this.item.workReportInfo, 'workReportInfo', this.item.product[0].feedQuantity)
+						this.$set(this.notFormedList[0], 'notFormedNum', 0)
+						this.notFormedNum=0
+						this.$forceUpdate()
+						this.notForme()
+						return uni.showToast({
+							icon: 'none',
+							title: '合格品数量不能大于投料数量'
+						})
+					}
+					
+				}
+			}
+		},
+		blurWeight(){
+			this.$set(this.item.workReportInfo, 'formedWeight', this.formedWeight)
+		},
+			
+		blurWeight2(){
+			this.$set(this.item.workReportInfo, 'notFormedWeight', this.notFormedWeight)
+		},
 
 		notForme() {
 

+ 33 - 22
pages/pda/jobBooking/components/semiProductJobBomPL.vue

@@ -143,11 +143,11 @@
 						<view class="item ww15 content_num">
 							<view v-if='isDetails'>{{yy.allFeedQuantity }}</view>
 							<input class="uni-input" v-else v-model="yy.allFeedQuantity"
-								@input="blurNum($event,idx, yyIdx)" type='number'></input>
+								@input="blurNum($event,idx, yyIdx)" type='number' v-show="keyYes"></input>
 						</view>
 						<view class="item ww25 content_num">
 							<view v-if='isDetails'>{{yy.allReportWeight }}</view>
-							<input class="uni-input" v-else v-model="yy.allReportWeight" type='digit'></input>
+							<input class="uni-input" v-else v-model="yy.allReportWeight" type='digit' @input="blurWeight(it, idx, yyIdx)"></input>
 						</view>
 						<view class="item ww20 content_num">
 							<view v-if='isDetails'>{{yy.deviceName }}</view>
@@ -221,13 +221,13 @@
 						<view class="item ww10 content_num">
 							<view v-if='isDetails'>{{yy.allFeedQuantity }}</view>
 							<input class="uni-input" v-else v-model="yy.allFeedQuantity"
-								@input="blurNum2($event,idx, yyIdx)" type='number'></input>
+								@input="blurNum2($event,idx, yyIdx)" type='number' v-show="keyNo"></input>
 						</view>
 						
 						<view class="item ww10 content_num">
 							<view v-if='isDetails'>{{yy.allReportWeight }}</view>
 							<input class="uni-input" v-else v-model="yy.allReportWeight"
-								 type='number'></input>
+								 type='number' @input="blurWeight2(it, idx, yyIdx)" ></input>
 						</view>
 						
 						<view class="item ww15 content_num">
@@ -371,8 +371,9 @@
 						code: "5",
 						name: '让步接收'
 					}
-				]
-
+				],
+				keyNo:'1',
+				keyYes:'1'
 
 
 
@@ -484,28 +485,34 @@
 					count2 = count2 + Number(m.allFeedQuantity || 0)
 				})
 				
-
+                this.keyYes=false;
 				if (Number(count + count2) > this.list[idx].feedQuantity) {
-
 					this.$set(this.list[idx].extInfo.batchReportInfo[yyIdx], 'allFeedQuantity', 0)
 					this.$forceUpdate()
-
+					this.keyYes=true;
 					uni.showToast({
 						title: `投料数不能大于投料数量`,
 						icon: 'none'
 					})
-
-
+				   this.$emit('countNumPl',this.list,idx)
+				}else{
+					this.keyYes=true;
+					this.$emit('countNumPl',this.list,idx)
 				}
-
 			},
+			blurWeight(it, idx, yyIdx) {
+				this.$emit('countNumPl',this.list,idx)
+			  },
+			  blurWeight2(it, idx, yyIdx) {
+				  this.$emit('countNumPl',this.list,idx)
+				},
 			
 			
 			blurNum2(event, idx, yyIdx) {
 			
-				let value = event.target.value;
-				value = value.replace(/\./g, '');
-				this.$set(this.list[idx].extInfo.notBatchReportInfo[yyIdx], 'allFeedQuantity', value);
+				// let value = event.target.value;
+				// value = value.replace(/\./g, '');
+				// this.$set(this.list[idx].extInfo.notBatchReportInfo[yyIdx], 'allFeedQuantity', value);
 			
 				let count = 0
 				this.list[idx].extInfo.batchReportInfo.forEach(m => {
@@ -517,20 +524,24 @@
 					count2 = count2 + Number(m.allFeedQuantity || 0)
 				})
 				
-			
+			    this.keyNo=false;
 				if (Number(count + count2) > this.list[idx].feedQuantity) {
-			
-					this.$set(this.list[idx].extInfo.notBatchReportInfo[yyIdx], 'allFeedQuantity', 0)
-					this.$forceUpdate()
+				   this.$set(this.list[idx].extInfo.notBatchReportInfo[yyIdx], 'allFeedQuantity', 0)
+			       this.$nextTick(()=>{
+					   // this.$set(this.list[idx].extInfo.notBatchReportInfo[yyIdx], 'allFeedQuantity', 0)
+				   })
+				   this.keyNo=true;
+				    this.$forceUpdate()
 			
 					uni.showToast({
 						title: `投料数不能大于投料数量`,
 						icon: 'none'
 					})
-			
-			
+					this.$emit('countNumPl',this.list,idx)
+				}else{
+					this.keyNo=true;
+					this.$emit('countNumPl',this.list,idx)
 				}
-			
 			},
 
 

+ 49 - 15
pages/pda/jobBooking/index/index.vue

@@ -62,7 +62,7 @@
 
 					<semiProductJobBomPL
 						v-if='objData.semiProductList && objData.semiProductList.length != 0 && taskType != 4 && taskType != 6 && objData.singleReport == 0'
-						:item='objData' :list='objData.semiProductList' :equipmentList="objData.equipmentList">
+						:item='objData' :list='objData.semiProductList' :equipmentList="objData.equipmentList" @countNumPl='countNumPl'>
 					</semiProductJobBomPL>
 
 					<oneJobQualityBom
@@ -726,11 +726,10 @@ export default {
 
 
 		async save(type) {
-			console.log(type, 'type');
 
 			// 验证判断条件
 			this.$isJobExls(1, this.objData);
-
+			
 			if (!(this.clientEnvironmentId == 3 || this.objData.singleReport !== 1)) {
 
 				if (this.objData.semiProductList.length) {
@@ -811,7 +810,6 @@ export default {
 
 
 
-
 			if (this.objData.productRecycleList.length > 0 && this.clientEnvironmentId != 2) {
 				const isRecycle = await this.checkRecycle()
 				if (!isRecycle) {
@@ -823,7 +821,6 @@ export default {
 
 
 
-
 			if (this.taskType == 4 && this.clientEnvironmentId != 3 && this.clientEnvironmentId != 2 &&this.objData.singleReport !== 1) {
 				const isPack = await this.checkPack()
 
@@ -834,17 +831,15 @@ export default {
 
 
 
-
 			//
 			// console.log(this.objData.currentTaskDiagram.isFirstTask,'22222');
-			if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask  1是  判断是否首工序
-
-				const isFirstTask = await this.checkFirstTask()
-				if (!isFirstTask) {
-					return false
-				}
-			}
+			// if (this.objData.currentTaskDiagram.isFirstTask == 0) { // isFirstTask  1是  判断是否首工序
 
+			// 	const isFirstTask = await this.checkFirstTask()
+			// 	if (!isFirstTask) {
+			// 		return false
+			// 	}
+			// }
 
 			if (this.taskType == 1) {
 
@@ -885,6 +880,9 @@ export default {
 			
 			if(this.objData.semiProductList.length>0){
 				this.objData.semiProductList.map((ditem)=>{
+					let wdid=ditem.deviceId?ditem.deviceId.split('/'):''
+					ditem.deviceId=wdid?wdid[0]:''
+					
 					if(ditem.extInfo.batchReportInfo){
 					  ditem.extInfo.batchReportInfo.map((baItem)=>{
 						 let idvalue=baItem.deviceId?baItem.deviceId.split('/'):''
@@ -900,7 +898,7 @@ export default {
 					}
 				})
 			}
-			
+			console.log(this.objData,'this.objData')
 			jobSave(this.objData).then(res => {
 
 
@@ -1099,7 +1097,43 @@ export default {
 
 			})
 		},
-		
+		//批量报工合格不合格重量统计
+		countNumPl(list,index){
+		  console.log('11111122222333',list)
+		  //合格总数
+		  let formedNumCount=0
+		  //合格总重量
+		  let formedWeightCount=0
+		  //不合格总数
+		  let notFormedNumCount=0
+		  //不合格总重量
+		  let notFormedWeightCount=0
+		  list.map((item=>{
+			//合格总数
+			item.extInfo.batchReportInfo.forEach((m) => {
+			  formedNumCount = formedNumCount + Number(m.allFeedQuantity || 0);
+			});
+			//合格总重量
+			item.extInfo.batchReportInfo.forEach((w) => {
+			  formedWeightCount = formedWeightCount + Number(w.allReportWeight || 0);
+			});
+			//不合格总数
+			item.extInfo.notBatchReportInfo.forEach((nf) => {
+			  notFormedNumCount = notFormedNumCount + Number(nf.allFeedQuantity || 0);
+			});
+			//不合格总重量
+			item.extInfo.notBatchReportInfo.forEach((nw) => {
+			  notFormedWeightCount = notFormedWeightCount + Number(nw.allReportWeight || 0);
+			});
+		  }))
+		  this.$set(this.objData.workReportInfo,'formedNum',formedNumCount);//合格总数
+		  this.$set(this.objData.workReportInfo,'formedWeight',formedWeightCount);//合格总重量
+		  this.$set(this.objData.workReportInfo,'notFormedNum',notFormedNumCount);//不合格总数
+		  this.$set(this.objData.workReportInfo,'notFormedWeight',notFormedWeightCount);//不合格总重量
+		  this.$refs.jobReftg.formedTotal(formedNumCount,formedWeightCount,notFormedNumCount,notFormedWeightCount)
+		  this.$forceUpdate()
+		}
+		  
 
 
 	},