|
|
@@ -104,6 +104,7 @@
|
|
|
disabled
|
|
|
></el-input>
|
|
|
<el-button type="primary" @click="setEquation">配置公式</el-button>
|
|
|
+ <el-button type="primary" @click="delEquation">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-card>
|
|
|
@@ -261,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) => {
|
|
|
@@ -303,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 = [];
|
|
|
@@ -311,8 +318,9 @@
|
|
|
JSON.stringify(this.domObj.equation)
|
|
|
);
|
|
|
this.equationUnit.activeIndex = this.domObj.equation.length;
|
|
|
+ } else {
|
|
|
+ this.equationUnit.equation = [];
|
|
|
}
|
|
|
-
|
|
|
this.list.forEach((item) => {
|
|
|
if (item.type == 'customText') {
|
|
|
for (let key in item.valueObj) {
|
|
|
@@ -328,6 +336,10 @@
|
|
|
});
|
|
|
this.visible = true;
|
|
|
},
|
|
|
+ delEquation() {
|
|
|
+ this.equationUnit.equation = [];
|
|
|
+ this.editInputChange('equation');
|
|
|
+ },
|
|
|
tagItemDelete(index) {
|
|
|
this.equationUnit.equation.splice(index, 1);
|
|
|
},
|
|
|
@@ -393,6 +405,7 @@
|
|
|
init(list) {
|
|
|
this.list = JSON.parse(list);
|
|
|
if (this.list.length) {
|
|
|
+ // this.list[0].id="ozFSPs"
|
|
|
this.$nextTick(() => {
|
|
|
this.list.forEach((item) => {
|
|
|
this.$refs['customTextRef' + item.id][0].init({
|
|
|
@@ -406,7 +419,6 @@
|
|
|
},
|
|
|
editShowFn({ templateDivRef, domObj }) {
|
|
|
this.templateDivRef = templateDivRef;
|
|
|
- console.log(domObj, 'domObj');
|
|
|
this.$set(this, 'domObj', domObj);
|
|
|
this.editShow = true;
|
|
|
},
|
|
|
@@ -434,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);
|