Compare commits
No commits in common. "80f4528a886d32c9d019771bb5d529b10ecd1320" and "8907dbd18698b2304fbe0799d5630dfbac756a51" have entirely different histories.
80f4528a88
...
8907dbd186
|
|
@ -33,7 +33,7 @@ function BasicCascader(props) {
|
||||||
if (!onGetNodePathsIsIncludeOneself && selectedOptions) {
|
if (!onGetNodePathsIsIncludeOneself && selectedOptions) {
|
||||||
nodePaths = selectedOptions.slice(0, -1);
|
nodePaths = selectedOptions.slice(0, -1);
|
||||||
}
|
}
|
||||||
return nodePaths || [];
|
return nodePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (value, selectedOptions) => {
|
const handleChange = (value, selectedOptions) => {
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,6 @@ export interface BasicSelectProps extends SelectProps {
|
||||||
idKey?: string;
|
idKey?: string;
|
||||||
/** 占位符 */
|
/** 占位符 */
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
/** 获取 label */
|
|
||||||
onGetLabel?: (label: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,23 @@ function BasicSelect(props) {
|
||||||
...restProps
|
...restProps
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
// const handleSelect = (event) => {
|
||||||
|
// onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// const handleClear = () => {
|
||||||
|
// onGetLabel?.(undefined);
|
||||||
|
// };
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
if (event)
|
if (event)
|
||||||
onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
onGetLabel?.(getLabelName({ list: data, status: event, idKey, nameKey }));
|
||||||
else
|
else
|
||||||
onGetLabel?.("");
|
onGetLabel?.(undefined);
|
||||||
};
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
// <Select placeholder={`请选择${placeholder}`} showSearch allowClear onClear={handleClear} onSelect={handleSelect} {...restProps}>
|
||||||
<Select placeholder={`请选择${placeholder}`} showSearch allowClear onChange={handleChange} {...restProps}>
|
<Select placeholder={`请选择${placeholder}`} showSearch allowClear onChange={handleChange} {...restProps}>
|
||||||
{data.map((item) => {
|
{data.map((item) => {
|
||||||
const value = item[idKey];
|
const value = item[idKey];
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ export interface BasicSelectTreeProps extends TreeSelectProps {
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
/** 控制只能选择到第几级 */
|
/** 控制只能选择到第几级 */
|
||||||
level?: number;
|
level?: number;
|
||||||
/** 获取 label */
|
|
||||||
onGetLabel?: (label: string) => void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,4 +26,4 @@ export interface BasicSelectTreeProps extends TreeSelectProps {
|
||||||
*/
|
*/
|
||||||
declare const BasicSelectTree: FC<BasicSelectTreeProps>;
|
declare const BasicSelectTree: FC<BasicSelectTreeProps>;
|
||||||
|
|
||||||
export default BasicSelectTree;
|
export default BasicSelectTree;
|
||||||
|
|
@ -6,8 +6,7 @@ import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
|
||||||
*/
|
*/
|
||||||
function BasicSelectTree(props) {
|
function BasicSelectTree(props) {
|
||||||
const {
|
const {
|
||||||
onChange,
|
onSelect,
|
||||||
onGetLabel,
|
|
||||||
onGetNodePaths,
|
onGetNodePaths,
|
||||||
onGetNodePathsIsIncludeOneself = true,
|
onGetNodePathsIsIncludeOneself = true,
|
||||||
placeholder = "",
|
placeholder = "",
|
||||||
|
|
@ -29,8 +28,8 @@ function BasicSelectTree(props) {
|
||||||
})
|
})
|
||||||
: treeData;
|
: treeData;
|
||||||
|
|
||||||
const handleChange = (value, label, extra) => {
|
const handleSelect = (value, node, extra) => {
|
||||||
if (value) {
|
if (value.length > 0) {
|
||||||
const parentNodes = getTreeNodePaths({
|
const parentNodes = getTreeNodePaths({
|
||||||
data: treeData,
|
data: treeData,
|
||||||
targetId: value,
|
targetId: value,
|
||||||
|
|
@ -39,13 +38,8 @@ function BasicSelectTree(props) {
|
||||||
isIncludeOneself: onGetNodePathsIsIncludeOneself,
|
isIncludeOneself: onGetNodePathsIsIncludeOneself,
|
||||||
});
|
});
|
||||||
onGetNodePaths?.(parentNodes);
|
onGetNodePaths?.(parentNodes);
|
||||||
onGetLabel?.(parentNodes[parentNodes.length - 1][nameKey]);
|
|
||||||
}
|
}
|
||||||
else {
|
onSelect?.(value, node, extra);
|
||||||
onGetNodePaths?.([]);
|
|
||||||
onGetLabel?.("");
|
|
||||||
}
|
|
||||||
onChange?.(value, label, extra);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -56,7 +50,7 @@ function BasicSelectTree(props) {
|
||||||
popup: { root: { maxHeight: 400, overflow: "auto" } },
|
popup: { root: { maxHeight: 400, overflow: "auto" } },
|
||||||
}}
|
}}
|
||||||
placeholder={`请选择${placeholder}`}
|
placeholder={`请选择${placeholder}`}
|
||||||
onChange={handleChange}
|
onSelect={handleSelect}
|
||||||
allowClear
|
allowClear
|
||||||
treeData={processedTreeData}
|
treeData={processedTreeData}
|
||||||
fieldNames={{ label: nameKey, value: idKey, children: childrenKey }}
|
fieldNames={{ label: nameKey, value: idKey, children: childrenKey }}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "zy-react-library",
|
"name": "zy-react-library",
|
||||||
"private": false,
|
"private": false,
|
||||||
"version": "1.0.55",
|
"version": "1.0.54",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "",
|
"description": "",
|
||||||
"author": "LiuJiaNan",
|
"author": "LiuJiaNan",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue