|
|
@@ -262,27 +262,16 @@
|
|
|
// 计算
|
|
|
calculation() {
|
|
|
this.getValue();
|
|
|
- let data = {};
|
|
|
let equation = [];
|
|
|
this.list.forEach((item) => {
|
|
|
- if (item.type == 'customText') {
|
|
|
- data = { ...item.valueObj, ...data };
|
|
|
- } else {
|
|
|
- item.valueObj.rows.forEach((row) => {
|
|
|
- row.cells.forEach((cell) => {
|
|
|
- data[cell.id] = cell.value;
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
equation.push({
|
|
|
id: item.id,
|
|
|
equation: item.equation
|
|
|
});
|
|
|
});
|
|
|
equation.forEach((item) => {
|
|
|
- console.log(item.equation);
|
|
|
-
|
|
|
for (const key in item.equation) {
|
|
|
+ let data=this.getObjValue() //每次计算都获取最新的值
|
|
|
let value = '';
|
|
|
if (item.equation[key].length) {
|
|
|
item.equation[key].forEach((equationItem) => {
|
|
|
@@ -304,6 +293,23 @@
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ getObjValue() {
|
|
|
+ this.getValue();
|
|
|
+ let data = {};
|
|
|
+ this.list.forEach((item) => {
|
|
|
+ if (item.type == 'customText') {
|
|
|
+ data = { ...item.valueObj, ...data };
|
|
|
+ } else {
|
|
|
+ item.valueObj.rows.forEach((row) => {
|
|
|
+ row.cells.forEach((cell) => {
|
|
|
+ data[cell.id] = cell.value;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return data || {};
|
|
|
+ },
|
|
|
+
|
|
|
setEquation() {
|
|
|
this.getValue();
|
|
|
this.idList = [];
|
|
|
@@ -413,7 +419,6 @@
|
|
|
},
|
|
|
editShowFn({ templateDivRef, domObj }) {
|
|
|
this.templateDivRef = templateDivRef;
|
|
|
- console.log(domObj, 'domObj');
|
|
|
this.$set(this, 'domObj', domObj);
|
|
|
this.editShow = true;
|
|
|
},
|
|
|
@@ -441,7 +446,6 @@
|
|
|
},
|
|
|
getValue() {
|
|
|
this.list.forEach((item, index) => {
|
|
|
- console.log(item);
|
|
|
let { form, valueObj, equation } =
|
|
|
this.$refs['customTextRef' + item.id][0].getValue();
|
|
|
this.$set(this.list[index], 'value', form);
|