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"
@@ -145,18 +134,23 @@
              <el-table-column
                prop="plan_startdate"
                label="计划开工日期"
                width="185"
                width="150"
                sortable="custom"
              />
              >
                <template slot-scope="{row}">
                  <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0,11) }}</div>
                  <div v-else>/</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="plan_enddate"
                label="计划完工日期"
                width="185"
                width="150"
                sortable="custom"
                fixed="right"
              >
                <template slot-scope="{row}">
                  <div v-if="row.plan_startdate">{{ row.plan_startdate }}</div>
                  <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0,11) }}</div>
                  <div v-else>/</div>
                </template>
              </el-table-column>
@@ -207,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>
@@ -234,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"
@@ -339,18 +321,23 @@
              <el-table-column
                prop="plan_startdate"
                label="计划开工日期"
                width="185"
                width="150"
                sortable="custom"
              />
              >
                <template slot-scope="{row}">
                  <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0,11) }}</div>
                  <div v-else>/</div>
                </template>
              </el-table-column>
              <el-table-column
                prop="plan_enddate"
                label="计划完工日期"
                width="185"
                width="150"
                sortable="custom"
                fixed="right"
              >
                <template slot-scope="{row}">
                  <div v-if="row.plan_startdate">{{ row.plan_startdate }}</div>
                  <div v-if="row.plan_startdate">{{ row.plan_startdate.substring(0,11) }}</div>
                  <div v-else>/</div>
                </template>
              </el-table-column>
@@ -389,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>
@@ -415,26 +403,25 @@
              <el-table-column
                prop="wo_code"
                label="工单号"
                width="160"
                min-width="160"
                sortable="custom"
              />
              <el-table-column
                prop="partcode"
                label="产品编码"
                width="110"
                min-width="110"
                sortable="custom"
              />
              <el-table-column
                prop="partname"
                width="160"
                min-width="160"
                label="产品名称"
                show-tooltip-when-overflow
                sortable="custom"
              />
              <el-table-column
                prop="stepname"
                label="工序"
                width="120"
                min-width="120"
                sortable="custom"
              />
              <el-table-column
@@ -617,6 +604,23 @@
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <!--        <el-form-item v-if="dialogTitle==='自制报工'" label="报工人员:">-->
        <!--          <el-input v-model="dialogForm.remarks" type="textarea" style="width: 200px;" />-->
        <!--        </el-form-item>-->
        <el-form-item v-if="dialogTitle==='自制报工'" label="报工人:">
          <el-select
            v-model="dialogForm.operation"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in OperationArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
@@ -803,8 +807,8 @@
        <el-form-item
          v-if="dialogTitle==='外协收料'"
          label="不良原因:"
          prop="badcode"
        >
          <!--          prop="badcode"-->
          <el-select
            v-model="dialogForm.badcode"
            style="width: 200px;"
@@ -817,6 +821,20 @@
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogTitle==='外协收料'" label="收料人:">
          <el-select
            v-model="dialogForm.operation"
            style="width: 200px;"
            placeholder="请选择"
          >
            <el-option
              v-for="item in OperationArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
            />
          </el-select>
        </el-form-item>
@@ -960,7 +978,7 @@
            placeholder="请选择"
          >
            <el-option
              v-for="item in badOperationArr"
              v-for="item in OperationArr"
              :key="item.usercode"
              :label="item.username"
              :value="item.usercode"
@@ -1028,8 +1046,8 @@
          />
          <el-table-column
            prop="repair_qty"
            label="维修数量"
            width="90"
            label="维修合格数量"
            width="110"
          >
            <template slot-scope="{row}">
              <!--              {{ row.repair_qty }}-->
@@ -1192,6 +1210,7 @@
        startqtySum: '', // 不能超过的数值
        operation: getCookie('navTabId'), // 报工人(收料人)
        remarks: ''// 备注
      },
@@ -1284,23 +1303,38 @@
        operation: getCookie('navTabId')
      },
      badTableDataDialog: [], // 不良对话框table表格
      badOperationArr: [] // 维修人员数组
      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()
