zy-react-library 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/components/Cascader/Area/index.js +11 -11
- package/components/Cascader/Basic/index.js +23 -30
- package/components/Cascader/Dictionary/index.js +42 -42
- package/components/Cascader/Industry/index.js +12 -11
- package/components/Editor/index.js +43 -63
- package/components/FormBuilder/FormBuilder.js +97 -87
- package/components/FormBuilder/FormItemsRenderer.js +579 -581
- package/components/FormBuilder/index.js +5 -3
- package/components/HeaderBack/index.js +39 -32
- package/components/HiddenInfo/gwj/index.js +507 -439
- package/components/Icon/AddIcon/index.js +6 -6
- package/components/Icon/BackIcon/index.js +6 -6
- package/components/Icon/DeleteIcon/index.js +6 -6
- package/components/Icon/DownloadIcon/index.js +6 -6
- package/components/Icon/EditIcon/index.js +6 -6
- package/components/Icon/ExportIcon/index.js +6 -6
- package/components/Icon/ImportIcon/index.js +6 -6
- package/components/Icon/LocationIcon/index.js +6 -6
- package/components/Icon/PrintIcon/index.js +6 -6
- package/components/Icon/ResetIcon/index.js +6 -6
- package/components/Icon/SearchIcon/index.js +6 -6
- package/components/Icon/VideoIcon/index.js +6 -6
- package/components/Icon/ViewIcon/index.js +6 -6
- package/components/ImportFile/index.js +94 -91
- package/components/LeftTree/Area/index.js +15 -15
- package/components/LeftTree/Basic/index.js +54 -65
- package/components/LeftTree/Department/Gwj/index.js +29 -32
- package/components/LeftTree/Dictionary/index.js +42 -42
- package/components/Map/MapSelector.js +280 -254
- package/components/Map/index.js +90 -77
- package/components/Page/index.d.ts +2 -0
- package/components/Page/index.js +44 -34
- package/components/Pdf/index.js +92 -90
- package/components/PreviewImg/index.js +26 -32
- package/components/PreviewPdf/index.js +78 -86
- package/components/Search/index.js +147 -141
- package/components/Select/Basic/index.js +70 -76
- package/components/Select/Dictionary/index.js +42 -42
- package/components/Select/Personnel/Gwj/index.js +45 -49
- package/components/SelectCreate/index.js +33 -40
- package/components/SelectTree/Area/index.js +11 -17
- package/components/SelectTree/Basic/index.js +105 -102
- package/components/SelectTree/Department/Gwj/index.js +40 -46
- package/components/SelectTree/Dictionary/index.js +42 -42
- package/components/SelectTree/HiddenLevel/Gwj/index.js +33 -35
- package/components/SelectTree/HiddenPart/Gwj/index.js +16 -19
- package/components/SelectTree/Industry/index.js +12 -18
- package/components/Signature/index.js +68 -62
- package/components/Table/index.js +77 -73
- package/components/Table/index.less +7 -1
- package/components/TooltipPreviewImg/index.js +28 -27
- package/components/Upload/index.js +229 -275
- package/components/Video/AliPlayer.js +182 -160
- package/components/Video/index.js +71 -90
- package/css/common.less +4 -0
- package/enum/dictionary/index.js +5 -3
- package/enum/formItemRender/index.js +37 -35
- package/enum/hidden/gwj/index.js +65 -26
- package/enum/uploadFile/gwj/index.js +166 -84
- package/hooks/useDeleteFile/index.js +24 -30
- package/hooks/useDictionary/index.js +28 -30
- package/hooks/useDownloadBlob/index.js +78 -77
- package/hooks/useDownloadFile/index.js +76 -79
- package/hooks/useGetFile/index.js +32 -32
- package/hooks/useGetUrlQuery/index.js +1 -2
- package/hooks/useGetUserInfo/index.js +19 -26
- package/hooks/useIdle/index.js +9 -11
- package/hooks/useImportFile/index.js +30 -28
- package/hooks/useIsExistenceDuplicateSelection/index.js +25 -18
- package/hooks/useTable/index.js +49 -38
- package/hooks/useUploadFile/index.js +142 -147
- package/hooks/useUrlQueryCriteria/index.js +20 -13
- package/package.json +14 -1
- package/regular/index.js +34 -39
- package/utils/index.js +515 -511
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PlusOutlined } from
|
|
2
|
-
|
|
3
|
-
const AddIcon = props => (
|
|
4
|
-
<PlusOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { PlusOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const AddIcon = props => /*#__PURE__*/jsx(PlusOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
AddIcon.displayName = "AddIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { AddIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ArrowLeftOutlined } from
|
|
2
|
-
|
|
3
|
-
const BackIcon = props => (
|
|
4
|
-
<ArrowLeftOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { ArrowLeftOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const BackIcon = props => /*#__PURE__*/jsx(ArrowLeftOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
BackIcon.displayName = "BackIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { BackIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DeleteOutlined } from
|
|
2
|
-
|
|
3
|
-
const DeleteIcon = props => (
|
|
4
|
-
<DeleteOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { DeleteOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const DeleteIcon = props => /*#__PURE__*/jsx(DeleteOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
DeleteIcon.displayName = "DeleteIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { DeleteIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { DownloadOutlined } from
|
|
2
|
-
|
|
3
|
-
const DownloadIcon = props => (
|
|
4
|
-
<DownloadOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { DownloadOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const DownloadIcon = props => /*#__PURE__*/jsx(DownloadOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
DownloadIcon.displayName = "DownloadIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { DownloadIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EditOutlined } from
|
|
2
|
-
|
|
3
|
-
const EditIcon = props => (
|
|
4
|
-
<EditOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { EditOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const EditIcon = props => /*#__PURE__*/jsx(EditOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
EditIcon.displayName = "EditIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { EditIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ExportOutlined } from
|
|
2
|
-
|
|
3
|
-
const ExportIcon = props => (
|
|
4
|
-
<ExportOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { ExportOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const ExportIcon = props => /*#__PURE__*/jsx(ExportOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
ExportIcon.displayName = "ExportIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { ExportIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ImportOutlined } from
|
|
2
|
-
|
|
3
|
-
const ImportIcon = props => (
|
|
4
|
-
<ImportOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { ImportOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const ImportIcon = props => /*#__PURE__*/jsx(ImportOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
ImportIcon.displayName = "ImportIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { ImportIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EnvironmentOutlined } from
|
|
2
|
-
|
|
3
|
-
const LocationIcon = props => (
|
|
4
|
-
<EnvironmentOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { EnvironmentOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const LocationIcon = props => /*#__PURE__*/jsx(EnvironmentOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
LocationIcon.displayName = "LocationIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { LocationIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PrinterOutlined } from
|
|
2
|
-
|
|
3
|
-
const PrintIcon = props => (
|
|
4
|
-
<PrinterOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { PrinterOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const PrintIcon = props => /*#__PURE__*/jsx(PrinterOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
PrintIcon.displayName = "PrintIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { PrintIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ReloadOutlined } from
|
|
2
|
-
|
|
3
|
-
const ResetIcon = props => (
|
|
4
|
-
<ReloadOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { ReloadOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const ResetIcon = props => /*#__PURE__*/jsx(ReloadOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
ResetIcon.displayName = "ResetIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { ResetIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { SearchOutlined } from
|
|
2
|
-
|
|
3
|
-
const SearchIcon = props => (
|
|
4
|
-
<SearchOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { SearchOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const SearchIcon = props => /*#__PURE__*/jsx(SearchOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
SearchIcon.displayName = "SearchIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { SearchIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PlayCircleOutlined } from
|
|
2
|
-
|
|
3
|
-
const VideoIcon = props => (
|
|
4
|
-
<PlayCircleOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { PlayCircleOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const VideoIcon = props => /*#__PURE__*/jsx(PlayCircleOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
VideoIcon.displayName = "VideoIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { VideoIcon as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { EyeOutlined } from
|
|
2
|
-
|
|
3
|
-
const ViewIcon = props => (
|
|
4
|
-
<EyeOutlined {...props} />
|
|
5
|
-
);
|
|
1
|
+
import { EyeOutlined } from '@ant-design/icons';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
6
3
|
|
|
4
|
+
const ViewIcon = props => /*#__PURE__*/jsx(EyeOutlined, {
|
|
5
|
+
...props
|
|
6
|
+
});
|
|
7
7
|
ViewIcon.displayName = "ViewIcon";
|
|
8
8
|
|
|
9
|
-
export default
|
|
9
|
+
export { ViewIcon as default };
|
|
@@ -1,91 +1,94 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getFileUrl } from
|
|
3
|
-
import Upload from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
children,
|
|
17
|
-
exportTemplateButtonText = "导出模板",
|
|
18
|
-
extraButtons,
|
|
19
|
-
...restProps
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
import { Form, Modal, Button } from 'antd';
|
|
2
|
+
import { getFileUrl } from '../../utils/index.js';
|
|
3
|
+
import Upload from '../Upload/index.js';
|
|
4
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
const ImportFile = props => {
|
|
7
|
+
const {
|
|
8
|
+
visible,
|
|
9
|
+
onCancel,
|
|
10
|
+
onConfirm,
|
|
11
|
+
title = "导入",
|
|
12
|
+
templateUrl,
|
|
13
|
+
labelCol = {
|
|
14
|
+
span: 4
|
|
15
|
+
},
|
|
16
|
+
children,
|
|
17
|
+
exportTemplateButtonText = "导出模板",
|
|
18
|
+
extraButtons,
|
|
19
|
+
...restProps
|
|
20
|
+
} = props;
|
|
21
|
+
const [form] = Form.useForm();
|
|
22
|
+
|
|
23
|
+
// 关闭弹窗
|
|
24
|
+
const handleClose = () => {
|
|
25
|
+
form.resetFields();
|
|
26
|
+
onCancel();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// 提交表单
|
|
30
|
+
const handleSubmit = values => {
|
|
31
|
+
onConfirm(values);
|
|
32
|
+
handleClose();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 导出模板
|
|
36
|
+
const handleExportTemplate = () => {
|
|
37
|
+
Modal.confirm({
|
|
38
|
+
title: "提示",
|
|
39
|
+
content: "确定要下载excel模板吗?",
|
|
40
|
+
okText: "确定",
|
|
41
|
+
cancelText: "取消",
|
|
42
|
+
onOk: () => {
|
|
43
|
+
const fileUrl = getFileUrl();
|
|
44
|
+
window.open(fileUrl + templateUrl);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/jsx(Modal, {
|
|
49
|
+
title: title,
|
|
50
|
+
open: visible,
|
|
51
|
+
onCancel: handleClose,
|
|
52
|
+
width: 600,
|
|
53
|
+
maskClosable: false,
|
|
54
|
+
footer: [templateUrl && /*#__PURE__*/jsx(Button, {
|
|
55
|
+
onClick: handleExportTemplate,
|
|
56
|
+
children: exportTemplateButtonText
|
|
57
|
+
}, "export"), ...(extraButtons || []), /*#__PURE__*/jsx(Button, {
|
|
58
|
+
onClick: handleClose,
|
|
59
|
+
children: "\u53D6\u6D88"
|
|
60
|
+
}, "cancel"), /*#__PURE__*/jsx(Button, {
|
|
61
|
+
type: "primary",
|
|
62
|
+
onClick: form.submit,
|
|
63
|
+
children: "\u786E\u5B9A"
|
|
64
|
+
}, "submit")],
|
|
65
|
+
children: /*#__PURE__*/jsxs(Form, {
|
|
66
|
+
form: form,
|
|
67
|
+
labelCol: labelCol,
|
|
68
|
+
wrapperCol: {
|
|
69
|
+
span: 24 - labelCol.span
|
|
70
|
+
},
|
|
71
|
+
scrollToFirstError: true,
|
|
72
|
+
onFinish: handleSubmit,
|
|
73
|
+
...restProps,
|
|
74
|
+
children: [children && typeof children === "function" ? children({
|
|
75
|
+
form
|
|
76
|
+
}) : children, /*#__PURE__*/jsx(Form.Item, {
|
|
77
|
+
label: "\u9644\u4EF6",
|
|
78
|
+
name: "file",
|
|
79
|
+
rules: [{
|
|
80
|
+
required: true,
|
|
81
|
+
message: "附件不能为空"
|
|
82
|
+
}],
|
|
83
|
+
children: /*#__PURE__*/jsx(Upload, {
|
|
84
|
+
accept: ".xls,.xlsx",
|
|
85
|
+
listType: "text",
|
|
86
|
+
maxCount: 1
|
|
87
|
+
})
|
|
88
|
+
})]
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
ImportFile.displayName = "ImportFile";
|
|
93
|
+
|
|
94
|
+
export { ImportFile as default };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import Area from
|
|
2
|
-
import BasicLeftTree from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
AreaLeftTree.displayName = "AreaLeftTree";
|
|
14
|
-
|
|
15
|
-
export default
|
|
1
|
+
import Area from '../../../json/area.json';
|
|
2
|
+
import BasicLeftTree from '../Basic/index.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
function AreaLeftTree(props) {
|
|
6
|
+
return /*#__PURE__*/jsx(BasicLeftTree, {
|
|
7
|
+
treeData: Area,
|
|
8
|
+
nameKey: "label",
|
|
9
|
+
idKey: "value",
|
|
10
|
+
...props
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
AreaLeftTree.displayName = "AreaLeftTree";
|
|
14
|
+
|
|
15
|
+
export { AreaLeftTree as default };
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Input, Tree } from
|
|
2
|
-
import {
|
|
3
|
-
import { getTreeNodePaths } from
|
|
1
|
+
import { Input, Tree } from 'antd';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { getTreeNodePaths } from '../../../utils/index.js';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
Search
|
|
8
|
+
} = Input;
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* 基础左侧树组件(不建议直接使用此组件,二次继承使用)
|
|
9
12
|
*/
|
|
10
|
-
const BasicLeftTree =
|
|
13
|
+
const BasicLeftTree = props => {
|
|
11
14
|
const {
|
|
12
15
|
onGetData,
|
|
13
16
|
onSelect,
|
|
@@ -20,21 +23,18 @@ const BasicLeftTree = (props) => {
|
|
|
20
23
|
childrenKey = "children",
|
|
21
24
|
...restProps
|
|
22
25
|
} = props;
|
|
23
|
-
|
|
24
26
|
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
25
27
|
const [searchValue, setSearchValue] = useState("");
|
|
26
28
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
27
|
-
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
setExpandedKeys(externalExpandedKeys);
|
|
30
31
|
}, [externalExpandedKeys]);
|
|
31
32
|
|
|
32
33
|
// 展开所有包含匹配项的父节点
|
|
33
34
|
const getAllExpandedKeys = (data, searchValue, keys = []) => {
|
|
34
|
-
data.forEach(
|
|
35
|
+
data.forEach(node => {
|
|
35
36
|
if (node[childrenKey]) {
|
|
36
|
-
if (node[nameKey].includes(searchValue)
|
|
37
|
-
|| node[childrenKey].some(child => child[nameKey].includes(searchValue))) {
|
|
37
|
+
if (node[nameKey].includes(searchValue) || node[childrenKey].some(child => child[nameKey].includes(searchValue))) {
|
|
38
38
|
keys.push(node[idKey]);
|
|
39
39
|
}
|
|
40
40
|
getAllExpandedKeys(node[childrenKey], searchValue, keys);
|
|
@@ -48,7 +48,6 @@ const BasicLeftTree = (props) => {
|
|
|
48
48
|
if (!searchValue) {
|
|
49
49
|
return data;
|
|
50
50
|
}
|
|
51
|
-
|
|
52
51
|
return data.reduce((acc, node) => {
|
|
53
52
|
// 检查当前节点是否匹配
|
|
54
53
|
const isMatch = node[nameKey].includes(searchValue);
|
|
@@ -60,19 +59,16 @@ const BasicLeftTree = (props) => {
|
|
|
60
59
|
if (isMatch || filteredChildren.length > 0) {
|
|
61
60
|
acc.push({
|
|
62
61
|
...node,
|
|
63
|
-
[childrenKey]: filteredChildren.length > 0 ? filteredChildren : undefined
|
|
62
|
+
[childrenKey]: filteredChildren.length > 0 ? filteredChildren : undefined
|
|
64
63
|
});
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
return acc;
|
|
68
66
|
}, []);
|
|
69
67
|
};
|
|
70
|
-
|
|
71
|
-
const handleExpand = (newExpandedKeys) => {
|
|
68
|
+
const handleExpand = newExpandedKeys => {
|
|
72
69
|
setExpandedKeys(newExpandedKeys);
|
|
73
70
|
setAutoExpandParent(false);
|
|
74
71
|
};
|
|
75
|
-
|
|
76
72
|
const handleSelect = (selectedKeys, event) => {
|
|
77
73
|
if (selectedKeys.length > 0) {
|
|
78
74
|
const selectedNodeId = selectedKeys[0];
|
|
@@ -81,91 +77,84 @@ const BasicLeftTree = (props) => {
|
|
|
81
77
|
targetId: selectedNodeId,
|
|
82
78
|
idKey,
|
|
83
79
|
childrenKey,
|
|
84
|
-
isIncludeOneself: onGetNodePathsIsIncludeOneself
|
|
80
|
+
isIncludeOneself: onGetNodePathsIsIncludeOneself
|
|
85
81
|
});
|
|
86
82
|
onGetNodePaths?.(parentNodes);
|
|
87
83
|
}
|
|
88
84
|
onSelect?.(selectedKeys, event);
|
|
89
85
|
};
|
|
90
|
-
|
|
91
|
-
const onFilterTreeData = (value) => {
|
|
86
|
+
const onFilterTreeData = value => {
|
|
92
87
|
setSearchValue(value);
|
|
93
88
|
setAutoExpandParent(true);
|
|
94
|
-
|
|
95
89
|
if (!value) {
|
|
96
90
|
setExpandedKeys([]);
|
|
97
91
|
return;
|
|
98
92
|
}
|
|
99
|
-
|
|
100
93
|
const expandedKeys = getAllExpandedKeys(treeData, value);
|
|
101
|
-
|
|
102
94
|
setExpandedKeys(expandedKeys);
|
|
103
95
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (value === searchValue)
|
|
107
|
-
return;
|
|
96
|
+
const onSearch = async value => {
|
|
97
|
+
if (value === searchValue) return;
|
|
108
98
|
onFilterTreeData(value);
|
|
109
99
|
};
|
|
110
100
|
|
|
111
101
|
// 渲染带高亮的标题
|
|
112
|
-
const renderTitle =
|
|
113
|
-
if (!searchValue)
|
|
114
|
-
return name;
|
|
115
|
-
|
|
102
|
+
const renderTitle = name => {
|
|
103
|
+
if (!searchValue) return name;
|
|
116
104
|
const index = name.indexOf(searchValue);
|
|
117
|
-
if (index === -1)
|
|
118
|
-
return name;
|
|
119
|
-
|
|
105
|
+
if (index === -1) return name;
|
|
120
106
|
const beforeStr = name.substring(0, index);
|
|
121
107
|
const afterStr = name.substring(index + searchValue.length);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
);
|
|
108
|
+
return /*#__PURE__*/jsxs("span", {
|
|
109
|
+
children: [beforeStr, /*#__PURE__*/jsx("span", {
|
|
110
|
+
style: {
|
|
111
|
+
color: "#f50"
|
|
112
|
+
},
|
|
113
|
+
children: searchValue
|
|
114
|
+
}), afterStr]
|
|
115
|
+
});
|
|
130
116
|
};
|
|
131
117
|
|
|
132
118
|
// 递归处理树节点标题显示
|
|
133
|
-
const processTreeData =
|
|
119
|
+
const processTreeData = data => {
|
|
134
120
|
return data.map(node => ({
|
|
135
121
|
...node,
|
|
136
122
|
[nameKey]: renderTitle(node[nameKey]),
|
|
137
|
-
[childrenKey]: node[childrenKey] ? processTreeData(node[childrenKey]) : undefined
|
|
123
|
+
[childrenKey]: node[childrenKey] ? processTreeData(node[childrenKey]) : undefined
|
|
138
124
|
}));
|
|
139
125
|
};
|
|
140
126
|
|
|
141
127
|
// 过滤并处理树数据
|
|
142
128
|
const filteredTreeData = filterTreeData(treeData, searchValue);
|
|
143
129
|
const processedTreeData = processTreeData(filteredTreeData);
|
|
144
|
-
|
|
145
130
|
useEffect(() => {
|
|
146
131
|
onGetData?.(treeData);
|
|
147
132
|
}, [treeData]);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
133
|
+
return /*#__PURE__*/jsxs("div", {
|
|
134
|
+
style: {
|
|
135
|
+
width: 300
|
|
136
|
+
},
|
|
137
|
+
children: [/*#__PURE__*/jsx(Search, {
|
|
138
|
+
style: {
|
|
139
|
+
marginBottom: 8
|
|
140
|
+
},
|
|
141
|
+
placeholder: "\u8F93\u5165\u5173\u952E\u5B57\u8FDB\u884C\u8FC7\u6EE4",
|
|
142
|
+
onSearch: onSearch
|
|
143
|
+
}), /*#__PURE__*/jsx(Tree, {
|
|
144
|
+
onExpand: handleExpand,
|
|
145
|
+
onSelect: handleSelect,
|
|
146
|
+
autoExpandParent: autoExpandParent,
|
|
147
|
+
expandedKeys: expandedKeys,
|
|
148
|
+
treeData: processedTreeData,
|
|
149
|
+
fieldNames: {
|
|
150
|
+
title: nameKey,
|
|
151
|
+
key: idKey,
|
|
152
|
+
children: childrenKey
|
|
153
|
+
},
|
|
154
|
+
...restProps
|
|
155
|
+
})]
|
|
156
|
+
});
|
|
167
157
|
};
|
|
168
|
-
|
|
169
158
|
BasicLeftTree.displayName = "BasicLeftTree";
|
|
170
159
|
|
|
171
|
-
export default
|
|
160
|
+
export { BasicLeftTree as default };
|