From 5eeb8864bebb1dc4f97f2feef32b742d8a9a10d5 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 14 九月 2022 15:43:04 +0800
Subject: [PATCH] 1.新增报表管理菜单

---
 src/views/scgl/sckbg.vue |  289 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 218 insertions(+), 71 deletions(-)

diff --git a/src/views/scgl/sckbg.vue b/src/views/scgl/sckbg.vue
index 1da7ea2..f28de38 100644
--- a/src/views/scgl/sckbg.vue
+++ b/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.enter.native="val=>enterNative(val,'produceCode')"
               />
+              <!--                @keyup.native="e=>judgeIsScanning(e,'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"
@@ -214,6 +203,8 @@
                 style="width: 300px"
                 @keyup.enter.native="val=>enterNative(val,'WXproduceCode')"
               />
+              <!--              @keyup.native="e=>judgeIsScanning(e,'WXproduceCode')"-->
+
             </div>
             <div v-if="false" style="display: flex;padding-right: 10px">
               <el-button @click="WXsend">
@@ -239,19 +230,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"
@@ -401,6 +379,8 @@
                 style="width: 300px"
                 @keyup.enter.native="val=>enterNative(val,'badProduceCode')"
               />
+              <!--              @keyup.native="e=>judgeIsScanning(e,'badProduceCode')"-->
+
             </div>
           </div>
           <el-divider />
@@ -632,6 +612,20 @@
         <!--        <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>
         <el-form-item v-if="dialogTitle==='鑷埗鎶ュ伐'" label="澶囨敞锛�">
           <el-input v-model="dialogForm.remarks" type="textarea" style="width: 200px;" />
         </el-form-item>
@@ -815,8 +809,8 @@
         <el-form-item
           v-if="dialogTitle==='澶栧崗鏀舵枡'"
           label="涓嶈壇鍘熷洜锛�"
-          prop="badcode"
         >
+          <!--          prop="badcode"-->
           <el-select
             v-model="dialogForm.badcode"
             style="width: 200px;"
@@ -832,6 +826,20 @@
             />
           </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>-->
         <el-form-item v-if="dialogTitle==='澶栧崗鏀舵枡'" label="澶囨敞锛�">
           <el-input v-model="dialogForm.remarks" type="textarea" style="width: 200px;" />
         </el-form-item>
@@ -1040,8 +1048,8 @@
           />
           <el-table-column
             prop="repair_qty"
-            label="缁翠慨鏁伴噺"
-            width="90"
+            label="缁翠慨鍚堟牸鏁伴噺"
+            width="110"
           >
             <template slot-scope="{row}">
               <!--              {{ row.repair_qty }}-->
@@ -1190,7 +1198,7 @@
         taskqty: '', // 浠诲姟鏁伴噺
         fqty: '', // 鍙戞枡鏁伴噺
 
-        inuser: '', // 鏀舵枡浜哄憳
+        inuser: getCookie('navTabId'), // 鏀舵枡浜哄憳
         sqty: '', // 鏀舵枡鏁伴噺
         ngqty: '', // 涓嶈壇鏁伴噺
         badcode: '', // 涓嶈壇鍘熷洜缂栫爜
@@ -1204,6 +1212,7 @@
 
         startqtySum: '', // 涓嶈兘瓒呰繃鐨勬暟鍊�
 
+        operation: getCookie('navTabId'), // 鎶ュ伐浜猴紙鏀舵枡浜猴級
         remarks: ''// 澶囨敞
 
       },
@@ -1296,23 +1305,39 @@
         operation: getCookie('navTabId')
       },
       badTableDataDialog: [], // 涓嶈壇瀵硅瘽妗唗able琛ㄦ牸
-      OperationArr: [] // 浜哄憳鏁扮粍
+      OperationArr: [], // 浜哄憳鏁扮粍
+      sendButtonIsDisabled: false, // 涓嬭揪鎸夐挳鏄惁鍙偣鍑�
+      judgeIsScanningArr: [], // 鍒ゆ柇鏄惁鎵爜鏁扮粍
+      countJudgeIsScanningInput: 0// 鍒ゆ柇鎵爜妗嗙殑涓暟
     }
   },
-  // 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
+    //
+    //     // 鍦ㄨ繖閲岃皟鐢紝骞舵墽琛宼his.fnThrottle(this.search, 500, 2000)();
+    //     this.fnThrottle(this.enterNative, 500, 2000, 'produceCode')()
+    //   }
+    // },
+    // 'WXform.orderstepqrcode': {
+    //   handler(newValue) {
+    //     this.form.orderstepqrcode = newValue
+    //
+    //     // 鍦ㄨ繖閲岃皟鐢紝骞舵墽琛宼his.fnThrottle(this.search, 500, 2000)();
+    //     this.fnThrottle(this.enterNative, 500, 2000, 'WXproduceCode')()
+    //   }
+    // },
+    // 'badForm.orderstepqrcode': {
+    //   handler(newValue) {
+    //     this.form.orderstepqrcode = newValue
+    //
+    //     // 鍦ㄨ繖閲岃皟鐢紝骞舵墽琛宼his.fnThrottle(this.search, 500, 2000)();
+    //     this.fnThrottle(this.enterNative, 500, 2000, 'badProduceCode')()
+    //   }
+    // }
+  },
+
   created() {
     this.getMesOrderStepSearch()
     this.tabClick()
@@ -1327,8 +1352,11 @@
     })
     // webapp_urlprotocol_startup()
     // webapp_ws_autoupdate(true)
+
+    this.getMesOrderSelectUserAll() // 鑾峰彇鎵�鏈変汉鍛�
   },
   methods: {
+
     tableRowClassName({ row, rowIndex }) {
       return 'custom-row'
     },
@@ -1416,9 +1444,108 @@
         })
       }
     },
