Преглед изворни кода

fix(report): replaceAll兼容QQ浏览器

lishihao пре 4 година
родитељ
комит
983c01b5d4
1 измењених фајлова са 6 додато и 2 уклоњено
  1. 6 2
      report/src/core/formulasFun.ts

+ 6 - 2
report/src/core/formulasFun.ts

@@ -6,6 +6,11 @@ import { ReportDate as useReportDate } from '../public/ReportDate'
 import { ICurrent_RPT, IRptTpl, IDataObj, Fields } from '../interface/basic'
 import { JV  } from './jpc_value_define';
 
+/* eslint-disable import/prefer-default-export */
+export const replaceAll = (FindText: RegExp | string, RepText: string, str: string): string => {
+    const regExp = new RegExp(FindText, 'g');
+    return str.replace(regExp, RepText);
+  };
 
 export const formulaExec = (runType: string, $CURRENT_TEMPLATE: IRptTpl, $CURRENT_DATA: IDataObj, $CURRENT_RPT: ICurrent_RPT) => {
     formulasDataSetter.setupData($CURRENT_RPT, $CURRENT_DATA);
@@ -33,7 +38,6 @@ export const formulaExec = (runType: string, $CURRENT_TEMPLATE: IRptTpl, $CURREN
         trim,
         leftTrim,
         rightTrim,
-        replaceAll,
         comdify,
         convertToCaptionNum,
         convertStrToBoolean,
@@ -55,7 +59,7 @@ export const formulaExec = (runType: string, $CURRENT_TEMPLATE: IRptTpl, $CURREN
                     // console.log(expression);
                     //临时处理
                     if (expression.indexOf(`new Date(`)) {
-                        newExpression= replaceAll(`new Date(`, `new ReportDate(`,expression)
+                        newExpression= replaceAll(/new Date\(/g, `new ReportDate(`,expression)
                     }
                     eval(newExpression);
                 } catch (ex) {