|
@@ -719,12 +719,20 @@ let analyzer = {
|
|
|
return arrBase ? arrBase : [];
|
|
|
},
|
|
|
|
|
|
- getFID: function (FName, calcTemplate) { // F3、F22 → 4、99
|
|
|
+ getID: function (FName, calcTemplate) { // F13 → 4
|
|
|
let idx = FName.slice(1) - 1;
|
|
|
let id = calcTemplate.calcItems[idx] ? calcTemplate.calcItems[idx].ID : null;
|
|
|
return id;
|
|
|
},
|
|
|
- getFItem: function (FName, calcTemplate){ // F3 → calcItems[2] → {Object}
|
|
|
+ getFName: function (atID, calcTemplate) { // @3 → F7
|
|
|
+ for (var i = 0; i < calcTemplate.calcItems.length; i++) {
|
|
|
+ if (calcTemplate.calcItems[i].ID == atID.slice(1)) {
|
|
|
+ return 'F'+ (i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ },
|
|
|
+ getItem: function (FName, calcTemplate){ // F3 → calcItems[2] → {Object}
|
|
|
let idx = FName.slice(1) - 1;
|
|
|
return calcTemplate.calcItems[idx];
|
|
|
},
|
|
@@ -797,13 +805,31 @@ let analyzer = {
|
|
|
|
|
|
return true; // 表达式合法
|
|
|
},
|
|
|
+ getDispExpr: function (expression, calcTemplate) {
|
|
|
+ function refIDToLine(expr, template) {
|
|
|
+ let rst = expr;
|
|
|
+ let IDArr = analyzer.getAtIDArr(rst);
|
|
|
+ let fArr = [];
|
|
|
+ for (let atID of IDArr){
|
|
|
+ let FN = analyzer.getFName(atID, template);
|
|
|
+ fArr.push(FN);
|
|
|
+ };
|
|
|
+ for (let i = 0; i < IDArr.length; i++) {
|
|
|
+ let patt = new RegExp(IDArr[i]);
|
|
|
+ let val = fArr[i];
|
|
|
+ rst = rst.replace(patt, val);
|
|
|
+ };
|
|
|
+ return rst;
|
|
|
+ };
|
|
|
+ return refIDToLine(expression, calcTemplate);
|
|
|
+ },
|
|
|
getExpression: function (dispExpr, calcTemplate) {
|
|
|
function refLineToID(expr, template) {
|
|
|
let rst = expr;
|
|
|
let fArr = me.getFArr(rst);
|
|
|
let IDArr = [];
|
|
|
for (let F of fArr){
|
|
|
- let ID = me.getFID(F, template);
|
|
|
+ let ID = me.getID(F, template);
|
|
|
IDArr.push(ID);
|
|
|
};
|
|
|
for (let i = 0; i < fArr.length; i++) {
|
|
@@ -1083,7 +1109,8 @@ class CalcProgram {
|
|
|
|
|
|
for (let i = 0; i < template.calcItems.length; i++) {
|
|
|
let item = template.calcItems[i];
|
|
|
- item.expression = analyzer.getExpression(item.dispExpr, template);
|
|
|
+ // item.expression = analyzer.getExpression(item.dispExpr, template);
|
|
|
+ item.dispExpr = analyzer.getDispExpr(item.expression, template);
|
|
|
template.compiledCalcItems[item.ID] = item;
|
|
|
template.compiledCalcItems[item.ID + "_idx"] = i;
|
|
|
}
|