|
@@ -38,14 +38,15 @@
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
label="操作"
|
|
label="操作"
|
|
|
align="center"
|
|
align="center"
|
|
|
- width="100">
|
|
|
|
|
|
|
+ width="100"
|
|
|
|
|
+ v-if="!view">
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-button @click="editRow(scope.row, index)" type="text" size="mini">编辑</el-button>
|
|
<el-button @click="editRow(scope.row, index)" type="text" size="mini">编辑</el-button>
|
|
|
<el-button @click="deleteRow(index)" type="text" size="mini">删除</el-button>
|
|
<el-button @click="deleteRow(index)" type="text" size="mini">删除</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
- <div @click="addRow" style="text-align: center;">
|
|
|
|
|
|
|
+ <div v-if="!view" @click="addRow" style="text-align: center;">
|
|
|
<el-button type="text" icon="el-icon-plus">添加</el-button>
|
|
<el-button type="text" icon="el-icon-plus">添加</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
<ele-modal
|
|
<ele-modal
|
|
@@ -171,8 +172,8 @@
|
|
|
</el-card>
|
|
</el-card>
|
|
|
|
|
|
|
|
<div slot="footer">
|
|
<div slot="footer">
|
|
|
- <el-button type="primary" size="small" @click="save">保存</el-button>
|
|
|
|
|
- <el-button size="small" @click="handleClose">关闭</el-button>
|
|
|
|
|
|
|
+ <el-button type="primary" size="small" @click="save">保存</el-button>
|
|
|
|
|
+ <el-button size="small" @click="handleClose">关闭</el-button>
|
|
|
</div>
|
|
</div>
|
|
|
</ele-modal>
|
|
</ele-modal>
|
|
|
<!-- <el-form ref="form" :model="info">
|
|
<!-- <el-form ref="form" :model="info">
|
|
@@ -316,16 +317,21 @@ export default {
|
|
|
type: String,
|
|
type: String,
|
|
|
default: ''
|
|
default: ''
|
|
|
},
|
|
},
|
|
|
|
|
+ view: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
watch: {
|
|
watch: {
|
|
|
info: {
|
|
info: {
|
|
|
handler(newVal, oldVal) {
|
|
handler(newVal, oldVal) {
|
|
|
console.log('info', newVal);
|
|
console.log('info', newVal);
|
|
|
// this.form = JSON.parse(JSON.stringify(newVal));
|
|
// this.form = JSON.parse(JSON.stringify(newVal));
|
|
|
|
|
+ this.tableData = newVal.blank_business_component || [];
|
|
|
},
|
|
},
|
|
|
deep: true,
|
|
deep: true,
|
|
|
immediate: true
|
|
immediate: true
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
const formItem = {
|
|
const formItem = {
|
|
@@ -335,8 +341,7 @@ export default {
|
|
|
endPlace: '',
|
|
endPlace: '',
|
|
|
transportationWay: '',
|
|
transportationWay: '',
|
|
|
price: '',
|
|
price: '',
|
|
|
- remark: '',
|
|
|
|
|
- type: 'add'
|
|
|
|
|
|
|
+ remark: ''
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
form: {},
|
|
form: {},
|
|
@@ -379,35 +384,43 @@ export default {
|
|
|
visible: false,
|
|
visible: false,
|
|
|
currentItem: {},
|
|
currentItem: {},
|
|
|
currentIndex: null,
|
|
currentIndex: null,
|
|
|
|
|
+ type: 'add'
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- console.log('info~~~', this.info);
|
|
|
|
|
- this.initForm();
|
|
|
|
|
|
|
+ // console.log('info~~~', this.info);
|
|
|
|
|
+ // this.initForm();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- async initForm() {
|
|
|
|
|
- let data = await this.generateForm.getData(false);
|
|
|
|
|
- console.log('generateForm~~~', data);
|
|
|
|
|
- data[this.id] = [this.formItem];
|
|
|
|
|
- this.generateForm.setData({
|
|
|
|
|
- [this.id]: data[this.id]
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- async addNewRow() {
|
|
|
|
|
|
|
+ // async initForm() {
|
|
|
|
|
+ // let data = await this.generateForm.getData(false);
|
|
|
|
|
+ // console.log('generateForm~~~', data);
|
|
|
|
|
+ // data[this.id] = [this.formItem];
|
|
|
|
|
+ // this.generateForm.setData({
|
|
|
|
|
+ // [this.id]: data[this.id]
|
|
|
|
|
+ // });
|
|
|
|
|
+ // },
|
|
|
|
|
+ // async addNewRow() {
|
|
|
|
|
+ // let data = await this.generateForm.getData(false);
|
|
|
|
|
+ // console.log(this.id, data[this.id]);
|
|
|
|
|
+ // data[this.id].push(this.formItem);
|
|
|
|
|
+ // this.generateForm.setData({
|
|
|
|
|
+ // [this.id]: data[this.id]
|
|
|
|
|
+ // });
|
|
|
|
|
+ // },
|
|
|
|
|
+ // async delNewRow(index) {
|
|
|
|
|
+ // let data = await this.generateForm.getData(false);
|
|
|
|
|
+ // data[this.id] = data[this.id].filter((item, index1) => index1 != index);
|
|
|
|
|
+ // this.generateForm.setData({
|
|
|
|
|
+ // [this.id]: data[this.id]
|
|
|
|
|
+ // });
|
|
|
|
|
+ // },
|
|
|
|
|
+ async updateRowInfo() {
|
|
|
let data = await this.generateForm.getData(false);
|
|
let data = await this.generateForm.getData(false);
|
|
|
- console.log(this.id, data[this.id]);
|
|
|
|
|
- data[this.id].push(this.formItem);
|
|
|
|
|
this.generateForm.setData({
|
|
this.generateForm.setData({
|
|
|
- [this.id]: data[this.id]
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
- async delNewRow(index) {
|
|
|
|
|
- let data = await this.generateForm.getData(false);
|
|
|
|
|
- data[this.id] = data[this.id].filter((item, index1) => index1 != index);
|
|
|
|
|
- this.generateForm.setData({
|
|
|
|
|
- [this.id]: data[this.id]
|
|
|
|
|
|
|
+ 'blank_business_component': this.tableData
|
|
|
});
|
|
});
|
|
|
|
|
+ console.log('updateRowInfo', this.tableData, data);
|
|
|
},
|
|
},
|
|
|
validateForm() {
|
|
validateForm() {
|
|
|
//开始表单校验
|
|
//开始表单校验
|
|
@@ -439,6 +452,19 @@ export default {
|
|
|
},
|
|
},
|
|
|
delRow(index) {
|
|
delRow(index) {
|
|
|
this.tableData.splice(index, 1);
|
|
this.tableData.splice(index, 1);
|
|
|
|
|
+ this.updateRowInfo();
|
|
|
|
|
+ this.calculateTotalPrice();
|
|
|
|
|
+ },
|
|
|
|
|
+ async calculateTotalPrice() {
|
|
|
|
|
+ let data = await this.generateForm.getData(false);
|
|
|
|
|
+ let totalPrice = 0;
|
|
|
|
|
+ this.tableData.forEach(item => {
|
|
|
|
|
+ totalPrice += Number(item.price);
|
|
|
|
|
+ });
|
|
|
|
|
+ const price = Number(data.input_t2qmoggj);
|
|
|
|
|
+ this.generateForm.setData({
|
|
|
|
|
+ input_a1cnspuk: totalPrice + price
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
async save() {
|
|
async save() {
|
|
|
try {
|
|
try {
|
|
@@ -446,12 +472,15 @@ export default {
|
|
|
console.log('表单验证通过');
|
|
console.log('表单验证通过');
|
|
|
// 深拷贝form对象,避免引用问题
|
|
// 深拷贝form对象,避免引用问题
|
|
|
const newForm = JSON.parse(JSON.stringify(this.form));
|
|
const newForm = JSON.parse(JSON.stringify(this.form));
|
|
|
|
|
+ console.log('newForm', newForm);
|
|
|
if(this.type === 'add') {
|
|
if(this.type === 'add') {
|
|
|
this.tableData.push(newForm);
|
|
this.tableData.push(newForm);
|
|
|
} else {
|
|
} else {
|
|
|
this.tableData[this.currentIndex] = newForm;
|
|
this.tableData[this.currentIndex] = newForm;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ console.log('this.tableData', this.tableData);
|
|
|
|
|
+ this.updateRowInfo()
|
|
|
|
|
+ this.calculateTotalPrice()
|
|
|
this.handleClose(); // 保存后关闭弹窗
|
|
this.handleClose(); // 保存后关闭弹窗
|
|
|
// 重置form
|
|
// 重置form
|
|
|
this.form = {};
|
|
this.form = {};
|