@@ -1315,8 +1349,11 @@
    })
    // webapp_urlprotocol_startup()
    // webapp_ws_autoupdate(true)
    this.getMesOrderSelectUserAll() // 获取所有人员
  },
  methods: {
    tableRowClassName({ row, rowIndex }) {
      return 'custom-row'
    },
@@ -1404,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
@@ -1581,7 +1662,7 @@
    // 生产班组下拉改变
    usergroupChange(val) {
      this.dialogForm.usergroupcode = val
      this.getUserTableData()
      this.getMesOrderSelectUserZZ2()
    },
    // 获取自制报工生产班组下拉列表
    async getMesOrderStepReportSelectUserGroup() {
@@ -1592,6 +1673,11 @@
    async getMesOrderSelectUserZZ() {
      const { data: res } = await MesOrderSelectUser({ usercode: this.dialogForm.usergroupcode })
      this.ZZuserArr = res
    },
    async getMesOrderSelectUserZZ2() {
      const { data: res } = await MesOrderSelectUser({ usercode: '' })
      this.ZZuserArr = res
      await this.getUserTableData()
    },
    // 获取自制生产设备下拉
    async getMesOrderStepStartSelectEqp() {
@@ -1630,6 +1716,8 @@
        item.isVisible = 0
        item.number = number
      })
      this.ZZuserArr = [...this.ZZuserArr].filter(x => [...this.userTableData].every(y => y.usercode !== x.usercode))
    },
    // 用户添加
    userAdd() {
@@ -1640,6 +1728,11 @@
    },
    // 用户列表删除
    userDel(row) {
      this.ZZuserArr.splice(0, 0, {
        usercode: row.usercode,
        username: row.username
      })
      this.userTableData.forEach((item, index) => {
        if (item.number === row.number) {
          this.userTableData.splice(index, 1)
@@ -1652,6 +1745,13 @@
      if (row.usercode === '') {
        return this.$message.info('人员名称不能为空!')
      }
      this.ZZuserArr.forEach((item, index) => {
        if (item.usercode === row.usercode) {
          this.ZZuserArr.splice(index, 1)
        }
      })
      this.userTableData.forEach(item => {
        if (item.number === row.number) {
          item.isVisible = 0
@@ -1682,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 = '', // 产品名称
@@ -1718,7 +1823,7 @@
      this.dialogForm.nextstepcode = '' // 下道工序编码
      this.dialogForm.remarks = '' // 备注
      this.dialogForm.operation = getCookie('navTabId') // 报工人(收料人)
      this.userTableData = [] // 人员列表
      this.$refs.dialogForm.clearValidate()
@@ -1784,12 +1889,12 @@
            SavaMesOrderStepIn(data).then(res => {
              if (res.code === '200') {
                this.$message.success('收料成功!')
                this.dialogVisible = false
                if (this.dialogForm.nextstepcode !== '') {
                  this.WXprint2()
                if (this.dialogForm.nextstepcode === '') {
                  this.WXprint2(this.OperationArr.find(item => item.usercode === this.dialogForm.operation).username)
                  this.dialogVisible2 = true
                }
                this.dialogVisible = false
                this.tabClick()
              } else {
                this.$message.error('收料失败!')
@@ -1860,13 +1965,12 @@
            SavaMesOrderStepReport(data).then(res => {
              if (res.code === '200') {
                this.$message.success('报工成功!')
                this.dialogVisible = false
                console.log(this.dialogForm.nextstepcode, 1)
                if (this.dialogForm.nextstepcode !== '') {
                  this.ZZprint2()
                if (this.dialogForm.nextstepcode === '') {
                  this.ZZprint2(this.OperationArr.find(item => item.usercode === this.dialogForm.operation).username)
                  this.dialogVisible2 = true
                }
                this.dialogVisible = false
                this.tabClick()
              } else {
                this.$message.error('报工失败!')
@@ -1889,27 +1993,27 @@
        correctLevel: QRCode.CorrectLevel.L// 容错率,L/M/H
      })
    },
    ZZprint2() {
    ZZprint2(username) {
      this.qrForm.qrvalue = this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode
      this.qrForm.startqty = this.dialogForm.startqty
      this.qrForm.wo_code = this.dialogForm.wo_code
      this.qrForm.partcode = this.dialogForm.partcode
      this.qrForm.partname = this.dialogForm.partname
      this.qrForm.nextstepname = this.dialogForm.nextstepname
      this.qrForm.operator = getCookie('username')
      this.qrForm.operator = username
      this.qrForm.operatorTime = handleDatetime2(new Date())
      this.$nextTick(() => {
        this.bindQRCode(this.qrForm.qrvalue)
      })
    },
    WXprint2() {
    WXprint2(username) {
      this.qrForm.qrvalue = this.dialogForm.wo_code + ';' + this.dialogForm.nextstepcode
      this.qrForm.startqty = this.dialogForm.sqty
      this.qrForm.wo_code = this.dialogForm.wo_code
      this.qrForm.partcode = this.dialogForm.partcode
      this.qrForm.partname = this.dialogForm.partname
      this.qrForm.nextstepname = this.dialogForm.nextstepname
      this.qrForm.operator = getCookie('username')
      this.qrForm.operator = username
      this.qrForm.operatorTime = handleDatetime2(new Date())
      this.$nextTick(() => {
        this.bindQRCode(this.qrForm.qrvalue)
@@ -1952,17 +2056,11 @@
      const data = {
        Data: this.badTableDataDialog
      }
      // console.log(JSON.stringify(data), 1)
      // console.log(this.badDialogForm.operation, 1)
      // this.badPrintOperator =
      // this.badPrint(this.badOperationArr.find(item => item.usercode === this.badDialogForm.operation).username)
      // this.dialogVisible2 = true
      EditOrderNgStepSeave(data, this.badDialogForm.operation).then(res => {
        if (res.code === '200' || res.code === '301') {
          this.getBadList()
          this.badDialogVisible = false
          this.badPrint(this.badOperationArr.find(item => item.usercode === this.badDialogForm.operation).username)
          this.badPrint(this.OperationArr.find(item => item.usercode === this.badDialogForm.operation).username)
          this.dialogVisible2 = true
          return this.$message.success('保存成功!')
        }
@@ -1987,13 +2085,14 @@
      this.badDialogForm = {}
      this.badDialogForm.operation = getCookie('navTabId')
      this.badTableDataDialog = []
      this.judgeIsScanningArr = []
    },
    async  getMesOrderSelectUserAll() {
      const { data: res } = await MesOrderSelectUser({ usercode: '' })
      this.OperationArr = res
    },
    // 点击维修处理按钮  或  扫描条码的扫描回车事件
    async repairHandle(row) {
      const { data: res1 } = await MesOrderSelectUser({ usercode: '' })
      this.badOperationArr = res1
      console.log(row)
      let data
      if (row.wo_code) {
        data = {
@@ -2059,10 +2158,6 @@
      })
    },
    badSave(row) {
      console.log(row, 1)
      // console.log(parseFloat(row.bad_qty) + parseFloat(row.repair_qty), 2)
      // console.log(parseFloat(row.ng_qty), 2)
      // console.log(parseFloat(row.bad_qty) + parseFloat(row.repair_qty) > parseFloat(row.ng_qty), 2)
      if (parseFloat(row.bad_qty) + parseFloat(row.repair_qty) > parseFloat(row.ng_qty)) {
        this.badCancel(row)
        return this.$message.info('维修数量与报废数量之和不能大于不良数量!')
@@ -2070,8 +2165,8 @@
      this.badTableDataDialog.forEach((item, index) => {
        if (item.id === row.id && item.m_id === row.m_id) {
          this.badTableDataDialog.splice(index, 1, {
            bad_qty: row.bad_qty,
            repair_qty: row.repair_qty,
            bad_qty: parseFloat(row.bad_qty),
            repair_qty: parseFloat(row.repair_qty),
            isVisible: 0,
            defect_code: row.defect_code,
            defect_name: row.defect_name,