From 759731d6262311987f657ee57d96608b8df2c80a Mon Sep 17 00:00:00 2001
From: gaoluyang <gaoluyang@rengu.cc>
Date: 星期五, 12 七月 2024 09:29:39 +0800
Subject: [PATCH] 科学计数法保留一位小数

---
 static/js/worker.js |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/static/js/worker.js b/static/js/worker.js
index a09aa41..c522b04 100644
--- a/static/js/worker.js
+++ b/static/js/worker.js
@@ -37,6 +37,8 @@
   }
   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 = {}
@@ -91,6 +93,7 @@
             // 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*', '')
                 }
@@ -107,6 +110,8 @@
                     return  eval(res) == eval(str)
                   }
                 } else if (m.includes('鈮�')) {
+                  console.log('eval(res)---', eval(res))
+                  console.log('eval(str)---', eval(str))
                   if(typeof res =='string'&&res.includes('/')){
                     return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
                   }else{
@@ -198,7 +203,7 @@
                 }
               })
             }
-            console.log(tableList)
+            // console.log(tableList)
           }
           result = {
             method:'saveInsContext',
@@ -217,15 +222,17 @@
         let comResult = ''
         try {
           if(getInspectionValueType(item.i)==1){
-            // let ask = currentSample.insProduct.find(m => m.id == item.i).ask?currentSample.insProduct.find(m => m.id == item.i).ask.split('&'):null;
-            // let tell = currentSample.insProduct.find(m => m.id == item.i).tell?currentSample.insProduct.find(m => m.id == item.i).tell.split('&'):null;
-            comResult = compute(item.v.f.replace(/=/g, ' '),comValue)
+            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('/') // 鍒ゆ柇瑕佹眰鍊兼槸鍚︿负鍒嗘暟
+            console.log('comValue---', comValue)
+            comResult = compute(item.v.f.replace(/=/g, ' '),comValue, isPoint)
+            console.log('comResult---', comResult)
             let list3 = list2.map(item=>item+'')
             isToExponential = list3.some(val => val.includes('e+'))
             // 瑁呭椤圭洰妫�楠屽�艰浆鍖�
             if (PROJECT === '瑁呭鐢电紗' && isToExponential) {
               let num2 = new Big(comResult)
-              comResult = num2.toExponential()
+              comResult = num2.toExponential(1)
             }
           }else{
             let valueList = [];
@@ -709,7 +716,7 @@
  * @param comValue 瀵硅薄绫诲瀷锛岃〃绀鸿鏇挎崲鐨勫崟鍏冩牸鍊硷紝閿负鍗曞厓鏍煎悕绉帮紝鍊间负鏇挎崲鍚庣殑鍊�
  * @returns 杩斿洖璁$畻鍚庣殑缁撴灉锛屽鏋滆绠楀け璐ュ垯杩斿洖0
  */
-function compute(f,comValue){
+function compute(f,comValue, isPoint){
   try {
     let str = f
     // 鑾峰彇鍗曞厓鏍煎搴斿��
@@ -765,6 +772,9 @@
     }
     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 {
       return eval(str)
     }

--
Gitblit v1.9.3