From c263fb316fc23d9db98ce711fda30d81c28d2d9c Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 08 八月 2024 19:02:10 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/center-lims-before

---
 static/js/worker.js |  127 +++++++++++++++++++++++++++++++-----------
 1 files changed, 94 insertions(+), 33 deletions(-)

diff --git a/static/js/worker.js b/static/js/worker.js
index b80cfc3..c3336df 100644
--- a/static/js/worker.js
+++ b/static/js/worker.js
@@ -1,23 +1,61 @@
 
 let code = ''
-let tableList = []
+let tableList = null
 let excelMethodList = []
 let comparisonList = []
 let currentSample = {}
 let PROJECT = ''
+let bushing = ''
 let result = {
   method:'',
   value:null
 }
 let param = null
+let currentTable = ''
 self.onmessage = function(event) {
   const data = JSON.parse(event.data);
+  if(currentTable!=data.currentTable){
+    tableList = data.tableList;
+  }
+  currentTable = data.currentTable;
+  if(data.type&&data.type=='saveData'){
+    tableList = data.tableList;
+    param = data.param;
+    return
+  }
+  if(data.bushing&&(data.bushing!=bushing)&&data.type=='saveData'){
+    tableList = data.tableList;
+    param = data.param;
+    bushing = data.bushing;
+    return
+  }
   code = data.code;
-  tableList = JSON.parse(JSON.stringify(data.tableList));
+  if(tableList){
+    let str = code.split('-')
+    let r = str[1]
+    let c = str[2]
+    tableList[0].arr.forEach((item,index)=>{
+      item.forEach((m,i)=>{
+        if(m.c==c&&m.r==r){
+          tableList[0].arr[index] = data.tableList[0].arr[index]
+        }
+      })
+    })
+  }else{
+    tableList = data.tableList;
+  }
+  if(param){
+    let str = code.split('-')
+    let pId = str[3]
+    param[pId] = data.param[pId]
+  }else{
+    param = data.param;
+  }
+  // tableList = data.tableList;
+  // param = data.param;
   excelMethodList = JSON.parse(JSON.stringify(data.excelMethodList));
   comparisonList = JSON.parse(JSON.stringify(data.comparisonList));
   currentSample = JSON.parse(JSON.stringify(data.currentSample));
-  param = data.param;
   PROJECT = data.PROJECT
   changeInput('', code);
 };
@@ -38,7 +76,6 @@
   let isToExponential = ''
   let list2 = []
   let isPoint = ''
