types(Cascader): fieldNames should be optional

This commit is contained in:
chenjiahan 2021-02-12 13:03:04 +08:00
parent ba69a212ba
commit 7e330109b3
3 changed files with 9 additions and 9 deletions

View File

@ -22,9 +22,9 @@ type CascaderTab = {
}; };
type CascaderFieldNames = { type CascaderFieldNames = {
text: string; text?: string;
value: string; value?: string;
children: string; children?: string;
}; };
export default createComponent({ export default createComponent({

View File

@ -38,7 +38,7 @@ export type PickerOption =
[key: string]: any; [key: string]: any;
}; };
export type PickerStringColumn = string[]; export type PickerPlainColumn = PickerOption[];
export type PickerObjectColumn = { export type PickerObjectColumn = {
values?: PickerOption[]; values?: PickerOption[];
@ -49,7 +49,7 @@ export type PickerObjectColumn = {
[key: string]: any; [key: string]: any;
}; };
export type PickerColumn = PickerStringColumn | PickerObjectColumn; export type PickerColumn = PickerPlainColumn | PickerObjectColumn;
function isOptionDisabled(option: PickerOption) { function isOptionDisabled(option: PickerOption) {
return isObject(option) && option.disabled; return isObject(option) && option.disabled;

View File

@ -83,7 +83,7 @@ export default createComponent({
return 'object'; return 'object';
} }
} }
return 'text'; return 'plain';
}); });
const formatCascade = () => { const formatCascade = () => {
@ -121,7 +121,7 @@ export default createComponent({
const format = () => { const format = () => {
const { columns } = props; const { columns } = props;
if (dataType.value === 'text') { if (dataType.value === 'plain') {
formattedColumns.value = [{ [valuesKey]: columns }]; formattedColumns.value = [{ [valuesKey]: columns }];
} else if (dataType.value === 'cascade') { } else if (dataType.value === 'cascade') {
formatCascade(); formatCascade();
@ -225,7 +225,7 @@ export default createComponent({
}; };
const emitAction = (event: 'confirm' | 'cancel') => { const emitAction = (event: 'confirm' | 'cancel') => {
if (dataType.value === 'text') { if (dataType.value === 'plain') {
emit(event, getColumnValue(0), getColumnIndex(0)); emit(event, getColumnValue(0), getColumnIndex(0));
} else { } else {
emit(event, getValues(), getIndexes()); emit(event, getValues(), getIndexes());
@ -237,7 +237,7 @@ export default createComponent({
onCascadeChange(columnIndex); onCascadeChange(columnIndex);
} }
if (dataType.value === 'text') { if (dataType.value === 'plain') {
emit('change', getColumnValue(0), getColumnIndex(0)); emit('change', getColumnValue(0), getColumnIndex(0));
} else { } else {
emit('change', getValues(), columnIndex); emit('change', getValues(), columnIndex);