From d975fc4756806f5b51f006c19c33571b9b8c0b3b Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期五, 20 十二月 2024 09:30:19 +0800
Subject: [PATCH] 修改下单时要求值输入限制

---
 static/js/worker.js |  468 +++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 301 insertions(+), 167 deletions(-)

diff --git a/static/js/worker.js b/static/js/worker.js
index ba752fe..e618e24 100644
--- a/static/js/worker.js
+++ b/static/js/worker.js
@@ -1,29 +1,59 @@
-
+// 澶氱嚎绋嬮噷闈㈤渶瑕佷繚瀛樼殑鏁版嵁
 let code = ''
+// 琛ㄦ牸鏁版嵁锛堟覆鏌擄級
 let tableList = null
+// 鏂规硶鍒楄〃
 let excelMethodList = []
+// excel鍧愭爣姣旇緝鍒楄〃
 let comparisonList = []
+// 褰撳墠鏍峰搧淇℃伅
 let currentSample = {}
+// 褰撳墠椤圭洰锛氭娴嬩腑蹇冦�佽澶囩數缂�
 let PROJECT = ''
+// 濂楃
+let bushing = ''
+// 澶氱嚎绋嬩紶閫掑埌涓荤嚎绋嬬殑鏁版嵁
 let result = {
   method:'',
   value:null
 }
+// 淇濆瓨鏃朵紶鍒板悗绔弬鏁�
 let param = null
+// 褰撳墠鐨勬ā鏉�
 let currentTable = ''
+// 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d
+let getDataTypeId = null
+// 鎺ユ敹鍒颁富绾跨▼澶勭悊閫昏緫鐨勬秷鎭�
 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;
+  if(data.getDataTypeId){
+    // 璁板綍 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d
+    getDataTypeId = data.getDataTypeId
+  }else{
+    getDataTypeId = null
+  }
   if(tableList){
+    // 濡傛灉琛ㄦ牸鏁版嵁瀛樺湪锛屽垯鏇存柊褰撳墠淇敼妫�楠岄」鐨勮〃鏍兼暟鎹�
     let str = code.split('-')
     let r = str[1]
     let c = str[2]
@@ -35,48 +65,56 @@
       })
     })
   }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));
   PROJECT = data.PROJECT
+  // 鎵ц璁$畻鏂规硶
   changeInput('', code);
 };
 
 function changeInput(m, code){
   let str = code.split('-')
-  let r = str[1]
-  let c = str[2]
+  let r = str[1]//褰撳墠琛�
+  let c = str[2]//褰撳墠鍒�
   let id = str[0]
-  let pId = str[3]
-  var list = []
+  let pId = str[3]//褰撳墠妫�楠岄」id锛宲aram[pId]涓哄綋鍓嶆楠岄」鐨勬墍鏈夊�硷紝鍖呭惈锛氳繃绋嬪�糹nsValue銆佽绠楀�糲omValue銆佽澶囩紪鐮乪quipValue銆佽澶囧悕绉癳quipName銆佹渶缁堝�紃esValue銆佺粨璁篿nsResult
+  var list = []//涓�涓弻灞傛暟缁勶紝閲岄潰淇濆瓨鏈夊綋鍓嶉〉闈㈡覆鏌撶殑鎵�鏈夋暟鎹�
+  // 璧嬪�煎綋鍓嶆ā鏉跨殑琛ㄦ牸鏁版嵁
   for (let a in tableList) {
     if (tableList[a].templateId == id) {
       list = tableList[a].arr
       break
     }
   }
-  let isToExponential = ''
-  let list2 = []
-  let isPoint = ''
+  let isToExponential = ''//鏄惁涓虹瀛﹁鏁版硶
+  let list2 = [] //涓�涓暟缁勶紝閲岄潰淇濆瓨鏈夊綋鍓嶆楠岄」鐨勬墍鏈夊弬鏁板��
+  let isPoint = '' //鏄惁涓哄皬鏁扮偣
+  // 寰幆鎵�鏈塭xcel鏂规硶锛屾壘鍒板綋鍓嶈銆佸垪鐨勬楠岄」锛屽鏋滄鍗曞厓鏍硷紙r,c锛夋槸鏌愪釜excel鏂规硶閲岄潰鐨勫弬鏁帮紝鍒欐墽琛屾鏂规硶
   excelMethodList.forEach(item => {
+    // item.valueList  鏄綋鍓峞xcel鏂规硶鐨勫弬鏁板垪琛紝鎵惧埌褰撳墠濉叆鐨勫�兼槸鍚︽槸鍙傛暟
     if (item.valueList&&item.valueList.length>0&&item.valueList.find(m => m.r == r && m.c == c)) {
+      // 濡傛灉鏄紝鍒欏畾涔変竴涓弬鏁扮殑瀵硅薄闆嗗悎锛岀敤浜庝繚瀛樺綋鍓峞xcel鏂规硶鍙傛暟鐨勫��
       var comValue = {}
       item.valueList.forEach(a => {
         list.forEach(b => {
           if (b[0].r == a.r) {
             b.forEach(c => {
               if (c.c == a.c) {
+                // 鑾峰彇褰撳墠鍙傛暟鐨凟xecl琛屽潗鏍�(ABCD)绛夌瓑
                 var tableCode = ''
                 for (var d in comparisonList) {
                   if (c.c == comparisonList[d].value) {
@@ -85,14 +123,18 @@
                   }
                 }
                 list2.push(c.v.v)
+                // 缁勮鍙傛暟鐨勫璞¢泦鍚堝苟璧嬪�硷紝鍒楀{A3:12,B4:15}
                 if(getInspectionValueType(item.i)==1&&!isNaN(parseFloat(c.v.v))){
+                  // 濡傛灉鏄暟瀛楄緭鍏ユ
                   let n = String(c.v.v)
                   if(n.includes('/')){
+                    // 濡傛灉鏄垎鏁帮紝鍒欒祴鍊�
                     comValue[(tableCode + (c.r + 1))] = c.v.v
                   }else{
                     comValue[(tableCode + (c.r + 1))] = parseFloat(c.v.v)
                   }
                 }else{
+                  // 濡傛灉鏄枃鏈�佷笅鎷夋绛夌瓑
                   comValue[(tableCode + (c.r + 1))] = c.v.v
                 }
               }
@@ -100,14 +142,17 @@
           }
         })
       })
+      // 濡傛灉姝xcel鏂规硶鏄粨璁哄垽鏂柟娉曪紝鍒欐墽琛屾鏂规硶
       if (item.v.ps != undefined && item.v.ps.value == '缁撹') {
         try {
           if (currentSample.insProduct.find(m => m.id == item.i)) {
+            // 濡傛灉褰撳墠妫�楠岄」鏄骇鍝佹楠岄」锛屽垯鎵ц姝ゆ柟娉曪紝鎵惧埌姝ゆ楠岄」鐨勮姹傚��
           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) {
@@ -120,178 +165,212 @@
               }
             })
           }else{
-            // console.log(ask,res,item.v.f)
-            if(ask){
-              comp = ask.map((m, i) => {
-                // console.log('m----', m)
-                if (m.includes('RTS')) {
-                  m = m.replace('RTS*', '')
+            // 濡傛灉涓嶄负绌猴紝鍒欏垽鏂綋鍓嶇粨璁哄氨闇�瑕佽繘琛屽垽鏂�
+            //瑕佹眰鍊间负-锛�/锛屸�旓紝鍒欑粨璁鸿缃负涓嶅垽瀹氾紝缁撹璧嬪�间负3
+            console.log(3333,ask)
+            if(ask[0]=='-' || ask[0]=='/' || ask[0]=='鈥�'){
+              item.v.v = 3
+              list.forEach(a => {
+                if (a[0].r == item.r) {
+                  for (let  b=0; b<a.length; b++) {
+                    if (a[b].c == item.c) {
+                      a[b].v.v = 3
+                      break
+                    }
+                  }
                 }
-                if (m.includes('=')) {
-                  let str = handleFraction(m.split('=')[1])
-                  if(typeof res == 'string'&&typeof str == 'string'){
-                    if(res.includes('/')){
-                      if (m.includes('/')) {
-                        return  eval(res) == eval(str)
-                      } else {
-                        return handleMoreParam(res,m.split('=')[1],'=')
+              })
+            }else{
+              // 瑕佹眰鍊间笉涓�-锛�/锛屸�旓紝鍒欒繘琛屽垽鏂�
+              if(ask){
+                // 寰幆瑕佹眰鍊煎垪琛紝鍒ゆ柇褰撳墠缁撹鐨勫弬鏁版槸鍚︾鍚堣姹�
+                comp = ask.map((m, i) => {
+                  // 瑁呭鐗规湁鐨勫垽鏂柟娉曪紙闇�瑕佺瀛﹁鏁版硶鐨勶級锛岃姹傚�艰繘琛屾浛鎹�
+                  if (m.includes('RTS')) {
+                    m = m.replace('RTS*', '')
+                  }
+                  // 濡傛灉瑕佹眰鍊煎寘鍚�=锛屽垯鍒ゆ柇褰撳墠缁撹鐨勫弬鏁版槸鍚︾瓑浜庤姹傚�硷紝
+                  // 浠ヤ笅鍒ゆ柇鍩烘湰涓�鑷达紝鍙槸鍒ゆ柇绫诲瀷涓嶄竴鏍凤紝灏变笉鍋氭敞閲婁簡
+                  if (m.includes('=')) {
+                    // 澶勭悊瑕佹眰鍊�
+                    let str = handleFraction(m.split('=')[1])
+                    if(typeof res == 'string'&&typeof str == 'string'){
+                      // 濡傛灉瑕佹眰鍊煎拰褰撳墠缁撹鐨勫弬鏁伴兘鏄瓧绗︿覆锛屽垯鎵ц
+                      if(res.includes('/')){
+                        // 濡傛灉缁撹鐨勫弬鏁版槸鍒嗘暟锛屽垯鍒ゆ柇
+                        if (m.includes('/')) {
+                          // 濡傛灉瑕佹眰鍊兼槸鍒嗘暟锛屽垯鍒ゆ柇
+                          return  eval(res) == eval(str)
+                        } else {
+                          // 濡傛灉瑕佹眰鍊间笉鏄垎鏁帮紝鍒欏垽鏂�
+                          return handleMoreParam(res,m.split('=')[1],'=')
+                        }
+                      }else{
+                        // 濡傛灉缁撹鐨勫弬鏁颁笉鏄垎鏁帮紝鍒欏垽鏂�
+                        return  res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '') == str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '')
                       }
                     }else{
-                      // console.log(res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, ''),' == ',str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, ''))
-                      return  res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '') == str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '')
+                      // 濡傛灉瑕佹眰鍊煎拰褰撳墠缁撹鐨勫弬鏁版湁涓�涓槸鏁板瓧锛屽垯鎵ц
+                      return  eval(res) == eval(str)
                     }
-                  }else{
-                    return  eval(res) == eval(str)
-                  }
-                } else if (m.includes('鈮�')) {
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
-                      // console.log('eval(res)----', eval(res))
+                  } else if (m.includes('鈮�')) {
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('鈮�')[1])
+                        return eval(res) >= eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+                      }
+                    }else{
                       let str = handleFraction(m.split('鈮�')[1])
-                      // console.log('eval(str)----', eval(str))
                       return eval(res) >= eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
                     }
-                  }else{
-                    let str = handleFraction(m.split('鈮�')[1])
-                    return eval(res) >= eval(str)
-                  }
-                }else if (m.includes('鈮�')) {
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if (m.includes('鈮�')) {
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('鈮�')[1])
+                        return eval(res) <= eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+                      }
+                    }else{
                       let str = handleFraction(m.split('鈮�')[1])
                       return eval(res) <= eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
                     }
-                  }else{
-                    let str = handleFraction(m.split('鈮�')[1])
-                    return eval(res) <= eval(str)
-                  }
-                }else if (m.includes('<')) {
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if (m.includes('<')) {
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('<')[1])
+                        return  eval(res) < eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('<')[1],'<')
+                      }
+                    }else{
                       let str = handleFraction(m.split('<')[1])
                       return  eval(res) < eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('<')[1],'<')
                     }
-                  }else{
-                    let str = handleFraction(m.split('<')[1])
-                    return  eval(res) < eval(str)
-                  }
-                }else if (m.includes('>')) {
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if (m.includes('>')) {
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('>')[1])
+                        return  eval(res) > eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('>')[1],'>')
+                      }
+                    }else{
                       let str = handleFraction(m.split('>')[1])
                       return  eval(res) > eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('>')[1],'>')
                     }
-                  }else{
-                    let str = handleFraction(m.split('>')[1])
-                    return  eval(res) > eval(str)
-                  }
-                }else if (m.includes('~')) {
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if (m.includes('~')) {
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let k = m.split('~')
+                        return  eval(res) >= eval(handleFraction((k[0]))) && eval(res) <= eval(handleFraction(k[1]))
+                      } else {
+                        return handleMoreParam(res,m,'~')
+                      }
+                    }else{
                       let k = m.split('~')
                       return  eval(res) >= eval(handleFraction((k[0]))) && eval(res) <= eval(handleFraction(k[1]))
-                    } else {
-                      return handleMoreParam(res,m,'~')
                     }
-                  }else{
-                    let k = m.split('~')
-                    return  eval(res) >= eval(handleFraction((k[0]))) && eval(res) <= eval(handleFraction(k[1]))
-                  }
-                }else if(m.includes('-')){
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if(m.includes('-')){
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let k = m.split('-')
+                        return  eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1]))
+                      } else {
+                        return handleMoreParam(res,m,'-')
+                      }
+                    }else{
                       let k = m.split('-')
+                      // console.log(k,eval(res),eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1])))
                       return  eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1]))
-                    } else {
-                      return handleMoreParam(res,m,'-')
                     }
-                  }else{
-                    let k = m.split('-')
-                    // console.log(k,eval(res),eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1])))
-                    return  eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1]))
-                  }
-                }else if(m.includes('卤')){
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if(m.includes('卤')){
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let k = m.split('卤')
+                        return  eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval(Number((handleFraction(k[0])) + Number(handleFraction(k[1]))))
+                      } else {
+                        return handleMoreParam(res,m,'卤')
+                      }
+                    }else{
                       let k = m.split('卤')
-                      return  eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval((handleFraction(k[0]) + handleFraction(k[1])))
-                    } else {
-                      return handleMoreParam(res,m,'卤')
+                      return  eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval(Number((handleFraction(k[0]) )+ Number(handleFraction(k[1]))))
                     }
-                  }else{
-                    let k = m.split('卤')
-                    return  eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval((handleFraction(k[0]) + handleFraction(k[1])))
-                  }
-                }else if(m.includes('锛�')){
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if(m.includes('锛�')){
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('锛�')[1])
+                        return  eval(res) > eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('锛�')[1],'>')
+                      }
+                    }else{
                       let str = handleFraction(m.split('锛�')[1])
                       return  eval(res) > eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('锛�')[1],'>')
                     }
-                  }else{
-                    let str = handleFraction(m.split('锛�')[1])
-                    return  eval(res) > eval(str)
-                  }
-                }else if(m.includes('锛�')){
-                  if(typeof res =='string'&&res.includes('/')){
-                    if (m.includes('/')) {
+                  }else if(m.includes('锛�')){
+                    if(typeof res =='string'&&res.includes('/')){
+                      if (m.includes('/')) {
+                        let str = handleFraction(m.split('锛�')[1])
+                        return  eval(res) < eval(str)
+                      } else {
+                        return handleMoreParam(res,m.split('锛�')[1],'<')
+                      }
+                    }else{
                       let str = handleFraction(m.split('锛�')[1])
                       return  eval(res) < eval(str)
-                    } else {
-                      return handleMoreParam(res,m.split('锛�')[1],'<')
                     }
-                  }else{
-                    let str = handleFraction(m.split('锛�')[1])
-                    return  eval(res) < eval(str)
                   }
-                }
-              })
+                })
+              }
+              // 濡傛灉瑕佹眰鍊肩殑姣忎釜鏉′欢閮界鍚堬紝鍒欑粰缁撹璧嬪�间负1锛屽悎鏍�
+              if (comp.every(m => m)) {
+                item.v.v = 1
+                list.forEach(a => {
+                  if (a[0].r == item.r) {
+                    for (let  b=0; b<a.length; b++) {
+                      if (a[b].c == item.c) {
+                        a[b].v.v = 1
+                        break
+                      }
+                    }
+                  }
+                })
+              }else {
+                // 鍚﹀垯缁欑粨璁鸿祴鍊间负0锛屼笉鍚堟牸
+                item.v.v = 0
+                list.forEach(a => {
+                  if (a[0].r == item.r) {
+                    for (let  b=0; b<a.length; b++) {
+                      if (a[b].c == item.c) {
+                        a[b].v.v = 0
+                        break
+                      }
+                    }
+                  }
+                })
+              }
             }
