loulijun2021
2022-09-07 ef9633e0d1689fd8869170f3aa0af6c90c2e5e7f
src/views/scgl/sckbg.vue
@@ -7,13 +7,15 @@
            <div style="display: flex;align-items: center">
              <div style="width: 90px">扫描条码:</div>
              <!--              oninput="value=value.replace(/[^0-9a-zA-Z;_]/g,'')"-->
              <el-input
                id="keyWords"
                v-model="form.orderstepqrcode"
                name="produceCode"
                style="width: 300px"
                @keyup.native="e=>judgeIsScanning(e,'produceCode')"
                @keyup.enter.native="val=>enterNative(val,'produceCode')"
              />
            </div>
            <div v-if="false" style="display: flex;padding-right: 10px">
              <el-button @click="ZZstart">
@@ -39,19 +41,6 @@
              :cell-style="this.$cellStyle"
              @sort-change="sortChange"
            >
              <!--              <el-table-column-->
              <!--                width="50"-->
              <!--                fixed-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <el-radio-->
              <!--                    v-model="radioSelected"-->
              <!--                    :label="row.wo"-->
              <!--                    style="color: #fff;padding-left: 10px; margin-right: -25px;"-->
              <!--                    @change.native="getCurrentRow(row.wo)"-->
              <!--                  />-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <el-table-column
                prop="RowNum"
                width="50"
@@ -212,6 +201,7 @@
                v-model="WXform.orderstepqrcode"
                name="WXproduceCode"
                style="width: 300px"
                @keyup.native="e=>judgeIsScanning(e,'WXproduceCode')"
                @keyup.enter.native="val=>enterNative(val,'WXproduceCode')"
              />
            </div>
@@ -239,19 +229,6 @@
              :cell-style="this.$cellStyle"
              @sort-change="WXsortChange"
            >
              <!--              <el-table-column-->
              <!--                width="50"-->
              <!--                fixed-->
              <!--              >-->
              <!--                <template slot-scope="{row}">-->
              <!--                  <el-radio-->
              <!--                    v-model="radioSelected"-->
              <!--                    :label="row.wo_code"-->
              <!--                    style="color: #fff;padding-left: 10px; margin-right: -25px;"-->
              <!--                    @change.native="getWXCurrentRow(row.wo_code)"-->
              <!--                  />-->
              <!--                </template>-->
              <!--              </el-table-column>-->
              <el-table-column
                prop="RowNum"
                width="50"
@@ -399,6 +376,7 @@
                v-model="badForm.orderstepqrcode"
                name="badProduceCode"
                style="width: 300px"
                @keyup.native="e=>judgeIsScanning(e,'badProduceCode')"
                @keyup.enter.native="val=>enterNative(val,'badProduceCode')"
              />
            </div>
@@ -829,8 +807,8 @@
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="不良原因:"
          prop="badcode"
        >
          <!--          prop="badcode"-->
          <el-select
            v-model="dialogForm.badcode"
            style="width: 200px;"
