提交 a0681cca 编写于 作者: V vben

fix(demo): fix demo error

上级 09c9f8a8
......@@ -41,12 +41,14 @@ export function renderEditCell(column: BasicColumn) {
};
}
export type EditRecordRow<T = Hash<any>> = {
onEdit: (editable: boolean, submit?: boolean) => Promise<boolean>;
editable: boolean;
onCancel: Fn;
onSubmit: Fn;
submitCbs: Fn[];
cancelCbs: Fn[];
validCbs: Fn[];
} & T;
export type EditRecordRow<T = Hash<any>> = Partial<
{
onEdit: (editable: boolean, submit?: boolean) => Promise<boolean>;
editable: boolean;
onCancel: Fn;
onSubmit: Fn;
submitCbs: Fn[];
cancelCbs: Fn[];
validCbs: Fn[];
} & T
>;
......@@ -16,7 +16,6 @@
TableAction,
BasicColumn,
ActionItem,
renderEditableRow,
EditTableHeaderIcon,
EditRecordRow,
} from '/@/components/Table';
......@@ -25,17 +24,21 @@
{
title: '成员姓名',
dataIndex: 'name',
customRender: renderEditableRow({ dataIndex: 'name', placeholder: '请输入成员姓名' }),
editRow: true,
},
{
title: '工号',
dataIndex: 'no',
customRender: renderEditableRow({ dataIndex: 'no', placeholder: '请输入工号' }),
editRow: true,
// customRender: renderEditableRow({ dataIndex: 'no', placeholder: '请输入工号' }),
},
{
title: '所属部门',
dataIndex: 'dept',
customRender: renderEditableRow({ dataIndex: 'dept', placeholder: '请输入所属部门' }),
editRow: true,
// customRender: renderEditableRow({ dataIndex: 'dept', placeholder: '请输入所属部门' }),
},
];
......@@ -73,12 +76,11 @@
});
function handleEdit(record: EditRecordRow) {
record.editable = true;
record.onEdit?.(true);
}
function handleCancel(record: EditRecordRow) {
record.editable = false;
record.onCancel && record.onCancel();
record.onEdit?.(false);
if (record.isNew) {
const data = getDataSource();
const index = data.findIndex((item) => item.key === record.key);
......@@ -87,8 +89,7 @@
}
function handleSave(record: EditRecordRow) {
record.editable = false;
record.onSubmit && record.onSubmit();
record.onEdit?.(false, true);
}
function handleAdd() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册