Update EditableCell.vue editComponentProps 参数扩展支持回调函数读取表格行数据
editComponentProps 参数扩展支持回调函数读取表格行数据 可根据行信息灵活配置可编辑单元格参数 editComponentProps: (record) => { return {...}}pull/1164/head
parent
6f060e456a
commit
8db81386cd
|
@ -96,7 +96,11 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const getComponentProps = computed(() => {
|
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 component = unref(getComponent);
|
||||||
const apiSelectProps: Recordable = {};
|
const apiSelectProps: Recordable = {};
|
||||||
if (component === 'ApiSelect') {
|
if (component === 'ApiSelect') {
|
||||||
|
@ -122,8 +126,10 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const getValues = computed(() => {
|
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);
|
const value = unref(currentValueRef);
|
||||||
|
|
||||||
if (editValueMap && isFunction(editValueMap)) {
|
if (editValueMap && isFunction(editValueMap)) {
|
||||||
|
@ -193,7 +199,11 @@
|
||||||
} else if (isString(e) || isBoolean(e) || isNumber(e) || isArray(e)) {
|
} else if (isString(e) || isBoolean(e) || isNumber(e) || isArray(e)) {
|
||||||
currentValueRef.value = 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);
|
if (onChange && isFunction(onChange)) onChange(...arguments);
|
||||||
|
|
||||||
table.emit?.('edit-change', {
|
table.emit?.('edit-change', {
|
||||||
|
@ -316,7 +326,11 @@
|
||||||
|
|
||||||
// only ApiSelect or TreeSelect
|
// only ApiSelect or TreeSelect
|
||||||
function handleOptionsChange(options: LabelValueOptions) {
|
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);
|
const component = unref(getComponent);
|
||||||
if (component === 'ApiTreeSelect') {
|
if (component === 'ApiTreeSelect') {
|
||||||
const { title = 'title', value = 'value', children = 'children' } = replaceFields || {};
|
const { title = 'title', value = 'value', children = 'children' } = replaceFields || {};
|
||||||
|
|
Loading…
Reference in New Issue