loulijun2021
2022-09-01 99a010f21d278498bafd248217c584e101db2d8f
src/views/zlgl/gxjy.vue
@@ -13,7 +13,9 @@
          <el-input
            v-model="form.orderstepqrcode"
            name="GXproduceCode"
            style="width: 300px"
            @keyup.native="e=>judgeIsScanning(e,'GXproduceCode')"
            @keyup.enter.native="val=>enterNative(val,'GXproduceCode')"
          />
        </div>
@@ -396,7 +398,8 @@
      multipleSelection: [], // 表格多选框
      tabClickIndex: null, // 点击的单元格
      tabClickLabel: '', // 当前点击的列名
      isCancel: false// 是否点击取消按钮
      isCancel: false, // 是否点击取消按钮
      judgeIsScanningArr: []// 判断是否扫码数组
    }
  },
  created() {
@@ -499,6 +502,42 @@
      row.name = res.name
      row.stepcheckitem_desc = res.descr
    },
    // 防抖      //扫码用的是防抖
    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()
            that.enterNative(that.form.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]) < 10
        if (i > 0 && this.judgeIsScanningArr.length === parseInt(i) + 1) {
          if (flag) {
            this.fnThrottle(this.enterNative, 500, 2000, belong)()
            return
          }
        }
      }
    },
    // 扫码键盘回车事件
    async enterNative(val, belong) {
      if (belong === 'GXproduceCode') {