-            if (comp.every(m => m)) {
-              item.v.v = 1
-              list.forEach(a => {
-                if (a[0].r == item.r) {
-                  for (let  b=0; b<a.length; b++) {
-                    if (a[b].c == item.c) {
-                      a[b].v.v = 1
-                      break
-                    }
-                  }
-                }
-              })
-            } else {
-              item.v.v = 0
-              list.forEach(a => {
-                if (a[0].r == item.r) {
-                  for (let  b=0; b<a.length; b++) {
-                    if (a[b].c == item.c) {
-                      a[b].v.v = 0
-                      break
-                    }
-                  }
-                }
-              })
-            }
-            // console.log(tableList)
           }
-          // console.log('1234567789', tableList,getParam())
+          let getDataType0 = false
+          // 浼樺寲鏁伴噰杈冨鏁版嵁鏃�-璁板綍鏈�鍚庝竴涓楠岄」鐨刬d锛屽鏋滃綋鍓嶆楠岄」鐨刬d涓庤褰曠殑id鐩稿悓锛屽垯澶氫紶涓�涓弬鏁板埌涓荤嚎绋嬶紝杩涜鏁版嵁淇濆瓨锛屽惁鍒欐暟閲囧氨涓嶈繘琛屼繚瀛�
+          if(item.i==getDataTypeId){
+            getDataType0 = true
+          }
+          // 璧嬪�间紶閫掑埌涓荤嚎绋嬬殑鏁版嵁锛宮ethod锛歴aveInsContext琛ㄧず姝ゆ秷鎭渶瑕佷繚瀛樻暟鎹�
           result = {
             method:'saveInsContext',
             value:{
-              tableList,
-              param:getParam()
+              tableList,// 琛ㄦ牸鏁版嵁
+              param:getParam(),//浼犵粰鍚庣鐨勫弬鏁�
+              getDataTypeId:getDataType0?getDataTypeId:'',
+              currentInsItemId: item.i,// 褰撳墠妫�楠岄」鐨刬d
             }
           }
