fix: EditableCell about checked/unChecked Value, getDisable, rowKey missing for updating (#3418). resolve #3419
This commit is contained in:
parent
d502e1d493
commit
404a4720b0
|
|
@ -66,13 +66,23 @@
|
||||||
|
|
||||||
const getComponentProps = computed(() => {
|
const getComponentProps = computed(() => {
|
||||||
const isCheckValue = unref(getIsCheckComp);
|
const isCheckValue = unref(getIsCheckComp);
|
||||||
|
let compProps = props.column?.editComponentProps ?? ({} as any);
|
||||||
|
const { checkedValue, unCheckedValue } = compProps;
|
||||||
|
|
||||||
const valueField = isCheckValue ? 'checked' : 'value';
|
const valueField = isCheckValue ? 'checked' : 'value';
|
||||||
const val = unref(currentValueRef);
|
const val = unref(currentValueRef);
|
||||||
|
|
||||||
const value = isCheckValue ? (isNumber(val) || isBoolean(val) ? val : !!val) : val;
|
let value = val;
|
||||||
|
if (isCheckValue) {
|
||||||
|
if (typeof checkedValue !== 'undefined') {
|
||||||
|
value = val === checkedValue ? checkedValue : unCheckedValue;
|
||||||
|
} else if (typeof unCheckedValue !== 'undefined') {
|
||||||
|
value = val === unCheckedValue ? unCheckedValue : checkedValue;
|
||||||
|
} else {
|
||||||
|
value = isNumber(val) || isBoolean(val) ? val : !!val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let compProps = props.column?.editComponentProps ?? ({} as any);
|
|
||||||
const { record, column, index } = props;
|
const { record, column, index } = props;
|
||||||
|
|
||||||
if (isFunction(compProps)) {
|
if (isFunction(compProps)) {
|
||||||
|
|
@ -114,7 +124,7 @@
|
||||||
}
|
}
|
||||||
if (isFunction(editDynamicDisabled)) {
|
if (isFunction(editDynamicDisabled)) {
|
||||||
const { record } = props;
|
const { record } = props;
|
||||||
disabled = editDynamicDisabled({ record });
|
disabled = editDynamicDisabled({ record, currentValue: currentValueRef.value });
|
||||||
}
|
}
|
||||||
return disabled;
|
return disabled;
|
||||||
});
|
});
|
||||||
|
|
@ -170,7 +180,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleEdit() {
|
function handleEdit() {
|
||||||
if (unref(getRowEditable) || unref(props.column?.editRow)) return;
|
if (unref(getRowEditable) || unref(props.column?.editRow) || unref(getDisable)) return;
|
||||||
ruleMessage.value = '';
|
ruleMessage.value = '';
|
||||||
isEdit.value = true;
|
isEdit.value = true;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
|
|
@ -248,17 +258,19 @@
|
||||||
if (!record.editable) {
|
if (!record.editable) {
|
||||||
const { getBindValues } = table;
|
const { getBindValues } = table;
|
||||||
|
|
||||||
const { beforeEditSubmit, columns } = unref(getBindValues);
|
const { beforeEditSubmit, columns, rowKey } = unref(getBindValues);
|
||||||
|
const rowKeyValue = typeof rowKey === 'string' ? rowKey : rowKey ? rowKey(record) : '';
|
||||||
|
|
||||||
if (beforeEditSubmit && isFunction(beforeEditSubmit)) {
|
if (beforeEditSubmit && isFunction(beforeEditSubmit)) {
|
||||||
spinning.value = true;
|
spinning.value = true;
|
||||||
const keys: string[] = columns
|
const keys: string[] = columns
|
||||||
.map((_column) => _column.dataIndex)
|
.map((_column) => _column.dataIndex)
|
||||||
.filter((field) => !!field) as string[];
|
.filter((field) => !!field) as string[];
|
||||||
|
|
||||||
let result: any = true;
|
let result: any = true;
|
||||||
try {
|
try {
|
||||||
result = await beforeEditSubmit({
|
result = await beforeEditSubmit({
|
||||||
record: pick(record, keys),
|
record: pick(record, [rowKeyValue, ...keys]),
|
||||||
index,
|
index,
|
||||||
key: dataKey as string,
|
key: dataKey as string,
|
||||||
value,
|
value,
|
||||||
|
|
@ -391,6 +403,7 @@
|
||||||
handleEnter,
|
handleEnter,
|
||||||
handleSubmitClick,
|
handleSubmitClick,
|
||||||
spinning,
|
spinning,
|
||||||
|
getDisable,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -408,10 +421,13 @@
|
||||||
record: this.record as Recordable,
|
record: this.record as Recordable,
|
||||||
column: this.column,
|
column: this.column,
|
||||||
index: this.index,
|
index: this.index,
|
||||||
|
currentValue: this.currentValueRef,
|
||||||
})
|
})
|
||||||
: this.getValues ?? '\u00A0'}
|
: this.getValues ?? '\u00A0'}
|
||||||
</div>
|
</div>
|
||||||
{!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />}
|
{!this.column.editRow && !this.getDisable && (
|
||||||
|
<FormOutlined class={`${this.prefixCls}__normal-icon`} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{this.isEdit && (
|
{this.isEdit && (
|
||||||
<Spin spinning={this.spinning}>
|
<Spin spinning={this.spinning}>
|
||||||
|
|
|
||||||
|
|
@ -472,6 +472,7 @@ export interface BasicColumn extends ColumnProps<Recordable> {
|
||||||
record: Recordable;
|
record: Recordable;
|
||||||
column: BasicColumn;
|
column: BasicColumn;
|
||||||
index: number;
|
index: number;
|
||||||
|
currentValue: string | number | boolean | Recordable;
|
||||||
}) => VNodeChild | JSX.Element;
|
}) => VNodeChild | JSX.Element;
|
||||||
// 动态 Disabled
|
// 动态 Disabled
|
||||||
editDynamicDisabled?: boolean | ((record: Recordable) => boolean);
|
editDynamicDisabled?: boolean | ((record: Recordable) => boolean);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue