achao před 3 roky
rodič
revize
dfaa7452d4
1 změnil soubory, kde provedl 145 přidání a 138 odebrání
  1. 145 138
      src/views/outboundManagement/weighingManagementNew.vue

+ 145 - 138
src/views/outboundManagement/weighingManagementNew.vue

@@ -288,6 +288,9 @@
         <el-button type="primary" @click="printBig">打印单据</el-button>
       </div>
     </el-dialog>
+      <BalanceAlert v-if="isShowBalance" ref="weightChild" :deptBudgetList="weighingList" :information="information"
+          v-on:balanceListen="setVal" class="zujian">
+        </BalanceAlert>
   </div>
 </template>
 <script>
@@ -672,6 +675,10 @@
           this.weighingList.tare = data
         }
       },
+      openPort() {
+        this.$refs.weightChild.openPort()
+      },
+
       listclick(row) {
         this.id = row.id
         getweighing({
@@ -1270,144 +1277,144 @@
           },
         }
       },
-      async openPort() {
-        console.log('openPort', navigator)
-        if ('serial' in navigator) {
-          //   if (!this.$store.state.app.reader) {
-          // The Web Serial API is supported.
-          console.log('the Web Serial API is supported.')
-          console.log(this.param)
-          const port = await navigator.serial.requestPort()
-          await port.open({
-            baudRate: this.param,
-          }) // set baud rate
-          this.reader = port.readable.getReader()
-          console.log('beforeReader', port)
-          console.log('beforeReader', this.reader)
-          this.$store.dispatch('app/setReader', this.reader)
-          //   } else {
-          //     console.log('afterport', this.$store.state.app.reader)
-          //     this.reader = this.$store.state.app.reader
-          //   }
-          // 监听来自串行设备的数据
-          while (true) {
-            const {
-              value,
-              done
-            } = await this.reader.read()
-            // console.log("value",value);
-            if (done) {
-              // 允许稍后关闭串口。
-              this.reader.releaseLock()
-              break
-            }
-            var result = ''
-            //2。获取16进制字符串
-            // 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(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 == '山东诸城迈饶库' ||
-                  this.warehouseName == '克东千红库')) ||
-              this.warehouseName == '鲅鱼圈祥腾库' ||
-              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 (this.tpyeNo != 2) {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = parseInt(result)
-                }
-              } else {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = parseInt(result)
-                }
-              }
-            } else if (
-              this.warehouseName &&
-              (this.warehouseName == '顺诚粮库' ||
-                this.warehouseName == '鲅鱼圈金信库')
-            ) {
-              for (var i = value.length - 1; i >= 0; i--) {
-                var tmp = String.fromCharCode(value[i])
-                console.log(tmp)
-                if (String.fromCharCode(value[0]) == '.') {
-                  flag = true
-                }
-                if (flag && result.length < 9 && tmp != '=' && tmp != '.') {
-                  result += tmp
-                }
-              }
-              if (this.tpyeNo != 2) {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = parseInt(result)
-                }
-              } else {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = 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 (this.tpyeNo != 2) {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = parseInt(result) * 100
-                }
-              } else {
-                if (parseInt(result) || parseInt(result) == 0) {
-                  this.weighingList.weight = parseInt(result) * 100
-                }
-              }
-            }
-            // setTimeout(1000)
-            // value 是一个 Uint8Array
-          }
-          await port.close()
-        } else {
-          console.log('the Web Serial API is not supported.', navigator)
-        }
-      },
+      // async openPort() {
+        // console.log('openPort', navigator)
+        // if ('serial' in navigator) {
+        //   //   if (!this.$store.state.app.reader) {
+        //   // The Web Serial API is supported.
+        //   console.log('the Web Serial API is supported.')
+        //   console.log(this.param)
+        //   const port = await navigator.serial.requestPort()
+        //   await port.open({
+        //     baudRate: this.param,
+        //   }) // set baud rate
+        //   this.reader = port.readable.getReader()
+        //   console.log('beforeReader', port)
+        //   console.log('beforeReader', this.reader)
+        //   this.$store.dispatch('app/setReader', this.reader)
+        //   //   } else {
+        //   //     console.log('afterport', this.$store.state.app.reader)
+        //   //     this.reader = this.$store.state.app.reader
+        //   //   }
+        //   // 监听来自串行设备的数据
+        //   while (true) {
+        //     const {
+        //       value,
+        //       done
+        //     } = await this.reader.read()
+        //     // console.log("value",value);
+        //     if (done) {
+        //       // 允许稍后关闭串口。
+        //       this.reader.releaseLock()
+        //       break
+        //     }
+        //     var result = ''
+        //     //2。获取16进制字符串
+        //     // 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(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 == '山东诸城迈饶库' ||
+        //           this.warehouseName == '克东千红库')) ||
+        //       this.warehouseName == '鲅鱼圈祥腾库' ||
+        //       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 (this.tpyeNo != 2) {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = parseInt(result)
+        //         }
+        //       } else {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = parseInt(result)
+        //         }
+        //       }
+        //     } else if (
+        //       this.warehouseName &&
+        //       (this.warehouseName == '顺诚粮库' ||
+        //         this.warehouseName == '鲅鱼圈金信库')
+        //     ) {
+        //       for (var i = value.length - 1; i >= 0; i--) {
+        //         var tmp = String.fromCharCode(value[i])
+        //         console.log(tmp)
+        //         if (String.fromCharCode(value[0]) == '.') {
+        //           flag = true
+        //         }
+        //         if (flag && result.length < 9 && tmp != '=' && tmp != '.') {
+        //           result += tmp
+        //         }
+        //       }
+        //       if (this.tpyeNo != 2) {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = parseInt(result)
+        //         }
+        //       } else {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = 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 (this.tpyeNo != 2) {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = parseInt(result) * 100
+        //         }
+        //       } else {
+        //         if (parseInt(result) || parseInt(result) == 0) {
+        //           this.weighingList.weight = parseInt(result) * 100
+        //         }
+        //       }
+        //     }
+        //     // setTimeout(1000)
+        //     // value 是一个 Uint8Array
+        //   }
+        //   await port.close()
+        // } else {
+        //   console.log('the Web Serial API is not supported.', navigator)
+        // }
+      // },
       find() {
         this.getList()
       },