mirror of
https://github.com/vbenjs/vben-admin-thin-next.git
synced 2025-01-24 02:00:22 +08:00
fix(table): fix unsuccessful saving of row edit table (#117)
Co-authored-by: heresy <Heresy@chxian.com>
This commit is contained in:
parent
59ad82442b
commit
404db2fb49
@ -7,7 +7,7 @@ import { RenderEditableCellParams } from '../types/table';
|
||||
import { ComponentType } from '../types/componentType';
|
||||
|
||||
import { componentMap } from '../componentMap';
|
||||
import { isString, isBoolean } from '/@/utils/is';
|
||||
import { isString, isBoolean, isArray } from '/@/utils/is';
|
||||
import { FormOutlined, CloseOutlined, CheckOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
const prefixCls = 'editable-cell';
|
||||
@ -50,6 +50,7 @@ const EditableCell = defineComponent({
|
||||
},
|
||||
placeholder: {
|
||||
type: String as PropType<string>,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
emits: ['submit', 'cancel'],
|
||||
@ -92,9 +93,22 @@ const EditableCell = defineComponent({
|
||||
|
||||
if (props.record) {
|
||||
/* eslint-disable */
|
||||
props.record.onCancel = handleCancel;
|
||||
isArray(props.record.submitCbs)
|
||||
? props.record.submitCbs.push(handleSubmit)
|
||||
: (props.record.submitCbs = [handleSubmit]);
|
||||
/* eslint-disable */
|
||||
isArray(props.record.cancelCbs)
|
||||
? props.record.cancelCbs.push(handleCancel)
|
||||
: (props.record.cancelCbs = [handleCancel]);
|
||||
|
||||
/* eslint-disable */
|
||||
props.record.onCancel = () => {
|
||||
isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn());
|
||||
};
|
||||
/* eslint-disable */
|
||||
props.record.onSubmit = handleSubmit;
|
||||
props.record.onSubmit = () => {
|
||||
isArray(props.record?.submitCbs) && props.record?.submitCbs.forEach((fn) => fn());
|
||||
};
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
@ -222,4 +236,6 @@ export type EditRecordRow<T = { [key: string]: any }> = {
|
||||
editable: boolean;
|
||||
onCancel: Fn;
|
||||
onSubmit: Fn;
|
||||
submitCbs: Fn[];
|
||||
cancelCbs: Fn[];
|
||||
} & T;
|
||||
|
Loading…
Reference in New Issue
Block a user