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 = {
text: string;
value: string;
children: string;
text?: string;
value?: string;
children?: string;
};
export default createComponent({

View File

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

View File

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