Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EditableCell.vue editComponentProps 参数扩展支持回调函数读取表格行数据 #1164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/components/Table/src/components/editable/EditableCell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@
});

const getComponentProps = computed(() => {
const compProps = props.column?.editComponentProps ?? {};
let editComponentProps = props.column?.editComponentProps ?? {};
if (isFunction(editComponentProps)) {
editComponentProps = editComponentProps(props.record as Recordable);
}
const compProps = editComponentProps;
const component = unref(getComponent);
const apiSelectProps: Recordable = {};
if (component === 'ApiSelect') {
Expand All @@ -122,8 +126,10 @@
});

const getValues = computed(() => {
const { editComponentProps, editValueMap } = props.column;

let { editComponentProps, editValueMap } = props.column;
if (editComponentProps && isFunction(editComponentProps)) {
editComponentProps = editComponentProps(props.record as Recordable);
}
const value = unref(currentValueRef);

if (editValueMap && isFunction(editValueMap)) {
Expand Down Expand Up @@ -193,7 +199,11 @@
} else if (isString(e) || isBoolean(e) || isNumber(e) || isArray(e)) {
currentValueRef.value = e;
}
const onChange = props.column?.editComponentProps?.onChange;
let editComponentProps = props.column?.editComponentProps ?? {};
if (isFunction(editComponentProps)) {
editComponentProps = editComponentProps(props.record as Recordable);
}
const onChange = editComponentProps?.onChange;
if (onChange && isFunction(onChange)) onChange(...arguments);

table.emit?.('edit-change', {
Expand Down Expand Up @@ -316,7 +326,11 @@

// only ApiSelect or TreeSelect
function handleOptionsChange(options: LabelValueOptions) {
const { replaceFields } = props.column?.editComponentProps ?? {};
let editComponentProps = props.column?.editComponentProps ?? {};
if (isFunction(editComponentProps)) {
editComponentProps = editComponentProps(props.record as Recordable);
}
const { replaceFields } = editComponentProps;
const component = unref(getComponent);
if (component === 'ApiTreeSelect') {
const { title = 'title', value = 'value', children = 'children' } = replaceFields || {};
Expand Down