+          console.log('result---', result)
+          // 鍙戞秷鎭粰涓荤嚎绋�
           self.postMessage(JSON.stringify(result))
         }
         } catch (error) {
@@ -299,27 +378,36 @@
         }
 
       } else {
-        let comResult = ''
+        // 濡傛灉鏄嚱鏁版柟娉曪紝鍒欐墽琛屾鏂规硶
+        let comResult = ''//鍒濆鍖栬绠楃粨鏋�
         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 = PROJECT=='瑁呭鐢电紗'&&tell&&tell.length>0&&typeof tell[0] =='string'&&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+'))
-            // 瑁呭椤圭洰妫�楠屽�艰浆鍖�
-            if (PROJECT === '瑁呭鐢电紗' && isToExponential) {
+            // 鍒ゆ柇鏄惁涓虹瀛﹁鏁版硶锛屽鏋滀负绉戝璁℃暟娉曪紝鍒欒繘琛岃浆鍖�
+            isToExponential = list3.some(val => val.includes('e+')||val.includes('e-'))
+            // 妫�楠屽�艰浆鍖�
+            let findProduct = currentSample.insProduct.find(i=>i.inspectionItem=='浣撶Н鐢甸樆鐜�')
+            // 鍒ゆ柇妫�楠岄」鏄惁涓轰綋绉數闃荤巼锛屽鏋滀负浣撶Н鐢甸樆鐜囦笖澶т簬100000锛屽垯杩涜杞寲
+            if (findProduct && isToExponential && comResult>=100000) {
               let num2 = new Big(comResult)
               comResult = num2.toExponential(1)
             }
           }else{
+            // 濡傛灉妫�楠屽�肩被鍨嬫槸鏂囨湰杈撳叆妗嗐�佷笅鎷夋
             let valueList = [];
+            // 澶勭悊excel鍑芥暟鍙傛暟鍒楄〃
             item.valueList.forEach(a => {
               valueList.push({
                 name: `${comparisonList.find(e=>e.value==a.c).label}${a.r+1}`,
                 value: 0,
               })
             })
+            // 缁檈xcel鍑芥暟鍙傛暟璧嬫枃鏈��
             for (var a in comValue) {
               valueList.forEach(b => {
                 if (b.name == a) {
@@ -327,35 +415,44 @@
                 }
               })
             }
+            // 璁$畻鍏紡锛屽幓鎺塭xcel鍑芥暟鐨勭瓑鍙凤紝骞舵浛鎹㈠弬鏁帮紝鍒楀锛�=A1  鍙樻垚 A1 鍙樻垚 鈥樻枃鏈緭鍏ョ殑鍊尖��
             let str = item.v.f.replace(/=/g, ' ')
             valueList.forEach(b => {
               str = str.replace(b.name, b.value)
             })
+            // 璁$畻缁撴灉璧嬪��
             comResult = str
           }
         } catch (error) {
           console.log('error---', error)
         }
         try {
+          // 寰幆琛ㄦ牸鏁版嵁锛岀粰琛ㄦ牸鏁版嵁杩涜璧嬪��
           list.forEach(a => {
             if (a[0].r == item.r && comResult !== '') {
+              // 鍒ゆ柇褰撳墠琛屾槸鍚︿负褰撳墠妫�楠岄」鎵�鍦ㄨ锛屽鏋滀负褰撳墠琛岋紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪��
               for (var b in a) {
                 if (a[b].c == item.c) {
                   try{
                     if(comResult==0){
+                      // 鍒ゆ柇璁$畻缁撴灉鏄惁涓�0锛屽鏋滀负0锛屽垯缁欒〃鏍兼暟鎹祴鍊间负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):0
+                      a[b].v.v = comResult?Number(comResult).toFixed(num):comResult
+                    }else if(typeof comResult == 'string' && (comResult.includes('e+')|| comResult.includes('e-'))){
+                      // 鍒ゆ柇璁$畻缁撴灉鏄惁涓虹瀛﹁鏁版硶锛屽鏋滀负绉戝璁℃暟娉曪紝鍒欑粰琛ㄦ牸鏁版嵁璧嬪�间负绉戝璁℃暟娉�
+                      a[b].v.v = 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)
                   }
@@ -364,6 +461,7 @@
               }
             }
           })
+          // 濡傛灉姝よ绠楃粨鏋滄墍灞炲崟鍏冩牸锛屽悓鏃朵篃鏄彟涓�涓猠xcel鍑芥暟鐨勫弬鏁帮紝閭d箞灏遍渶瑕侀�掑綊杩涜璁$畻
           changeInput(comResult, `${id}-${item.r}-${item.c}-${pId}`) //鏀瑰彉鏈�缁堝��
         } catch (error) {
           console.log('error---', error)
@@ -371,22 +469,31 @@
       }
     }
   })
+  // 璧嬪�煎绾跨▼浼犺緭鏁版嵁
   result = {
     method:'tableList',
     value:tableList
   }
+  // 鍙戦�佷富绾跨▼鏁版嵁
   self.postMessage(JSON.stringify(result))
   try {
+    // 璧嬪�煎绾跨▼浼犺緭鏁版嵁
     result = {
       method:'getCurrentInsProduct',
       value:pId
     }
+    // 鍙戦�佷富绾跨▼鏁版嵁
     self.postMessage(JSON.stringify(result))
   } catch (error) {
     console.log('error---', error)
   }
 }
