From 82e5335ce391e116a8aab48097e7efb76ce35007 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期五, 26 七月 2024 12:40:53 +0800
Subject: [PATCH] 解决j数采多个项目时数据回显不完的问题

---
 static/js/worker0.js                                   |   77 +++++++++++++++++++
 src/main.js                                            |    2 
 src/components/do/b1-inspect-order-plan/Inspection.vue |  122 ++++++++++++++++++------------
 .nvmdrc                                                |    1 
 4 files changed, 152 insertions(+), 50 deletions(-)

diff --git a/.nvmdrc b/.nvmdrc
new file mode 100644
index 0000000..421dc09
--- /dev/null
+++ b/.nvmdrc
@@ -0,0 +1 @@
+18.11.0
\ No newline at end of file
diff --git a/src/components/do/b1-inspect-order-plan/Inspection.vue b/src/components/do/b1-inspect-order-plan/Inspection.vue
index 498b892..d10c9a0 100644
--- a/src/components/do/b1-inspect-order-plan/Inspection.vue
+++ b/src/components/do/b1-inspect-order-plan/Inspection.vue
@@ -940,6 +940,7 @@
         },
         result: null,
         worker: null,
+        worker0: null,
         wareLength:[],
         dataAcquisitionInfo:{},
         dataAcquisitionEidt:0,
@@ -1124,69 +1125,92 @@
             return
           }
           this.dataAcquisitionInfo = res.data
