From 9c1906a8056c0c88fdd116b60fbd17aa8a0cbb5c Mon Sep 17 00:00:00 2001 From: gaoluyang <gaoluyang@rengu.cc> Date: 星期四, 18 七月 2024 16:32:25 +0800 Subject: [PATCH] 原始记录模板表格刷新当前页数不变 --- static/js/worker.js | 99 +++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 79 insertions(+), 20 deletions(-) diff --git a/static/js/worker.js b/static/js/worker.js index a09aa41..a8717a2 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*', '') } @@ -98,7 +101,11 @@ let str = handleFraction(m.split('=')[1]) if(typeof res == 'string'&&typeof str == 'string'){ if(res.includes('/')){ - return handleMoreParam(res,m.split('=')[1],'=') + if (m.includes('/')) { + return eval(res) == eval(str) + } else { + return handleMoreParam(res,m.split('=')[1],'=') + } }else{ // console.log(res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, ''),' == ',str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '')) return res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '') == str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '') @@ -108,42 +115,74 @@ } } else if (m.includes('鈮�')) { if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m.split('鈮�')[1],'鈮�') + if (m.includes('/')) { + // console.log('eval(res)----', eval(res)) + 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('/')){ - return handleMoreParam(res,m.split('鈮�')[1],'鈮�') + 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 if (m.includes('<')) { if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m.split('<')[1],'<') + 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 if (m.includes('>')) { if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m.split('>')[1],'>') + 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 if (m.includes('~')) { if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m,'~') + 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 if(m.includes('-')){ if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m,'-') + 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]))) @@ -151,21 +190,36 @@ } }else if(m.includes('卤')){ if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m,'卤') + if (m.includes('/')) { + 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,'卤') + } }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('/')){ - return handleMoreParam(res,m.split('锛�')[1],'>') + 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 if(m.includes('锛�')){ if(typeof res =='string'&&res.includes('/')){ - return handleMoreParam(res,m.split('锛�')[1],'<') + 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) @@ -198,7 +252,7 @@ } }) } - console.log(tableList) + // console.log(tableList) } result = { method:'saveInsContext', @@ -217,15 +271,15 @@ 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 = 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) { let num2 = new Big(comResult) - comResult = num2.toExponential() + comResult = num2.toExponential(1) } }else{ let valueList = []; @@ -257,8 +311,12 @@ for (var b in a) { if (a[b].c == item.c) { try{ - let val = parseFloat(comResult.toFixed(3)) - a[b].v.v = isNaN(val) ? '' : val + if(comResult==0){ + a[b].v.v = 0 + }else{ + let val = parseFloat(comResult.toFixed(3)) + a[b].v.v = isNaN(val) ? '' : val + } }catch(error){ a[b].v.v = comResult console.log('error---', error) @@ -553,8 +611,6 @@ } } - - /** * 鏍规嵁鍧愭爣鑾峰彇鍒楀悕 * @param {Object} cellId @@ -709,7 +765,7 @@ * @param comValue 瀵硅薄绫诲瀷锛岃〃绀鸿鏇挎崲鐨勫崟鍏冩牸鍊硷紝閿负鍗曞厓鏍煎悕绉帮紝鍊间负鏇挎崲鍚庣殑鍊� * @returns 杩斿洖璁$畻鍚庣殑缁撴灉锛屽鏋滆绠楀け璐ュ垯杩斿洖0 */ -function compute(f,comValue){ +function compute(f,comValue, isPoint){ try { let str = f // 鑾峰彇鍗曞厓鏍煎搴斿�� @@ -763,8 +819,11 @@ 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 { return eval(str) } -- Gitblit v1.9.3