-
+/**
+ * 鑾峰彇妫�娴嬪�肩被鍨�
+ *
+ * @param id 妫�娴嬪�肩被鍨嬪搴旂殑id
+ * @returns 杩斿洖妫�娴嬪�肩被鍨�
+ */
 function getInspectionValueType(id) {
   for (var a in currentSample.insProduct) {
     if (currentSample.insProduct[a].id == id) {
@@ -402,8 +509,10 @@
  */
 function handleFraction(str){
   if(str&&typeof(str)=='string'&&str.includes('/')){
+    // 澶勭悊鍒嗘暟
     return eval(str.split('/')[0]/str.split('/')[1])
   } else if (str && typeof(str) == 'string' && str.includes('*') && str.includes('^')) {
+    // 璁$畻涔樻柟
     const num1 = str.split('*')
     const num2 = num1[1].split('^')
     let num3 = new Big(num2[0]);
@@ -439,7 +548,7 @@
           return item <= handleFraction(str)
         case '卤':
           let k = str.split('卤')
-          return  item >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && item <= eval((handleFraction(k[0]) + handleFraction(k[1])))
+          return  item >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && item <= eval(Number((handleFraction(k[0])) + Number(handleFraction(k[1]))))
         case '~':
           let j = str.split('~')
           return  item >= eval(handleFraction((j[0]))) && item <= eval(handleFraction(j[1]))
@@ -463,6 +572,7 @@
 function getParam(){
   tableList[0].arr.forEach(a=>{
     a.forEach(b=>{
+      // 鍒濆鍖栦紶閫掑埌鍚庣鐨勫弬鏁�
       if(param[b.i]){
         param[b.i].insValue = []
         param[b.i].comValue = []
@@ -475,23 +585,34 @@
   })
   tableList[0].arr.forEach(a => {
     a.forEach(b=>{
+      // 鏍规嵁琛ㄦ牸鏁版嵁锛岃祴鍊间紶閫掑埌鍚庣鐨勫弬鏁�
       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)
+        // 璧嬪�艰绠楀��
+        b.i &&b.v.v&&b.valueList&&b.valueList.length>0&& 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&&b.valueList&&b.valueList.length>0&& (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
+          }
+        }
       }
     })
   })
@@ -508,7 +629,7 @@
 function SUM(...val){
   try {
     let num = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
       val.forEach(item=>{
         num+=item;
       })
@@ -527,7 +648,7 @@
 function MAX(...val){
   try {
     let max = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
       val = val.filter(item=>item!=null&&item!=='')
       if(val.length>0){
         max = Math.max(...val)
@@ -549,7 +670,7 @@
 function MIN(...val){
   try {
     let min = null;
-    if(val&&val.length>0){
+    if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
       val = val.filter(item=>item!=null&&item!=='')
       if(val.length>0){
         min = Math.min(...val)
@@ -570,8 +691,8 @@
   try {
     let num = null;
     let arr = [];
-    if(val&&val.length>0){
-      arr = val.filter(item=>item!=null&&item!=''&&item!=undefined)
+    if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
+      arr = val.filter(item=>item!==null&&item!==''&&item!=undefined)
       arr.forEach(item=>{
         num+=item;
       })
@@ -730,6 +851,7 @@
     let arr = getABCList(f)
     let arr2 = []
     arr.forEach(item=>{
+      // 鍒ゆ柇鏄惁涓鸿寖鍥达紝鍒楀MAX(A1:B2)
       if(item.includes(':')){
         let r0 = getIdFromColumnName(item.split(':')[0]).r;
         let c0 = getIdFromColumnName(item.split(':')[0]).c;
@@ -744,6 +866,7 @@
           }
         }
       }else{
+        // 娌℃湁鍒欑洿鎺ヨ幏鍙�
         arr2.push(getIdFromColumnName(item))
       }
     })
@@ -761,6 +884,7 @@
 function getABCList(f){
   try {
     let regex = /[=\+\-\*\%\(\)\/\^\s]/g;
+    // 涓婇潰璁$畻鍑芥暟鏂板鍚庯紝杩欓噷涔熻鍚屾澧炲姞
     let fouList = [
       "SUM",
       'MAX',
@@ -768,6 +892,7 @@
       'AVERAGE',
       'ABS',
     ]
+    // 鏇挎崲鐗规畩瀛楃
     f = f.replace(regex, ',').replace(new RegExp('"&', 'g'),'').replace(new RegExp('&"', 'g'),'')
     fouList.forEach(item=>{
       f = f.replace(new RegExp(item, 'g'),',')
@@ -867,13 +992,22 @@
     if(str.includes(',,')){
       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'),'')
     } else if (isPoint) {
+      // 璁$畻甯﹀皬鏁扮偣鐨�
       return str.replace('ABS', '').replace(/\(|\)/g, '')
     }else {
-      console.log('str', str,eval(str))
+      console.log('str', str)
+      // 璁$畻甯歌鐨�
       return eval(str)
     }
   } catch (error) {

--
Gitblit v1.9.3