@@ -1325,23 +1303,38 @@
        operation: getCookie('navTabId')
      },
      badTableDataDialog: [], // 不良对话框table表格
      OperationArr: [] // 人员数组
      OperationArr: [], // 人员数组
      sendButtonIsDisabled: false, // 下达按钮是否可点击
      judgeIsScanningArr: []// 判断是否扫码数组
    }
  },
  // computed: {
  //   qrLink: function() {
  //     return this.$store.getters.getPreviewUrl
  //   }
  // },
  // watch: {
  //   qrLink: function(newVal, oldNew) {
  //     if (newVal !== oldNew) {
  //       this.$nextTick(() => {
  //         this.bindQRCode(newVal)
  //       })
  //     }
  //   }
  // },
  watch: {
    // 'form.orderstepqrcode': {
    //   handler(newValue) {
    //     this.form.orderstepqrcode = newValue
    //
    //     // 在这里调用,并执行this.fnThrottle(this.search, 500, 2000)();
    //     this.fnThrottle(this.enterNative, 500, 2000, 'produceCode')()
    //   }
    // },
    // 'WXform.orderstepqrcode': {
    //   handler(newValue) {
    //     this.form.orderstepqrcode = newValue
    //
    //     // 在这里调用,并执行this.fnThrottle(this.search, 500, 2000)();
    //     this.fnThrottle(this.enterNative, 500, 2000, 'WXproduceCode')()
    //   }
    // },
    // 'badForm.orderstepqrcode': {
    //   handler(newValue) {
    //     this.form.orderstepqrcode = newValue
    //
    //     // 在这里调用,并执行this.fnThrottle(this.search, 500, 2000)();
    //     this.fnThrottle(this.enterNative, 500, 2000, 'badProduceCode')()
    //   }
    // }
  },
  created() {
    this.getMesOrderStepSearch()
    this.tabClick()
@@ -1360,6 +1353,7 @@
    this.getMesOrderSelectUserAll() // 获取所有人员
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
@@ -1447,9 +1441,53 @@
        })
      }
    },
    // 防抖      //扫码用的是防抖
    fnThrottle(method, delay, duration, belong) {
      var that = this
      var timer = this.timer
      var begin = new Date().getTime()
      return function() {
        var current = new Date().getTime()
        clearTimeout(timer)
        if (current - begin >= duration) {
          // method()
          // that.VALUE()
          begin = current
        } else {
          that.timer = setTimeout(function() {
            // method()
            if (belong === 'produceCode') {
              that.enterNative(that.form.orderstepqrcode, belong)
            }
            if (belong === 'WXproduceCode') {
              that.enterNative(that.WXform.orderstepqrcode, belong)
            }
            if (belong === 'badProduceCode') {
              that.enterNative(that.badForm.orderstepqrcode, belong)
            }
          }, delay)
        }
      }
    },
    // 判断是否是扫码枪扫码
    judgeIsScanning(e, belong) {
      const timenow = e.timeStamp
      let flag = true
      this.judgeIsScanningArr.push(timenow)
      let i
      for (i in this.judgeIsScanningArr) {
        flag = Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]) < 0.1
        if (i > 0 && this.judgeIsScanningArr.length === parseInt(i) + 1) {
          if (flag) {
            this.fnThrottle(this.enterNative, 500, 2000, belong)()
            return
          }
        }
      }
    },
    // 扫码键盘回车事件
    async enterNative(val, belong) {
      console.log(val, belong)
      console.log(val, belong, 89898989)
      // 开工:code="200"  count=0
      // 报工:code="200"  count=1
      // 发料:code="200"  count=2
@@ -1744,6 +1782,11 @@
    },
    // 对话框关闭事件
    handleClose() {
      this.judgeIsScanningArr = []
      this.form.orderstepqrcode = ''
      this.WXform.orderstepqrcode = ''
      this.badForm.orderstepqrcode = ''
      this.dialogForm.wo_code = '', // 工单编号
      this.dialogForm.partcode = '', // 产品编码
      this.dialogForm.partname = '', // 产品名称
@@ -1847,7 +1890,7 @@
              if (res.code === '200') {
                this.$message.success('收料成功!')
                if (this.dialogForm.nextstepcode !== '') {
                if (this.dialogForm.nextstepcode === '') {
                  this.WXprint2(this.OperationArr.find(item => item.usercode === this.dialogForm.operation).username)
                  this.dialogVisible2 = true
                }
@@ -1923,8 +1966,7 @@
              if (res.code === '200') {
                this.$message.success('报工成功!')
                console.log(this.dialogForm.nextstepcode, 1)
                if (this.dialogForm.nextstepcode !== '') {
                if (this.dialogForm.nextstepcode === '') {
                  this.ZZprint2(this.OperationArr.find(item => item.usercode === this.dialogForm.operation).username)
                  this.dialogVisible2 = true
                }
@@ -2043,6 +2085,7 @@
      this.badDialogForm = {}
      this.badDialogForm.operation = getCookie('navTabId')
      this.badTableDataDialog = []
      this.judgeIsScanningArr = []
    },
    async  getMesOrderSelectUserAll() {
      const { data: res } = await MesOrderSelectUser({ usercode: '' })