-
   excelMethodList.forEach(item => {
     if (item.valueList&&item.valueList.length>0&&item.valueList.find(m => m.r == r && m.c == c)) {
       var comValue = {}
@@ -76,8 +113,7 @@
           let ask = currentSample.insProduct.find(m => m.id == item.i).ask?currentSample.insProduct.find(m => m.id == item.i).ask.split('&'):null;
           let res = Object.values(comValue)[0]
           let comp = []
-
-          if(res==''||res==null||res==undefined||res=='Infinity'){
+          if(res===''||res===null||res===undefined||res==='Infinity'){
             item.v.v = null
             list.forEach(a => {
               if (a[0].r == item.r) {
@@ -137,6 +173,7 @@
                     }
                   }else{
                     let str = handleFraction(m.split('鈮�')[1])
+                    console.log(555555,res,str)
                     return eval(res) <= eval(str)
                   }
                 }else if (m.includes('<')) {
@@ -252,8 +289,9 @@
                 }
               })
             }
-            // console.log(tableList)
+            // console.log(5555,tableList)
           }
+          // console.log('1234567789', tableList,getParam())
           result = {
             method:'saveInsContext',
             value:{
@@ -272,7 +310,7 @@
         try {
           if(getInspectionValueType(item.i)==1){
             let tell = currentSample.insProduct.find(m => m.id == item.i).tell?currentSample.insProduct.find(m => m.id == item.i).tell.split('&'):null;
-            isPoint = tell[0].includes('/') // 鍒ゆ柇瑕佹眰鍊兼槸鍚︿负鍒嗘暟
+            isPoint = PROJECT=='瑁呭鐢电紗'&&tell&&tell.length>0&&typeof tell[0] =='string'&&tell[0].includes('/') // 鍒ゆ柇瑕佹眰鍊兼槸鍚︿负鍒嗘暟
             comResult = compute(item.v.f.replace(/=/g, ' '),comValue, isPoint)
             let list3 = list2.map(item=>item+'')
             isToExponential = list3.some(val => val.includes('e+'))
@@ -310,10 +348,20 @@
             if (a[0].r == item.r && comResult !== '') {
               for (var b in a) {
                 if (a[b].c == item.c) {
-                  // console.log('comResult---', comResult)
                   try{
-                    let val = parseFloat(comResult.toFixed(3))
-                    a[b].v.v = isNaN(val) ? '' : val
+                    if(comResult==0){
+                      a[b].v.v = 0
+                    }else if(a[b].v.ct&&a[b].v.ct.fa&&typeof a[b].v.ct.fa == 'string'&&a[b].v.ct.fa.includes('.')){
+                      let num = 0
+                      let str = a[b].v.ct.fa.split('.')[1]
+                      num = str.length
+                      a[b].v.v = comResult?Number(comResult).toFixed(num):comResult
+                    }else{
+                      let val = parseFloat(Number(comResult).toFixed(3))
+                      a[b].v.v = isNaN(val) ? comResult : val
+                    }
+                    // console.log('a[b].v.ct', comResult)
+                    // console.log('a[b].v.v', a[b].v.v)
                   }catch(error){
                     a[b].v.v = comResult
                     console.log('error---', error)
@@ -420,33 +468,41 @@
  * @returns 杩斿洖澶勭悊鍚庣殑鍙傛暟瀵硅薄
  */
 function getParam(){
-  for (var b in param){
-    param[b].insValue = []
-    param[b].comValue = []
-    param[b].equipValue = []
-    param[b].equipName = []
-    param[b].resValue = null
-    param[b].insResult = null
-  }
+  tableList[0].arr.forEach(a=>{
+    a.forEach(b=>{
+      if(param[b.i]){
+        param[b.i].insValue = []
+        param[b.i].comValue = []
+        param[b.i].equipValue = []
+        param[b.i].equipName = []
+        param[b.i].resValue = null
+        param[b.i].insResult = null
+      }
+    })
+  })
   tableList[0].arr.forEach(a => {
     a.forEach(b=>{
-      if (b.v.ps != undefined && b.v.ps.value === '妫�楠屽��') {
+      if (b.v.ps != undefined &&typeof b.v.ps.value =='string'&& b.v.ps.value.includes('妫�楠屽��')) {
         b.i &&b.v.v&& param[b.i].insValue.push(b)
       }
       if (b.v.ps != undefined && b.v.ps.value === '璁$畻鍊�') {
         b.i &&b.v.v&& param[b.i].comValue.push(b)
       }
       if (b.v.ps != undefined && b.v.ps.value === '璁惧缂栫爜') {
-        b.i &&b.v.v&& param[b.i].equipValue.push(b)
+        b.i &&b.v&& param[b.i].equipValue.push(b)
       }
       if (b.v.ps != undefined && b.v.ps.value === '璁惧鍚嶇О') {
-        b.i &&b.v.v&& param[b.i].equipName.push(b)
+        b.i &&b.v&& param[b.i].equipName.push(b)
       }
       if (b.v.ps != undefined && b.v.ps.value === '鏈�缁堝��') {
-        b.i &&b.v.v&& (param[b.i].resValue = b)
+        b.i &&b.v&& (param[b.i].resValue = b)
       }
       if (b.v.ps != undefined && b.v.ps.value === '缁撹') {
-        b.i &&(b.v.v||b.v.v===0||b.v.v==='0')&& (param[b.i].insResult = b)
+        if(b.i &&(b.v.v||b.v.v===0||b.v.v==='0')){
+          if(b.v.v != '鍚堟牸'&&b.v.v != '涓嶅悎鏍�'){
+            param[b.i].insResult = b
+          }
+        }
       }
     })
   })
@@ -463,7 +519,7 @@
 function SUM(...val){
   try {
     let num = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val.length>0){
       val.forEach(item=>{
         num+=item;
       })
@@ -482,7 +538,7 @@
 function MAX(...val){
   try {
     let max = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val.length>0){
       val = val.filter(item=>item!=null&&item!=='')
       if(val.length>0){
         max = Math.max(...val)
@@ -504,7 +560,7 @@
 function MIN(...val){
   try {
     let min = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val.length>0){
       val = val.filter(item=>item!=null&&item!=='')
       if(val.length>0){
         min = Math.min(...val)
@@ -525,8 +581,8 @@
   try {
     let num = null;
     let arr = [];
-    if(val&&val.length>0){
-      arr = val.filter(item=>item!=null&&item!=='')
+    if(val!=null&&val!=undefined&&val!='undefined'&&val.length>0){
+      arr = val.filter(item=>item!==null&&item!==''&&item!=undefined)
       arr.forEach(item=>{
         num+=item;
       })
@@ -607,8 +663,6 @@
     console.log('error---', error)
   }
 }
-
-
 
 /**
  * 鏍规嵁鍧愭爣鑾峰彇鍒楀悕
@@ -816,14 +870,21 @@
       str = str.replace(new RegExp(a, 'g'),arr[a])
     }
     if(str.includes(',,')){
-      str = str.replace(new RegExp(',,', 'g'),'')
+      str = str.replace(new RegExp(',,', 'g'),',')
     }
+    if(str.includes(',,')){
+      str = str.replace(new RegExp(',,', 'g'),',')
+    }
+    if(str.includes(',,')){
+      str = str.replace(new RegExp(',,', 'g'),',')
+    }
+    // console.log('str', str)
     if(str.includes('&"/"&')){
       return str.replace(new RegExp('&"/"&', 'g'),'/').replace(new RegExp('//', 'g'),'')
-      return str.replaceAll('&"/"&', '/').replaceAll('//','')
     } else if (isPoint) {
       return str.replace('ABS', '').replace(/\(|\)/g, '')
     }else {
+      console.log('str', str,eval(str))
       return eval(str)
     }
   } catch (error) {

--
Gitblit v1.9.3