licp
2024-07-26 82e5335ce391e116a8aab48097e7efb76ce35007
解决j数采多个项目时数据回显不完的问题
已修改2个文件
已添加2个文件
202 ■■■■ 文件已修改
.nvmdrc 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/do/b1-inspect-order-plan/Inspection.vue 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
static/js/worker0.js 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.nvmdrc
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1 @@
18.11.0
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){
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";
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)
                }
              }
            }
          })
        }
      }
    })
  })
}