|
@@ -4,6 +4,119 @@ function isFormulaItem(ele){
|
|
|
}
|
|
|
|
|
|
//转换公式的参数
|
|
|
+// function transformArguments(children,curEle,eleMap){
|
|
|
+// let fcReg = /(FC\.\S+\()(.+)\)/;
|
|
|
+// let fcText = '';
|
|
|
+// for (let i = (children.length-1); i >= 0; i--) {
|
|
|
+// let ele = children[i];
|
|
|
+
|
|
|
+// if(ele.isOn === false){
|
|
|
+// //点击了开关关闭的,跳过
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// //console.log(ele.name)
|
|
|
+// let tmpArr = fcReg.exec(ele.template.ft);
|
|
|
+// fcText = tmpArr[1] + fcText;//fc.XX( 左括号部分
|
|
|
+// let argList = tmpArr[2].split(",");//括号里面参数部分#1,#2..
|
|
|
+// let isNestEle = false;//是否有过嵌套的元素了
|
|
|
+// let isNestEle2 = false;
|
|
|
+// //console.log(argList)
|
|
|
+// //console.log(text)
|
|
|
+// argList.forEach((argText,index)=>{
|
|
|
+// if(argText.indexOf('#')>-1){
|
|
|
+// //#动态参数
|
|
|
+// let argIndex = index;
|
|
|
+// for (let j = 0; j < ele.template.args.length; j++) {
|
|
|
+// if(ele.template.args[j].key == argText){
|
|
|
+// //找到相同的#编码
|
|
|
+// argIndex = j;
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// let arg = ele.arguments[argIndex];
|
|
|
+
|
|
|
+// if(arg && isFormulaItem(arg)){
|
|
|
+// if(!isNestEle && !isNestEle2 && i != (children.length-1) && curEle.id == arg.id){
|
|
|
+// //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
+// //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
+// isNestEle = true;
|
|
|
+// }else{
|
|
|
+// if(arg.type == 'Element'){
|
|
|
+// eleMap[arg.tableElementKey] = {
|
|
|
+// id: arg.id,
|
|
|
+// name: arg.name,
|
|
|
+// tableElementKey: arg.tableElementKey,
|
|
|
+// type: "Element",
|
|
|
+// };
|
|
|
+// fcText += `E[${arg.tableElementKey}]`;
|
|
|
+// }else if(arg.type == 'ParamData'){
|
|
|
+// eleMap[arg.k] = {
|
|
|
+// id: arg.id,
|
|
|
+// name: arg.name,
|
|
|
+// v:arg.v,
|
|
|
+// k:arg.k,
|
|
|
+// type: "ParamData",
|
|
|
+// };
|
|
|
+// fcText += `WP[${arg.k}]`;
|
|
|
+// }
|
|
|
+
|
|
|
+// }
|
|
|
+// }else if(Array.isArray(arg)){
|
|
|
+// //ifsles方法会进来
|
|
|
+// arg.forEach((a)=>{
|
|
|
+// if(a && isFormulaItem(a)){
|
|
|
+// if(!isNestEle2 && i != (children.length-1) && curEle.id == a.id){
|
|
|
+// //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
+// //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
+// isNestEle2 = true
|
|
|
+// }else{
|
|
|
+// if(a.type == 'Element'){
|
|
|
+// eleMap[a.tableElementKey] = {
|
|
|
+// id: a.id,
|
|
|
+// name: a.name,
|
|
|
+// tableElementKey: a.tableElementKey,
|
|
|
+// type: "Element",
|
|
|
+// };
|
|
|
+// fcText += `E[${a.tableElementKey}]`;
|
|
|
+// }else if(a.type == 'ParamData'){
|
|
|
+// eleMap[a.k] = {
|
|
|
+// id: a.id,
|
|
|
+// name: a.name,
|
|
|
+// v:a.v,
|
|
|
+// k:a.k,
|
|
|
+// type: "ParamData",
|
|
|
+// };
|
|
|
+// fcText += `WP[${a.k}]`;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else if(a && a.type == 'Operator'){
|
|
|
+// //在运算符前后加上空格
|
|
|
+// fcText += ' '+a.name+' ';
|
|
|
+// //console.log(fcText)
|
|
|
+// }else if(a && a.type){
|
|
|
+// fcText += a.name;
|
|
|
+// }else{
|
|
|
+// fcText += a?a:"''";
|
|
|
+// }
|
|
|
+// })
|
|
|
+
|
|
|
+// }else{
|
|
|
+// fcText += arg?arg:"''";
|
|
|
+// }
|
|
|
+
|
|
|
+// }else{
|
|
|
+// //已有参数
|
|
|
+// fcText += argText?argText:'';
|
|
|
+// }
|
|
|
+// if(index != argList.length-1){
|
|
|
+// fcText += ',';
|
|
|
+// }
|
|
|
+// })
|
|
|
+// fcText += ')';
|
|
|
+// }
|
|
|
+
|
|
|
+// return fcText;
|
|
|
+// }
|
|
|
function transformArguments(children,curEle,eleMap){
|
|
|
let fcReg = /(FC\.\S+\()(.+)\)/;
|
|
|
let fcText = '';
|
|
@@ -14,110 +127,115 @@ function transformArguments(children,curEle,eleMap){
|
|
|
//点击了开关关闭的,跳过
|
|
|
continue;
|
|
|
}
|
|
|
- //console.log(ele.name)
|
|
|
- let tmpArr = fcReg.exec(ele.template.ft);
|
|
|
- fcText = tmpArr[1] + fcText;//fc.XX( 左括号部分
|
|
|
- let argList = tmpArr[2].split(",");//括号里面参数部分#1,#2..
|
|
|
- let isNestEle = false;//是否有过嵌套的元素了
|
|
|
- let isNestEle2 = false;
|
|
|
- //console.log(argList)
|
|
|
- //console.log(text)
|
|
|
- argList.forEach((argText,index)=>{
|
|
|
- if(argText.indexOf('#')>-1){
|
|
|
- //#动态参数
|
|
|
- let argIndex = index;
|
|
|
- for (let j = 0; j < ele.template.args.length; j++) {
|
|
|
- if(ele.template.args[j].key == argText){
|
|
|
- //找到相同的#编码
|
|
|
- argIndex = j;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- let arg = ele.arguments[argIndex];
|
|
|
-
|
|
|
- if(arg && isFormulaItem(arg)){
|
|
|
- if(!isNestEle && !isNestEle2 && i != (children.length-1) && curEle.id == arg.id){
|
|
|
- //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
- //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
- isNestEle = true;
|
|
|
- }else{
|
|
|
- if(arg.type == 'Element'){
|
|
|
- eleMap[arg.tableElementKey] = {
|
|
|
- id: arg.id,
|
|
|
- name: arg.name,
|
|
|
- tableElementKey: arg.tableElementKey,
|
|
|
- type: "Element",
|
|
|
- };
|
|
|
- fcText += `E[${arg.tableElementKey}]`;
|
|
|
- }else if(arg.type == 'ParamData'){
|
|
|
- eleMap[arg.k] = {
|
|
|
- id: arg.id,
|
|
|
- name: arg.name,
|
|
|
- v:arg.v,
|
|
|
- k:arg.k,
|
|
|
- type: "ParamData",
|
|
|
- };
|
|
|
- fcText += `WP[${arg.k}]`;
|
|
|
+ if (ele.template != null && ele.template != undefined) {
|
|
|
+ let tmpArr = fcReg.exec(ele.template.ft);
|
|
|
+ fcText = tmpArr[1] + fcText;//fc.XX( 左括号部分
|
|
|
+ let argList = tmpArr[2].split(",");//括号里面参数部分#1,#2..
|
|
|
+ let isNestEle = false;//是否有过嵌套的元素了
|
|
|
+ let isNestEle2 = false;
|
|
|
+ //console.log(argList)
|
|
|
+ //console.log(text)
|
|
|
+ argList.forEach((argText,index)=>{
|
|
|
+ if(argText.indexOf('#')>-1){
|
|
|
+ //#动态参数
|
|
|
+ let argIndex = index;
|
|
|
+ for (let j = 0; j < ele.template.args.length; j++) {
|
|
|
+ if(ele.template.args[j].key == argText){
|
|
|
+ //找到相同的#编码
|
|
|
+ argIndex = j;
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- }else if(Array.isArray(arg)){
|
|
|
- //ifsles方法会进来
|
|
|
- arg.forEach((a)=>{
|
|
|
- if(a && isFormulaItem(a)){
|
|
|
- if(!isNestEle2 && i != (children.length-1) && curEle.id == a.id){
|
|
|
- //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
- //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
- isNestEle2 = true
|
|
|
- }else{
|
|
|
- if(a.type == 'Element'){
|
|
|
- eleMap[a.tableElementKey] = {
|
|
|
- id: a.id,
|
|
|
- name: a.name,
|
|
|
- tableElementKey: a.tableElementKey,
|
|
|
- type: "Element",
|
|
|
- };
|
|
|
- fcText += `E[${a.tableElementKey}]`;
|
|
|
- }else if(a.type == 'ParamData'){
|
|
|
- eleMap[a.k] = {
|
|
|
- id: a.id,
|
|
|
- name: a.name,
|
|
|
- v:a.v,
|
|
|
- k:a.k,
|
|
|
- type: "ParamData",
|
|
|
- };
|
|
|
- fcText += `WP[${a.k}]`;
|
|
|
- }
|
|
|
- }
|
|
|
- }else if(a && a.type == 'Operator'){
|
|
|
- //在运算符前后加上空格
|
|
|
- fcText += ' '+a.name+' ';
|
|
|
- //console.log(fcText)
|
|
|
- }else if(a && a.type){
|
|
|
- fcText += a.name;
|
|
|
+ let arg = ele.arguments[argIndex];
|
|
|
+
|
|
|
+ if(arg && isFormulaItem(arg)){
|
|
|
+ if(!isNestEle && !isNestEle2 && i != (children.length-1) && curEle.id == arg.id){
|
|
|
+ //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
+ //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
+ isNestEle = true;
|
|
|
}else{
|
|
|
- fcText += a?a:"''";
|
|
|
+ if(arg.type == 'Element'){
|
|
|
+ eleMap[arg.tableElementKey] = {
|
|
|
+ id: arg.id,
|
|
|
+ name: arg.name,
|
|
|
+ tableElementKey: arg.tableElementKey,
|
|
|
+ type: "Element",
|
|
|
+ };
|
|
|
+ fcText += `E[${arg.tableElementKey}]`;
|
|
|
+ }else if(arg.type == 'ParamData'){
|
|
|
+ eleMap[arg.k] = {
|
|
|
+ id: arg.id,
|
|
|
+ name: arg.name,
|
|
|
+ v:arg.v,
|
|
|
+ k:arg.k,
|
|
|
+ type: "ParamData",
|
|
|
+ };
|
|
|
+ fcText += `WP[${arg.k}]`;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- })
|
|
|
-
|
|
|
+ }else if(Array.isArray(arg)){
|
|
|
+ //ifsles方法会进来
|
|
|
+ arg.forEach((a)=>{
|
|
|
+ if(a && isFormulaItem(a)){
|
|
|
+ if(!isNestEle2 && i != (children.length-1) && curEle.id == a.id){
|
|
|
+ //不是第一个嵌套的公式,且和当前挂载的是同一个元素
|
|
|
+ //认为这个参数是之前公式计算的结果,不再写入元素
|
|
|
+ isNestEle2 = true
|
|
|
+ }else{
|
|
|
+ if(a.type == 'Element'){
|
|
|
+ eleMap[a.tableElementKey] = {
|
|
|
+ id: a.id,
|
|
|
+ name: a.name,
|
|
|
+ tableElementKey: a.tableElementKey,
|
|
|
+ type: "Element",
|
|
|
+ };
|
|
|
+ fcText += `E[${a.tableElementKey}]`;
|
|
|
+ }else if(a.type == 'ParamData'){
|
|
|
+ eleMap[a.k] = {
|
|
|
+ id: a.id,
|
|
|
+ name: a.name,
|
|
|
+ v:a.v,
|
|
|
+ k:a.k,
|
|
|
+ type: "ParamData",
|
|
|
+ };
|
|
|
+ fcText += `WP[${a.k}]`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(a && a.type == 'Operator'){
|
|
|
+ //在运算符前后加上空格
|
|
|
+ fcText += ' '+a.name+' ';
|
|
|
+ //console.log(fcText)
|
|
|
+ }else if(a && a.type){
|
|
|
+ fcText += a.name;
|
|
|
+ }else{
|
|
|
+ fcText += a?a:"''";
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }else{
|
|
|
+ fcText += arg?arg:"''";
|
|
|
+ }
|
|
|
+
|
|
|
}else{
|
|
|
- fcText += arg?arg:"''";
|
|
|
+ //已有参数
|
|
|
+ fcText += argText?argText:'';
|
|
|
}
|
|
|
+ if(index != argList.length-1){
|
|
|
+ fcText += ',';
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ fcText += ')';
|
|
|
+
|
|
|
+ }
|
|
|
+ //console.log(ele.name)
|
|
|
|
|
|
- }else{
|
|
|
- //已有参数
|
|
|
- fcText += argText?argText:'';
|
|
|
- }
|
|
|
- if(index != argList.length-1){
|
|
|
- fcText += ',';
|
|
|
- }
|
|
|
- })
|
|
|
- fcText += ')';
|
|
|
+
|
|
|
}
|
|
|
|
|
|
return fcText;
|
|
|
}
|
|
|
-
|
|
|
export const formulaArrayToString = (processFormula,resultFormula) => {
|
|
|
let text = '';
|
|
|
let eleMap = {};//元素字典,为了回显的时候查询信息
|