ccjgmwz vor 3 Jahren
Ursprung
Commit
b4ba085c26

+ 22 - 6
src/views/home/index.vue

@@ -118,7 +118,7 @@ export default {
       },
       vesselBankFlag: sessionStorage.getItem('ws-pf_vesselBankFlag'),
       shezhiVal: '',
-      text:"数据",
+      text:'数据',
       reader:null,
       param:9600
     }
@@ -554,28 +554,44 @@ export default {
         // 监听来自串行设备的数据
         while (true) {
           const { value, done } = await this.reader.read();
-          // console.log("value",value);
           if (done) {
             // 允许稍后关闭串口。
             this.reader.releaseLock();
             break;
           }
-          var result="";
+          console.log('value:',value);
+
+          var result='';
           //2。获取16进制字符串
           // var receData = HexConvert.ByteToString(value);
           // console.log("receData",receData);
           var flag = false;
           for(var i=0;i<value.length;i++){
+              console.log('value[0]',value[0])
             var tmp = String.fromCharCode(value[i])
-            if(tmp == "+"){
+            if(value[0] != 49 && value[0] != 2){
+              break
+            }
+            if (tmp == String.fromCharCode(32) ) {
               flag = true
             }
-            if(flag && result.length <7){
+            if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+              // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+              //   continue
+              // }
+              // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+              //   continue
+              // }
               result += tmp
             }
           }
-          this.text = parseInt(result)
           setTimeout(1000)
+          if(parseInt(result)){
+            console.log('result:',result);
+            this.text = parseInt(result)*100
+          }
+          console.log('this.text:',this.text);
+          
           // value 是一个 Uint8Array
         }
          await port.close();

+ 1 - 0
src/views/houseSelfCollect/weighingManagement.vue

@@ -188,6 +188,7 @@
 						monitorUrl2: this.monitorUrl2,
 						allowEdit: this.allowEdit,
 						cangid: this.cangid,
+						warehouseName:this.warehouseName,
 						paramType: row.qualityInspectionManagement.paramType
 					},
 				})

+ 48 - 13
src/views/houseSelfCollect/weightCheck.vue

@@ -216,7 +216,8 @@
         monitorUrl1: '',
         monitorUrl2: '',
         cangid:'',
-        paramType:'1'
+        paramType:'1',
+        warehouseName:''
       }
     },
     activated() {
@@ -225,6 +226,7 @@
       this.paramType = this.$route.query.paramType
       this.getList()
       this.tpyeNo = this.$route.query.tpyeNo
+      this.warehouseName = this.$route.query.warehouseName
       this.weighingList.number = this.$route.query.number
       this.weighingList.binNumber = this.$route.query.binNumber
       this.weighingList.customer = this.$route.query.customer
@@ -405,6 +407,7 @@
             baudRate: this.param
           }); // set baud rate
           this.reader = port.readable.getReader();