-          let list = this.tableList[0].arr
-          list.forEach((item,index)=>{
-            let num = 0;
-            let str = ''
-            item.forEach(m=>{
-              if(m.v.ps&&(m.v.ps.value=='妫�楠屽瓙椤�'||m.v.ps.value=='妫�楠岄」')){
-                if(m.v.ps&&m.v.ps.value=='妫�楠岄」'){
-                  if(num==0){
-                    str = m.v.v+','
-                    num++
-                  }
-                }
-                if(m.v.ps&&m.v.ps.value=='妫�楠屽瓙椤�'){
-                  if(num==1){
-                    str = str+m.v.v
-                  }
-                }
-                if(this.dataAcquisitionInfo[str]){
-                  let num = 0;
-                  list[index].forEach(n=>{
-                    if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
-                      num++
-                    }
-                  })
-                  list[index].forEach((n,i)=>{
-                    if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
-                      let arr = n.v.ps.value.split('鍊�')
-                      if(arr[1] ==this.dataAcquisitionInfo.frequency){
-                        setTimeout(()=>{
-                          this.$delete(n.v,'v')
-                          this.$set(n.v,'v',this.dataAcquisitionInfo[str])
-                          this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
-                        },1000)
-                      }else if(Number(this.dataAcquisitionInfo.frequency)>num){
-                        if(n.v.ps.value.includes(num)){
-                          setTimeout(()=>{
-                            this.$delete(n.v,'v')
-                            this.$set(n.v,'v',this.dataAcquisitionInfo[str])
-                            this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
-                          },1000)
-                        }
-                      }
-                    }
-                  })
-                }
-              }
-            })
-          })
+          // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
+          this.worker0.postMessage(JSON.stringify({
+            dataAcquisitionInfo: this.dataAcquisitionInfo,
+            list:this.tableList[0].arr
+          }));
+          // 鐩戝惉 Worker 杩斿洖鐨勭粨鏋�
+          this.worker0.onmessage = (event) => {
+            let result = JSON.parse(event.data);
+            if(result.method=='changeInput'){
+              let {list,n} = result.value
+              this.$set(this.tableList[0],'arr',list)
+              this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+            }
+          };
+          // let list = this.tableList[0].arr
+          // list.forEach((item,index)=>{
+          //   let num = 0;
+          //   let str = ''
+          //   item.forEach(m=>{
+          //     if(m.v.ps&&(m.v.ps.value=='妫�楠屽瓙椤�'||m.v.ps.value=='妫�楠岄」')){
+          //       if(m.v.ps&&m.v.ps.value=='妫�楠岄」'){
+          //         if(num==0){
+          //           str = m.v.v+','
+          //           num++
+          //         }
+          //       }
+          //       if(m.v.ps&&m.v.ps.value=='妫�楠屽瓙椤�'){
+          //         if(num==1){
+          //           str = str+m.v.v
+          //         }
+          //       }
+          //       if(this.dataAcquisitionInfo[str]){
+          //         let num = 0;
+          //         list[index].forEach(n=>{
+          //           if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+          //             num++
+          //           }
+          //         })
+          //         list[index].forEach((n,i)=>{
+          //           if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+          //             let arr = n.v.ps.value.split('鍊�')
+          //             if(arr[1] ==this.dataAcquisitionInfo.frequency){
+          //               setTimeout(()=>{
+          //                 this.$delete(n.v,'v')
+          //                 this.$set(n.v,'v',this.dataAcquisitionInfo[str])
+          //                 this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+          //               },1000)
+          //             }else if(Number(this.dataAcquisitionInfo.frequency)>num){
+          //               if(n.v.ps.value.includes(num)){
+          //                 setTimeout(()=>{
+          //                   this.$delete(n.v,'v')
+          //                   this.$set(n.v,'v',this.dataAcquisitionInfo[str])
+          //                   this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+          //                 },1000)
+          //               }
+          //             }
+          //           }
+          //         })
+          //       }
+          //     }
+          //   })
+          // })
         })
       },
       // 澶氱嚎绋�
       startWorker() {
-      if (this.worker) {
+        if (this.worker) {
         this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝�
         }
         // 鍒涘缓 Worker 瀹炰緥
         this.worker = new Worker('/static/js/worker.js');
+        if (this.worker0) {
+        this.stopWorker(); // 纭繚涔嬪墠鐨� Worker 宸插仠姝�
+        }
+        // 鍒涘缓 Worker 瀹炰緥
+        this.worker0 = new Worker('/static/js/worker0.js');
       },
       stopWorker() {
         if (this.worker) {
           this.worker.terminate();
           this.worker = null;
         }
+        if (this.worker0) {
+          this.worker0.terminate();
+          this.worker0 = null;
+        }
       },
       // 娓╁害寰幆---寮�濮�
       changeItem(row){
diff --git a/src/main.js b/src/main.js
index f1ef892..7187b4b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -21,7 +21,7 @@
 // Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80";
 // const javaApi = 'http://127.0.0.1:8001';
 // 寮狅細192.168.45.249
-const javaApi = 'http://192.168.45.249:8001';
+const javaApi = 'http://192.168.45.2:8001';
 
 //浜�
 // Vue.prototype.LOCATIONVUE = "http://114.132.189.42:8080";
diff --git a/static/js/worker0.js b/static/js/worker0.js
new file mode 100644
index 0000000..c0f4e72
--- /dev/null
+++ b/static/js/worker0.js
@@ -0,0 +1,77 @@
+let dataAcquisitionInfo = null;
+let list = null;
+let result = {
+  method:'',
+  value:null
+}
+
+self.onmessage = function(event) {
+  const data = JSON.parse(event.data);
+  dataAcquisitionInfo = data.dataAcquisitionInfo;
+  list = data.list;
+  handleData()
+}
+
+function handleData(){
+  // console.log(33333,dataAcquisitionInfo)
+  list.forEach((item,index)=>{
+    let num = 0;
+    let str = ''
+    item.forEach(m=>{
+      if(m.v.ps&&(m.v.ps.value=='妫�楠屽瓙椤�'||m.v.ps.value=='妫�楠岄」')){
+        if(m.v.ps&&m.v.ps.value=='妫�楠岄」'){
+          if(num==0){
+            str = m.v.v+','
+            num++
+          }
+        }
+        if(m.v.ps&&m.v.ps.value=='妫�楠屽瓙椤�'){
+          if(num==1){
+            str = str+m.v.v
+          }
+        }
+        if(dataAcquisitionInfo[str]){
+          let num = 0;
+          list[index].forEach(n=>{
+            if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+              num++
+            }
+          })
+          list[index].forEach((n,i)=>{
+            if(n.v.ps&&n.v.ps.value&&typeof n.v.ps.value == 'string'&&n.v.ps.value.includes('妫�楠屽��')){
+              let arr = n.v.ps.value.split('鍊�')
+              if(arr[1] ==dataAcquisitionInfo.frequency){
+                n.v.v = dataAcquisitionInfo[str]
+                result = {
+                  method:'changeInput',
+                  value:{
+                    list:list,
+                    n:n
+                  }
+                }
+                self.postMessage(JSON.stringify(result))
+              }else if(Number(dataAcquisitionInfo.frequency)>num){
+                if(n.v.ps.value.includes(num)){
+                  n.v.v = dataAcquisitionInfo[str]
+                  result = {
+                    method:'changeInput',
+                    value:{
+                      list:list,
+                      n:n
+                    }
+                  }
+                  self.postMessage(JSON.stringify(result))
+                  // setTimeout(()=>{
+                  //   this.$delete(n.v,'v')
+                  //   this.$set(n.v,'v',this.dataAcquisitionInfo[str])
+                  //   this.changeInput('',`${this.currentSample.insProduct[0].templateId}-${n.r}-${n.c}-${n.i}`,n)
+                  // },1000)
+                }
+              }
+            }
+          })
+        }
+      }
+    })
+  })
+}

--
Gitblit v1.9.3