ccjgmwz 3 năm trước cách đây
mục cha
commit
6fab5deb00
1 tập tin đã thay đổi với 16 bổ sung23 xóa
  1. 16 23
      src/components/balanceAlert.vue

+ 16 - 23
src/components/balanceAlert.vue

@@ -5,7 +5,7 @@
     <div class="title" v-else>皮重</div>
     <div class="number" v-if="information.indexOf('毛重') > -1">{{grossWeightVal}} kg</div>
     <div class="number" v-else>{{tareVal}} KG</div>
-
+    
     <div class="btn" @click="sendVal">确定</div>
   </div>
 </template>
@@ -14,34 +14,28 @@
 
 export default {
   name: 'balanceAlert',
-  props: ['deptBudgetList1', 'information'],
+  props: ['deptBudgetList', 'information'],
   data () {
     return {
      param: 9600,
      grossWeightVal:'',
-     tareVal:'',
-     deptBudgetList:this.deptBudgetList1
+     tareVal:''
     }
   },
   activated(){
-
+   
   },
-  mounted(){debugger
+  mounted(){
  console.log('11111111111111111111111111111111111')
-    console.log(this.deptBudgetList1)
+    console.log(this.deptBudgetList)
     this.openPort()
   },
   computed: {
-
+    
   },
   created () {
-
+    
   },
-   watch: {
-      deptBudgetList1: function (deptBudgetList1) {debugger
-        this.deptBudgetList = deptBudgetList1
-      }
-    },
   methods: {
     sendVal(){
       console.log(this.grossWeightVal)
@@ -51,7 +45,7 @@ export default {
       }else{
         this.$emit('balanceListen',this.tareVal)
       }
-
+      
     },
    async closePort() {
       console.log('closePort')
@@ -78,7 +72,7 @@ export default {
           }
         // 监听来自串行设备的数据
         while (true) {
-
+          
           const { value, done } = await this.reader.read()
           // console.log("value",value);
           if (done) {
@@ -111,7 +105,6 @@ export default {
           //   }
           // }
           console.log('value:', value)
-          debugger
           if (
             this.deptBudgetList.warehouseName &&
             (this.deptBudgetList.warehouseName == '山东诸城迈饶库' ||
@@ -120,7 +113,7 @@ export default {
               this.deptBudgetList.warehouseName == '哈尔滨依兰库'||
               this.deptBudgetList.warehouseName == '龙江金信库')
           ) {
-
+            
             for (var i = 0; i < value.length; i++) {
               var tmp = String.fromCharCode(value[i])
               if (tmp == '+') {
@@ -167,7 +160,7 @@ export default {
             if(value.length > 10){
                for (var i = 0; i < value.length; i++) {
                   var tmp = String.fromCharCode(value[i])
-
+                  
                   // if (value[0] != 49 && value[0] != 2) {
                   //   // if (
                   //   //   value[value.length - 1] == 48 &&
@@ -193,19 +186,19 @@ export default {
                   if (
                     flag &&
                     result.length < 7 &&
-                    tmp != String.fromCharCode(32)
+                    tmp != String.fromCharCode(32) 
                     // &&
                     // !(
                     //   value[value.length - 1] == 48 && value[value.length - 2] == 48
                     // )
                   ) {
-                    if(i > 0&& value[i] == 48&& value[i-1] == 32){
+                    if(i > 0&& value[i] == 48&& value[i-1] == 32 && result){
                       break
                     }
                     else{
                       result += tmp
                     }
-
+                    
                   }
                   // if (flag1 && tmp != String.fromCharCode(32)) {
                   //   // if (
@@ -222,7 +215,7 @@ export default {
                   // }
                 }
             }
-
+            
             if (this.information.indexOf('毛重') > -1) {
               if (parseInt(result) || parseInt(result) == 0) {
                 this.grossWeightVal = parseInt(