Compare commits

..

No commits in common. "80f4528a886d32c9d019771bb5d529b10ecd1320" and "8907dbd18698b2304fbe0799d5630dfbac756a51" have entirely different histories.

6 changed files with 19 additions and 20 deletions

View File

@ -33,7 +33,7 @@ function BasicCascader(props) {
if (!onGetNodePathsIsIncludeOneself && selectedOptions) {
nodePaths = selectedOptions.slice(0, -1);
}
return nodePaths || [];
return nodePaths;
};
const handleChange = (value, selectedOptions) => {

View File

@ -13,8 +13,6 @@ export interface BasicSelectProps extends SelectProps {
idKey?: string;
/** 占位符 */
placeholder?: string;
/** 获取 label */
onGetLabel?: (label: string) => void;
}
/**

View File

@ -14,14 +14,23 @@ function BasicSelect(props) {
...restProps
} = props;
// const handleSelect = (event) => {
// onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
// };
//
// const handleClear = () => {
// onGetLabel?.(undefined);
// };
const handleChange = (event) => {
if (event)
onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
else
onGetLabel?.("");
};
onGetLabel?.(undefined);
}
return (
// <Select placeholder={`请选择${placeholder}`} showSearch allowClear onClear={handleClear} onSelect={handleSelect} {...restProps}>
<Select placeholder={`请选择${placeholder}`} showSearch allowClear onChange={handleChange} {...restProps}>
{data.map((item) => {
const value = item[idKey];

View File

@ -19,8 +19,6 @@ export interface BasicSelectTreeProps extends TreeSelectProps {
placeholder?: string;
/** 控制只能选择到第几级 */
level?: number;
/** 获取 label */
onGetLabel?: (label: string) => void;
}
/**
@ -28,4 +26,4 @@ export interface BasicSelectTreeProps extends TreeSelectProps {
*/
declare const BasicSelectTree: FC<BasicSelectTreeProps>;
export default BasicSelectTree;
export default BasicSelectTree;

View File

@ -6,8 +6,7 @@ import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
*/
function BasicSelectTree(props) {
const {
onChange,
onGetLabel,
onSelect,
onGetNodePaths,
onGetNodePathsIsIncludeOneself = true,
placeholder = "",
@ -29,8 +28,8 @@ function BasicSelectTree(props) {
})
: treeData;
const handleChange = (value, label, extra) => {
if (value) {
const handleSelect = (value, node, extra) => {
if (value.length > 0) {
const parentNodes = getTreeNodePaths({
data: treeData,
targetId: value,
@ -39,13 +38,8 @@ function BasicSelectTree(props) {
isIncludeOneself: onGetNodePathsIsIncludeOneself,
});
onGetNodePaths?.(parentNodes);
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);
}
else {
onGetNodePaths?.([]);
onGetLabel?.("");
}
onChange?.(value, label, extra);
onSelect?.(value, node, extra);
};
return (
@ -56,7 +50,7 @@ function BasicSelectTree(props) {
popup: { root: { maxHeight: 400, overflow: "auto" } },
}}
placeholder={`请选择${placeholder}`}
onChange={handleChange}
onSelect={handleSelect}
allowClear
treeData={processedTreeData}
fieldNames={{ label: nameKey, value: idKey, children: childrenKey }}

View File

@ -1,7 +1,7 @@
{
"name": "zy-react-library",
"private": false,
"version": "1.0.55",
"version": "1.0.54",
"type": "module",
"description": "",
"author": "LiuJiaNan",