From 0406078b52bc6b5e6eed97ca7e42e559f786289b Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期二, 22 十月 2024 15:56:51 +0800
Subject: [PATCH] 报告编制预览功能修改
---
src/util/excelFountion.js | 47 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 38 insertions(+), 9 deletions(-)
diff --git a/src/util/excelFountion.js b/src/util/excelFountion.js
index 75988a1..05a3e7c 100644
--- a/src/util/excelFountion.js
+++ b/src/util/excelFountion.js
@@ -51,7 +51,7 @@
let min = null;
if(val&&val.length>0){
val = val.filter(item=>item!=null&&item!=='')
- console.log(val)
+ // console.log(val)
if(val.length>0){
min = Math.min(...val)
}
@@ -127,6 +127,27 @@
}
}else{
return null;
+ }
+ } catch (error) {
+
+ }
+}
+
+/**
+ * 璁$畻骞�
+ *
+ * @param str 瀛楃涓插舰寮忕殑骞傝〃杈惧紡锛屼緥濡�"2^3"
+ * @returns 杩斿洖璁$畻鍚庣殑骞傚�硷紝濡傛灉琛ㄨ揪寮忔棤鏁堝垯杩斿洖null
+ */
+function CalculatePower(str){
+ try {
+ if(str&&str.includes('^')){
+ let arr = str.split('^');
+ if(arr&&arr.length>1){
+ return Math.pow(arr[0],arr[1]);
+ }else{
+ return null;
+ }
}
} catch (error) {
@@ -248,12 +269,13 @@
'MAX',
'MIN',
'AVERAGE',
- 'APS',
+ 'ABS',
]
- f = f.replace(regex, ',')
+ f = f.replace(regex, ',').replace(new RegExp('"&', 'g'),'').replace(new RegExp('&"', 'g'),'')
fouList.forEach(item=>{
- f = f.replaceAll(item,',')
+ f = f.replace(new RegExp(item, 'g'),'')
})
+ // console.log('f',f)
let arr = f.split(',').filter(item=>{
return item&& /[a-zA-Z]/.test(item)&&item!='undefined'&&item!='null'
});
@@ -294,8 +316,15 @@
// 鑾峰彇鍗曞厓鏍煎搴斿��
let arr = getAllCell(f)
for (var a in comValue) {
- if(comValue[a]!=='undefine'&&comValue[a]!=='null'&&comValue[a]!==undefined){
- arr[a] = comValue[a]
+ if(comValue[a]!=='undefined'&&comValue[a]!=='null'&&comValue[a]!==undefined){
+ if(typeof(comValue[a])=='string'&&comValue[a].includes('^')){
+ // 璁$畻骞傛
+ arr[a] = CalculatePower(comValue[a])
+ } else if (typeof(comValue[a])=='string'&&comValue[a].includes('/')) {
+ arr[a] = comValue[a]
+ } else{
+ arr[a] = comValue[a]
+ }
}
}
// 瑙f瀽鍏紡鍙傛暟锛岀壒鍒槸甯︼細鐨�
@@ -325,14 +354,14 @@
obj[item] = item
}
})
- str = str.replaceAll(':', '-')
+ str = str.replace(new RegExp(':', 'g'),'')
// 鏇挎崲鍙傛暟
for (var a in obj) {
- str = str.replaceAll(a, obj[a])
+ str = str.replace(new RegExp(a, 'g'),obj[a])
}
// 璁$畻
for (var a in arr) {
- str = str.replaceAll(a, arr[a])
+ str = str.replace(new RegExp(a, 'g'),arr[a])
}
return eval(str)
} catch (error) {
--
Gitblit v1.9.3