Skip to content

Commit

Permalink
fix: 修复子表单bug @0.9.1-3
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 17, 2021
1 parent 3f9892b commit f810d9c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.9.1-2",
"version": "0.9.1-3",
"author": "BoBo<[email protected]>",
"main": "lib/ProCrud.umd.min.js",
"files": [
Expand Down
4 changes: 0 additions & 4 deletions src/component/form-designer/src/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ import { formElement } from './componentsConfig';
AvatarUpload,
CrudTable: () => import('@/component/crud-table/src/CrudTable.vue'),
},
model: {
prop: 'value',
event: 'change',
},
name: 'GenerateFormItem',
})
export default class GenerateFormItem extends Vue {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<!--
* @file: 子表单
* GenerateFormItem如果想拿到整个子表单所有行数据改写如下
* v-model="subTableForm.tableData[scope.$index][row.model]"
* <el-form :model="subTableForm"></el-form>
* @author: BoBo
* @copyright: BoBo
Expand All @@ -20,7 +19,7 @@
<template v-if="readOnly || scope.row._mode === 'DETAIL'">
<span>{{ scope.row[row.model] }}</span>
</template>
<GenerateFormItem v-else :remote="remote" :model="scope.row[row.model]" v-model="inlineFormData[row.model]" :widget="row" :readOnly="readOnly || row._mode === 'DETAIL' ? {} : null" />
<GenerateFormItem v-else :remote="remote" :models="inlineFormData" :widget="row" :readOnly="readOnly || row._mode === 'DETAIL' ? {} : null" />
</template>
</el-table-column>
<el-table-column label="操作" header-align="center" :width="100">
Expand Down Expand Up @@ -151,11 +150,11 @@ export default class GenerateSubForm extends Vue {
return;
}
this.mode = 'ADD';
this.inlineFormData = {};
const [obj] = this.widget.tableColumns.map(item => ({
[item.model]: item.options.defaultValue || '',
_mode: 'ADD',
}));
this.inlineFormData = obj;
(this.subTableForm.tableData as any).push(obj);
}

Expand All @@ -168,19 +167,11 @@ export default class GenerateSubForm extends Vue {
.then(() => {
const promise = this.$PROCRUD.crud(DML.DELETE, this.widget.options.tableName, {}, { id: row.id });
promise.then(() => {
this.remote[this.widget.options.remoteFunc]((data) => {
if (Array.isArray(data)) {
if (data.length === 0) {
this.addRow();
} else {
(this.subTableForm.tableData as any) = data;
}
}
});
this.$message({
type: 'success',
message: '删除成功',
});
this.fetchList();
});
})
.catch(() => {
Expand Down Expand Up @@ -228,7 +219,6 @@ export default class GenerateSubForm extends Vue {
formValue[k] = this.getTablePrefill[k];
});
}

// 根据对话框状态判断保存或编辑
if (formValue._mode === 'ADD') {
type = DML.INSERT;
Expand Down

0 comments on commit f810d9c

Please sign in to comment.