+          
           // 监听来自串行设备的数据
           while (true) {
             const {
@@ -422,24 +425,56 @@
             // var receData = HexConvert.ByteToString(value);
             // console.log("receData",receData);
             var flag = false;
-            for (var i = 0; i < value.length; i++) {
-              var tmp = String.fromCharCode(value[i])
-              if (tmp == '+') {
-                flag = true
+            if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+              for (var i = 0; i < value.length; i++) {
+                var tmp = String.fromCharCode(value[i])
+                if (tmp == '+') {
+                  flag = true
+                }
+                if (flag && result.length < 6 && tmp != '+') {
+                  result += tmp
+                }
               }
-              if (flag && result.length < 6 && tmp != '+') {
-                result += tmp
+              if (this.tpyeNo != 2) {
+                if(parseInt(result)|| parseInt(result) == 0){
+                  this.weighingList.grossWeight = parseInt(result)
+                }
+              } else {
+                if(parseInt(result)|| parseInt(result) == 0){
+                  this.weighingList.tare = parseInt(result)
+                }
               }
             }
-            if (this.tpyeNo != 2) {
-              if(parseInt(result)){
-                this.weighingList.grossWeight = parseInt(result)
+            else{
+              for(var i=0;i<value.length;i++){
+                var tmp = String.fromCharCode(value[i])
+                if(value[0] != 49 && value[0] != 2){
+                  break
+                }
+                if (tmp == String.fromCharCode(32) ) {
+                  flag = true
+                }
+                if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+                  // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+                  //   continue
+                  // }
+                  // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+                  //   continue
+                  // }
+                  result += tmp
+                }
               }
-            } else {
-              if(parseInt(result)){
-                this.weighingList.tare = parseInt(result)
+              if (this.tpyeNo != 2) {
+                if(parseInt(result)|| parseInt(result) == 0){
+                  this.weighingList.grossWeight = parseInt(result)*100
+                }
+              } else {
+                if(parseInt(result)|| parseInt(result) == 0){
+                  this.weighingList.tare = parseInt(result)*100
+                }
               }
             }
+            
             setTimeout(1000)
             // value 是一个 Uint8Array
           }

+ 59 - 10
src/views/outboundManagement/weighing.vue

@@ -198,20 +198,69 @@
 				// var receData = HexConvert.ByteToString(value);
 				// console.log("receData",receData);
 				var flag = false;
-				for(var i=0;i<value.length;i++){
-					var tmp = String.fromCharCode(value[i])
-					if(tmp == '+'){
-					flag = true
+				// for(var i=0;i<value.length;i++){
+				// 	var tmp = String.fromCharCode(value[i])
+				// 	if(tmp == '+'){
+				// 	flag = true
+				// 	}
+				// 	if(flag && result.length <6 && tmp != '+'){
+				// 	result += tmp
+				// 	}
+				// }
+				// if(this.tpyeNo != 2){
+				// 	this.weighingList.grossWeight = parseInt(result)
+				// }
+				// else{
+				// 	this.weighingList.tare = parseInt(result) 
+				// }
+				if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+					for (var i = 0; i < value.length; i++) {
+						var tmp = String.fromCharCode(value[i])
+						if (tmp == '+') {
+						flag = true
+						}
+						if (flag && result.length < 6 && tmp != '+') {
+						result += tmp
+						}
 					}
-					if(flag && result.length <6 && tmp != '+'){
-					result += tmp
+					if (this.tpyeNo != 2) {
+						if(parseInt(result)|| parseInt(result) == 0){
+							this.weighingList.grossWeight = parseInt(result)
+						}
+					} else {
+						if(parseInt(result)|| parseInt(result) == 0){
+							this.weighingList.tare = parseInt(result)
+						}
 					}
 				}
-				if(this.tpyeNo != 2){
-					this.weighingList.grossWeight = parseInt(result)
-				}
 				else{
-					this.weighingList.tare = parseInt(result) 
+					for(var i=0;i<value.length;i++){
+						var tmp = String.fromCharCode(value[i])
+						if(value[0] != 49 && value[0] != 2){
+						break
+						}
+						if (tmp == String.fromCharCode(32) ) {
+						flag = true
+						}
+						if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+						// if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+						// 	continue
+						// }
+						// if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+						// 	continue
+						// }
+						result += tmp
+						}
+					}
+					if (this.tpyeNo != 2) {
+						if(parseInt(result)|| parseInt(result) == 0){
+						this.weighingList.grossWeight = parseInt(result)*100
+						}
+					} else {
+						if(parseInt(result)|| parseInt(result) == 0){
+						this.weighingList.tare = parseInt(result)*100
+						}
+					}
 				}
 				setTimeout(1000)
 				// value 是一个 Uint8Array

+ 63 - 11
src/views/warehouse/warehouseManagementGross.vue

@@ -642,6 +642,7 @@ export default {
       },
       accessoryTFs: false,
       allowEdit: true,
+      param: 9600,
       information:''
     }
   },
@@ -712,22 +713,73 @@ export default {
           // var receData = HexConvert.ByteToString(value);
           // console.log("receData",receData);
           var flag = false;
-          for (var i = 0; i < value.length; i++) {
-            var tmp = String.fromCharCode(value[i])
-            if (tmp == '+') {
+          // for (var i = 0; i < value.length; i++) {
+          //   var tmp = String.fromCharCode(value[i])
+          //   if (tmp == '+') {
+          //     flag = true
+          //   }
+          //   if (flag && result.length < 6 && tmp != '+') {
+          //     result += tmp
+          //   }
+          // }
+          // if (this.information != '毛重检斤') {
+          //   if(parseInt(result)){
+          //     this.deptBudgetList.grossWeight = parseInt(result)
+          //   }
+          // } else {
+          //   if(parseInt(result)){
+          //     this.deptBudgetList.tare = parseInt(result)
+          //   }
+          // }
+          console.log('value:',value);
+
+          if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+            for (var i = 0; i < value.length; i++) {
+              var tmp = String.fromCharCode(value[i])
+              if (tmp == '+') {
               flag = true
-            }
-            if (flag && result.length < 6 && tmp != '+') {
+              }
+              if (flag && result.length < 6 && tmp != '+') {
               result += tmp
+              }
+            }
+            if (this.information != '毛重检斤') {
+              if(parseInt(result)|| parseInt(result) == 0){
+                this.deptBudgetList.grossWeight = parseInt(result)
+              }
+            } else {
+              if(parseInt(result)|| parseInt(result) == 0){
+                this.deptBudgetList.tare = parseInt(result)
+              }
             }
           }
-          if (this.information != '毛重检斤') {
-            if(parseInt(result)){
-              this.deptBudgetList.grossWeight = parseInt(result)
+          else{
+            for(var i=0;i<value.length;i++){
+              var tmp = String.fromCharCode(value[i])
+              if(value[0] != 49 && value[0] != 2){
+              break
+              }
+              if (tmp == String.fromCharCode(32) ) {
+              flag = true
+              }
+              if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+              // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+              //   continue
+              // }
+              // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+              //   continue
+              // }
+              result += tmp
+              }
             }
-          } else {
-            if(parseInt(result)){
-              this.deptBudgetList.tare = parseInt(result)
+            if (this.information != '毛重检斤') {
+              if(parseInt(result)|| parseInt(result) == 0){
+              this.deptBudgetList.grossWeight = parseInt(result)*100
+              }
+            } else {
+              if(parseInt(result)|| parseInt(result) == 0){
+              this.deptBudgetList.tare = parseInt(result)*100
+              }
             }
           }
           setTimeout(1000)

+ 45 - 7
src/views/warehouse/warehouseManagementNoWeightIn.vue

@@ -575,6 +575,7 @@ export default {
         },
       },
       accessoryTFs: false,
+      param: 9600,
       allowEdit:true
     }
   },
@@ -663,17 +664,54 @@ export default {
           // var receData = HexConvert.ByteToString(value);
           // console.log("receData",receData);
           var flag = false;
-          for (var i = 0; i < value.length; i++) {
-            var tmp = String.fromCharCode(value[i])
-            if (tmp == '+') {
+          // for (var i = 0; i < value.length; i++) {
+          //   var tmp = String.fromCharCode(value[i])
+          //   if (tmp == '+') {
+          //     flag = true
+          //   }
+          //   if (flag && result.length < 6 && tmp != '+') {
+          //     result += tmp
+          //   }
+          // }
+          // if(parseInt(result)){
+          //     this.dataList.tare = parseInt(result)
+          // }
+          if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+            for (var i = 0; i < value.length; i++) {
+              var tmp = String.fromCharCode(value[i])
+              if (tmp == '+') {
               flag = true
-            }
-            if (flag && result.length < 6 && tmp != '+') {
+              }
+              if (flag && result.length < 6 && tmp != '+') {
               result += tmp
+              }
             }
-          }
-          if(parseInt(result)){
+            if(parseInt(result)|| parseInt(result) == 0){
               this.dataList.tare = parseInt(result)
+            }
+          }
+          else{
+            for(var i=0;i<value.length;i++){
+              var tmp = String.fromCharCode(value[i])
+              if(value[0] != 49 && value[0] != 2){
+              break
+              }
+              if (tmp == String.fromCharCode(32) ) {
+              flag = true
+              }
+              if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+              // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+              //   continue
+              // }
+              // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+              //   continue
+              // }
+              result += tmp
+              }
+            }
+            if(parseInt(result)|| parseInt(result) == 0){
+              this.dataList.tare = parseInt(result)*100
+            }
           }
           setTimeout(1000)
           // value 是一个 Uint8Array

+ 45 - 7
src/views/warehouse/warehouseManagementNoWeightOut.vue

@@ -485,6 +485,7 @@ export default {
         },
       },
       accessoryTFs: false,
+      param: 9600,
       allowEdit:true
     }
   },
@@ -555,17 +556,54 @@ export default {
           // var receData = HexConvert.ByteToString(value);
           // console.log("receData",receData);
           var flag = false;
-          for (var i = 0; i < value.length; i++) {
-            var tmp = String.fromCharCode(value[i])
-            if (tmp == '+') {
+          // for (var i = 0; i < value.length; i++) {
+          //   var tmp = String.fromCharCode(value[i])
+          //   if (tmp == '+') {
+          //     flag = true
+          //   }
+          //   if (flag && result.length < 6 && tmp != '+') {
+          //     result += tmp
+          //   }
+          // }
+          // if(parseInt(result)){
+          //     this.dataList.grossWeight = parseInt(result)
+          // }
+          if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+            for (var i = 0; i < value.length; i++) {
+              var tmp = String.fromCharCode(value[i])
+              if (tmp == '+') {
               flag = true
-            }
-            if (flag && result.length < 6 && tmp != '+') {
+              }
+              if (flag && result.length < 6 && tmp != '+') {
               result += tmp
+              }
             }
-          }
-          if(parseInt(result)){
+            if(parseInt(result)|| parseInt(result) == 0){
               this.dataList.grossWeight = parseInt(result)
+            }
+          }
+          else{
+            for(var i=0;i<value.length;i++){
+              var tmp = String.fromCharCode(value[i])
+              if(value[0] != 49 && value[0] != 2){
+              break
+              }
+              if (tmp == String.fromCharCode(32) ) {
+              flag = true
+              }
+              if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+              // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+              //   continue
+              // }
+              // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+              //   continue
+              // }
+              result += tmp
+              }
+            }
+            if(parseInt(result)|| parseInt(result) == 0){
+              this.dataList.grossWeight = parseInt(result)*100
+            }
           }
           setTimeout(1000)
           // value 是一个 Uint8Array

+ 61 - 11
src/views/warehouse/warehouseManagementTare.vue

@@ -460,6 +460,7 @@ export default {
       },
       accessoryTFs: false,
       allowEdit: true,
+      param: 9600,
       information:''
     }
   },
@@ -513,22 +514,71 @@ export default {
           // var receData = HexConvert.ByteToString(value);
           // console.log("receData",receData);
           var flag = false;
-          for (var i = 0; i < value.length; i++) {
-            var tmp = String.fromCharCode(value[i])
-            if (tmp == '+') {
+          // for (var i = 0; i < value.length; i++) {
+          //   var tmp = String.fromCharCode(value[i])
+          //   if (tmp == '+') {
+          //     flag = true
+          //   }
+          //   if (flag && result.length < 6 && tmp != '+') {
+          //     result += tmp
+          //   }
+          // }
+          // if (this.information != '毛重检斤') {
+          //   if(parseInt(result)){
+          //     this.deptBudgetList.grossWeight = parseInt(result)
+          //   }
+          // } else {
+          //   if(parseInt(result)){
+          //     this.deptBudgetList.tare = parseInt(result)
+          //   }
+          // }
+          if(this.warehouseName&&this.warehouseName == '山东诸城迈饶库'){
+            for (var i = 0; i < value.length; i++) {
+              var tmp = String.fromCharCode(value[i])
+              if (tmp == '+') {
               flag = true
-            }
-            if (flag && result.length < 6 && tmp != '+') {
+              }
+              if (flag && result.length < 6 && tmp != '+') {
               result += tmp
+              }
+            }
+            if (this.information != '毛重检斤') {
+              if(parseInt(result)|| parseInt(result) == 0){
+                this.deptBudgetList.grossWeight = parseInt(result)
+              }
+            } else {
+              if(parseInt(result)|| parseInt(result) == 0){
+                this.deptBudgetList.tare = parseInt(result)
+              }
             }
           }
-          if (this.information != '毛重检斤') {
-            if(parseInt(result)){
-              this.deptBudgetList.grossWeight = parseInt(result)
+          else{
+            for(var i=0;i<value.length;i++){
+              var tmp = String.fromCharCode(value[i])
+              if(value[0] != 49 && value[0] != 2){
+              break
+              }
+              if (tmp == String.fromCharCode(32) ) {
+              flag = true
+              }
+              if (flag && result.length < 7 && tmp != String.fromCharCode(32)) {
+              // if(i-1 >=0 &&tmp == String.fromCharCode(48) && value[i-1] == 32){
+              //   continue
+              // }
+              // if(i-2 >=0 &&tmp == String.fromCharCode(48) && value[i-2] == 32){
+              //   continue
+              // }
+              result += tmp
+              }
             }
-          } else {
-            if(parseInt(result)){
-              this.deptBudgetList.tare = parseInt(result)
+            if (this.information != '毛重检斤') {
+              if(parseInt(result) || parseInt(result) == 0){
+                this.deptBudgetList.grossWeight = parseInt(result)*100
+              }
+            } else {
+              if(parseInt(result)|| parseInt(result) == 0){
+                this.deptBudgetList.tare = parseInt(result)*100
+              }
             }
           }
           setTimeout(1000)