优化Select
parent
1107ecee47
commit
47b4f23b6d
|
|
@ -14,7 +14,7 @@ export interface BasicSelectProps extends SelectProps {
|
|||
/** 占位符 */
|
||||
placeholder?: string;
|
||||
/** 获取 label */
|
||||
onGetLabel?: (label: string) => void;
|
||||
onGetLabel?: (label: string | string[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Record<string, any>[]) => void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,10 +18,24 @@ function BasicSelect(props) {
|
|||
} = props;
|
||||
|
||||
const handleChange = (event, option) => {
|
||||
if (Array.isArray(event)) {
|
||||
if (event.length > 0) {
|
||||
const name = [];
|
||||
event.forEach((item) => {
|
||||
name.push(getLabelName({ list: data, status: item, idKey, nameKey }));
|
||||
});
|
||||
onGetLabel?.(name);
|
||||
}
|
||||
else {
|
||||
onGetLabel?.([]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (event)
|
||||
onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
||||
else
|
||||
onGetLabel?.("");
|
||||
}
|
||||
onChange?.(event, option);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue