|
@@ -335,7 +335,8 @@ export default {
|
|
|
endPlace: '',
|
|
endPlace: '',
|
|
|
transportationWay: '',
|
|
transportationWay: '',
|
|
|
price: '',
|
|
price: '',
|
|
|
- remark: ''
|
|
|
|
|
|
|
+ remark: '',
|
|
|
|
|
+ type: 'add'
|
|
|
}
|
|
}
|
|
|
return {
|
|
return {
|
|
|
form: {},
|
|
form: {},
|
|
@@ -421,6 +422,7 @@ export default {
|
|
|
});
|
|
});
|
|
|
},
|
|
},
|
|
|
addRow() {
|
|
addRow() {
|
|
|
|
|
+ this.type = 'add';
|
|
|
this.visible = true;
|
|
this.visible = true;
|
|
|
|
|
|
|
|
},
|
|
},
|
|
@@ -428,11 +430,15 @@ export default {
|
|
|
this.visible = false;
|
|
this.visible = false;
|
|
|
},
|
|
},
|
|
|
editRow(row, index) {
|
|
editRow(row, index) {
|
|
|
|
|
+ this.type = 'edit';
|
|
|
console.log('编辑行', row, index);
|
|
console.log('编辑行', row, index);
|
|
|
this.currentItem = row;
|
|
this.currentItem = row;
|
|
|
this.currentIndex = index;
|
|
this.currentIndex = index;
|
|
|
this.visible = true;
|
|
this.visible = true;
|
|
|
- // this.form = JSON.parse(JSON.stringify(row));
|
|
|
|
|
|
|
+ this.form = JSON.parse(JSON.stringify(row));
|
|
|
|
|
+ },
|
|
|
|
|
+ delRow(index) {
|
|
|
|
|
+ this.tableData.splice(index, 1);
|
|
|
},
|
|
},
|
|
|
async save() {
|
|
async save() {
|
|
|
try {
|
|
try {
|
|
@@ -440,7 +446,12 @@ export default {
|
|
|
console.log('表单验证通过');
|
|
console.log('表单验证通过');
|
|
|
// 深拷贝form对象,避免引用问题
|
|
// 深拷贝form对象,避免引用问题
|
|
|
const newForm = JSON.parse(JSON.stringify(this.form));
|
|
const newForm = JSON.parse(JSON.stringify(this.form));
|
|
|
- this.tableData.push(newForm);
|
|
|
|
|
|
|
+ if(this.type === 'add') {
|
|
|
|
|
+ this.tableData.push(newForm);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.tableData[this.currentIndex] = newForm;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.handleClose(); // 保存后关闭弹窗
|
|
this.handleClose(); // 保存后关闭弹窗
|
|
|
// 重置form
|
|
// 重置form
|
|
|
this.form = {};
|
|
this.form = {};
|