+    // 闃叉姈      //鎵爜鐢ㄧ殑鏄槻鎶�
+    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)
+        }
+      }
+    },
+    // 鍒ゆ柇鏄惁鏄壂鐮佹灙鎵爜
+    judgeIsScanning2(e, belong) {
+      if (belong === 'produceCode' && this.form.orderstepqrcode.toString().length === 0) {
+        this.judgeIsScanningArr = []
+        this.countJudgeIsScanningInput = 0
+      }
+      if (belong === 'WXproduceCode' && this.WXform.orderstepqrcode.toString().length === 0) {
+        this.judgeIsScanningArr = []
+        this.countJudgeIsScanningInput = 0
+      }
+      const timenow = e.timeStamp
+      // console.log(timenow, 1)
+      // let flag = true
+      let flag = false
+      this.judgeIsScanningArr.push(timenow)
+      let i
+
+      for (i in this.judgeIsScanningArr) {
+        console.log(Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]))
+        // flag = Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]) < 0.1
+        if (Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]) < 0.1) {
+          this.countJudgeIsScanningInput++
+        }
+        if (this.countJudgeIsScanningInput >= 3) {
+          flag = true
+        }
+        if (i > 0 && this.judgeIsScanningArr.length === parseInt(i) + 1) {
+          if (flag) {
+            console.log(flag, 1)
+            this.fnThrottle(this.enterNative, 500, 2000, belong)()
+            return
+          }
+        }
+      }
+
+      // // for (i in this.judgeIsScanningArr) {
+      // // console.log(i)
+      // // console.log( this.judgeIsScanningArr)
+      // console.log(Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]))
+      // if (Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 1]) - Math.ceil(this.judgeIsScanningArr[this.judgeIsScanningArr.length - 2]) < 10) {
+      //   this.countJudgeIsScanningInput++
+      // }
+      // if (this.countJudgeIsScanningInput > this.judgeIsScanningArr.length / 2) {
+      //   flag = true
+      // }
+      // // 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) {
+      //   console.log(flag, 2)
+      //   this.fnThrottle(this.enterNative, 500, 2000, belong)()
+      //   return
+      // }
+      // // }
+      // // }
+    },
+    // 鍒ゆ柇鏄惁鏄壂鐮佹灙鎵爜
+    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
       // 鎶ュ伐锛歝ode="200"  count=1
       // 鍙戞枡锛歝ode="200"  count=2
@@ -1593,7 +1720,7 @@
     // 鐢熶骇鐝粍涓嬫媺鏀瑰彉
     usergroupChange(val) {
       this.dialogForm.usergroupcode = val
-      this.getUserTableData()
+      this.getMesOrderSelectUserZZ2()
     },
     // 鑾峰彇鑷埗鎶ュ伐鐢熶骇鐝粍涓嬫媺鍒楄〃
     async getMesOrderStepReportSelectUserGroup() {
@@ -1604,6 +1731,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() {
@@ -1642,6 +1774,8 @@
         item.isVisible = 0
         item.number = number
       })
+
+      this.ZZuserArr = [...this.ZZuserArr].filter(x => [...this.userTableData].every(y => y.usercode !== x.usercode))
     },
     // 鐢ㄦ埛娣诲姞
     userAdd() {
@@ -1652,6 +1786,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)
@@ -1664,6 +1803,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
@@ -1694,6 +1840,11 @@
     },
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
+      this.judgeIsScanningArr = []
+      this.form.orderstepqrcode = ''
+      this.WXform.orderstepqrcode = ''
+      this.badForm.orderstepqrcode = ''
+
       this.dialogForm.wo_code = '', // 宸ュ崟缂栧彿
       this.dialogForm.partcode = '', // 浜у搧缂栫爜
       this.dialogForm.partname = '', // 浜у搧鍚嶇О
@@ -1713,7 +1864,7 @@
       this.dialogForm.taskqty = '', // 浠诲姟鏁伴噺
       this.dialogForm.fqty = '', // 鍙戞枡鏁伴噺
 
-      this.dialogForm.inuser = '', // 鏀舵枡浜哄憳
+      this.dialogForm.inuser = getCookie('navTabId'), // 鏀舵枡浜哄憳  榛樿鐧诲綍浜哄憳
       this.dialogForm.sqty = '', // 鏀舵枡鏁伴噺
       this.dialogForm.ngqty = '', // 涓嶈壇鏁伴噺
       this.dialogForm.badcode = '', // 涓嶈壇鍘熷洜缂栫爜
@@ -1730,7 +1881,7 @@
       this.dialogForm.nextstepcode = '' // 涓嬮亾宸ュ簭缂栫爜
 
       this.dialogForm.remarks = '' // 澶囨敞
-
+      this.dialogForm.operation = getCookie('navTabId') // 鎶ュ伐浜猴紙鏀舵枡浜猴級
       this.userTableData = [] // 浜哄憳鍒楄〃
 
       this.$refs.dialogForm.clearValidate()
@@ -1796,12 +1947,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.inuser).username)
                   this.dialogVisible2 = true
                 }
+                this.dialogVisible = false
                 this.tabClick()
               } else {
                 this.$message.error('鏀舵枡澶辫触!')
@@ -1872,13 +2023,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('鎶ュ伐澶辫触!')
@@ -1901,27 +2051,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)
@@ -1993,13 +2143,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.OperationArr = res1
-
-      console.log(row)
       let data
       if (row.wo_code) {
         data = {
@@ -2065,10 +2216,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('缁翠慨鏁伴噺涓庢姤搴熸暟閲忎箣鍜屼笉鑳藉ぇ浜庝笉鑹暟閲忥紒')
@@ -2076,8 +2223,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,

--
Gitblit v1.9.3