|
@@ -43,34 +43,4 @@ export function simulateCopyText(text) {
|
|
|
type: 'success',
|
|
|
message: '文本已复制',
|
|
|
});
|
|
|
-}
|
|
|
-
|
|
|
-// 全局匹配费用计算公式
|
|
|
-export function matchStringAndFormat(str, regArr) {
|
|
|
- // 使用正则表达式匹配非计算字符的序列
|
|
|
- const nonCalculationCharacters = str.match(/[^\+\-*/\(\) ]+/g);
|
|
|
- let res = str.replace(/[^\+\-*/\(\) ]+/g, '$');
|
|
|
- let filterArr = [] as any;
|
|
|
- regArr.filter(item => {
|
|
|
- nonCalculationCharacters.forEach((team, index) => {
|
|
|
- if (item.label === team) {
|
|
|
- filterArr[index] = item.value;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- filterArr = Array.from(filterArr);
|
|
|
- filterArr.forEach((item, index) => {
|
|
|
- if (!item) {
|
|
|
- filterArr[index] = nonCalculationCharacters[index];
|
|
|
- }
|
|
|
- });
|
|
|
- if (filterArr.length < nonCalculationCharacters.length) {
|
|
|
- const sliceArr = nonCalculationCharacters.slice(filterArr.length);
|
|
|
- filterArr = [...filterArr, ...sliceArr];
|
|
|
- }
|
|
|
- filterArr.forEach(item => {
|
|
|
- res = res.replace('$', item);
|
|
|
- });
|
|
|
- const newStr = res.replace(/(/g, '(').replace(/)/g, ')');
|
|
|
- return newStr;
|
|
|
-}
|
|
|
+}
|