zy-react-library 1.1.1 → 1.1.3
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 +1 -20
- package/components/Cascader/Basic/index.js +1 -64
- package/components/Cascader/Dictionary/index.js +1 -42
- package/components/Cascader/Industry/index.js +1 -20
- package/components/Editor/index.js +1 -102
- package/components/FormBuilder/FormBuilder.js +1 -87
- package/components/FormBuilder/FormItemsRenderer.js +1 -591
- package/components/FormBuilder/index.js +1 -3
- package/components/HeaderBack/index.js +1 -37
- package/components/HiddenInfo/gwj/index.js +1 -518
- package/components/Icon/AddIcon/index.js +1 -9
- package/components/Icon/BackIcon/index.js +1 -9
- package/components/Icon/DeleteIcon/index.js +1 -9
- package/components/Icon/DownloadIcon/index.js +1 -9
- package/components/Icon/EditIcon/index.js +1 -9
- package/components/Icon/ExportIcon/index.js +1 -9
- package/components/Icon/ImportIcon/index.js +1 -9
- package/components/Icon/LocationIcon/index.js +1 -9
- package/components/Icon/PrintIcon/index.js +1 -9
- package/components/Icon/ResetIcon/index.js +1 -9
- package/components/Icon/SearchIcon/index.js +1 -9
- package/components/Icon/VideoIcon/index.js +1 -9
- package/components/Icon/ViewIcon/index.js +1 -9
- package/components/ImportFile/index.js +1 -91
- package/components/LeftTree/Area/index.js +1 -15
- package/components/LeftTree/Basic/index.js +1 -171
- package/components/LeftTree/Department/Gwj/index.js +1 -32
- package/components/LeftTree/Dictionary/index.js +1 -42
- package/components/Map/MapSelector.js +1 -254
- package/components/Map/index.js +1 -77
- package/components/Page/index.js +1 -50
- package/components/Pdf/index.js +1 -134
- package/components/PreviewImg/index.js +1 -32
- package/components/PreviewPdf/index.js +1 -86
- package/components/Search/index.js +1 -141
- package/components/Select/Basic/index.js +1 -76
- package/components/Select/Dictionary/index.js +1 -42
- package/components/Select/Personnel/Gwj/index.js +1 -49
- package/components/SelectCreate/index.js +1 -55
- package/components/SelectTree/Area/index.js +1 -26
- package/components/SelectTree/Basic/index.js +1 -102
- package/components/SelectTree/Department/Gwj/index.js +1 -46
- package/components/SelectTree/Dictionary/index.js +1 -42
- package/components/SelectTree/HiddenLevel/Gwj/index.js +1 -72
- package/components/SelectTree/HiddenPart/Gwj/index.js +1 -39
- package/components/SelectTree/Industry/index.js +1 -27
- package/components/Signature/index.js +1 -94
- package/components/Table/index.js +1 -73
- package/components/Table/index.less +7 -1
- package/components/TooltipPreviewImg/index.js +1 -27
- package/components/Upload/index.js +1 -275
- package/components/Video/AliPlayer.js +1 -160
- package/components/Video/index.js +1 -90
- package/css/common.less +4 -0
- package/enum/dictionary/index.js +1 -7
- package/enum/formItemRender/index.js +1 -37
- package/enum/hidden/gwj/index.js +1 -31
- package/enum/uploadFile/gwj/index.js +1 -176
- package/hooks/useDeleteFile/index.js +1 -101
- package/hooks/useDictionary/index.js +1 -66
- package/hooks/useDownloadBlob/index.js +1 -79
- package/hooks/useDownloadFile/index.js +1 -81
- package/hooks/useGetFile/index.js +1 -74
- package/hooks/useGetUrlQuery/index.js +1 -16
- package/hooks/useGetUserInfo/index.js +1 -49
- package/hooks/useIdle/index.js +1 -67
- package/hooks/useImportFile/index.js +1 -59
- package/hooks/useIsExistenceDuplicateSelection/index.js +1 -20
- package/hooks/useTable/index.js +1 -113
- package/hooks/useUploadFile/index.js +1 -149
- package/hooks/useUrlQueryCriteria/index.js +1 -77
- package/package.json +18 -1
- package/regular/index.js +1 -61
- package/utils/index.js +1 -587
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const ResetIcon = props => (
|
|
4
|
-
<ReloadOutlined {...props} />
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
ResetIcon.displayName = "ResetIcon";
|
|
8
|
-
|
|
9
|
-
export default ResetIcon;
|
|
1
|
+
import{ReloadOutlined as t}from"@ant-design/icons";import{jsx as e}from"react/jsx-runtime";const o=o=>e(t,{...o});o.displayName="ResetIcon";export{o as default};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const SearchIcon = props => (
|
|
4
|
-
<SearchOutlined {...props} />
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
SearchIcon.displayName = "SearchIcon";
|
|
8
|
-
|
|
9
|
-
export default SearchIcon;
|
|
1
|
+
import{SearchOutlined as o}from"@ant-design/icons";import{jsx as r}from"react/jsx-runtime";const t=t=>r(o,{...t});t.displayName="SearchIcon";export{t as default};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const VideoIcon = props => (
|
|
4
|
-
<PlayCircleOutlined {...props} />
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
VideoIcon.displayName = "VideoIcon";
|
|
8
|
-
|
|
9
|
-
export default VideoIcon;
|
|
1
|
+
import{PlayCircleOutlined as o}from"@ant-design/icons";import{jsx as t}from"react/jsx-runtime";const e=e=>t(o,{...e});e.displayName="VideoIcon";export{e as default};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const ViewIcon = props => (
|
|
4
|
-
<EyeOutlined {...props} />
|
|
5
|
-
);
|
|
6
|
-
|
|
7
|
-
ViewIcon.displayName = "ViewIcon";
|
|
8
|
-
|
|
9
|
-
export default ViewIcon;
|
|
1
|
+
import{EyeOutlined as o}from"@ant-design/icons";import{jsx as t}from"react/jsx-runtime";const e=e=>t(o,{...e});e.displayName="ViewIcon";export{e as default};
|
|
@@ -1,91 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getFileUrl } from "../../utils";
|
|
3
|
-
import Upload from "../Upload";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 导入文件组件
|
|
7
|
-
*/
|
|
8
|
-
const ImportFile = (props) => {
|
|
9
|
-
const {
|
|
10
|
-
visible,
|
|
11
|
-
onCancel,
|
|
12
|
-
onConfirm,
|
|
13
|
-
title = "导入",
|
|
14
|
-
templateUrl,
|
|
15
|
-
labelCol = { span: 4 },
|
|
16
|
-
children,
|
|
17
|
-
exportTemplateButtonText = "导出模板",
|
|
18
|
-
extraButtons,
|
|
19
|
-
...restProps
|
|
20
|
-
} = props;
|
|
21
|
-
|
|
22
|
-
const [form] = Form.useForm();
|
|
23
|
-
|
|
24
|
-
// 关闭弹窗
|
|
25
|
-
const handleClose = () => {
|
|
26
|
-
form.resetFields();
|
|
27
|
-
onCancel();
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// 提交表单
|
|
31
|
-
const handleSubmit = (values) => {
|
|
32
|
-
onConfirm(values);
|
|
33
|
-
handleClose();
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// 导出模板
|
|
37
|
-
const handleExportTemplate = () => {
|
|
38
|
-
Modal.confirm({
|
|
39
|
-
title: "提示",
|
|
40
|
-
content: "确定要下载excel模板吗?",
|
|
41
|
-
okText: "确定",
|
|
42
|
-
cancelText: "取消",
|
|
43
|
-
onOk: () => {
|
|
44
|
-
const fileUrl = getFileUrl();
|
|
45
|
-
window.open(fileUrl + templateUrl);
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<Modal
|
|
52
|
-
title={title}
|
|
53
|
-
open={visible}
|
|
54
|
-
onCancel={handleClose}
|
|
55
|
-
width={600}
|
|
56
|
-
maskClosable={false}
|
|
57
|
-
footer={[
|
|
58
|
-
templateUrl && (
|
|
59
|
-
<Button key="export" onClick={handleExportTemplate}>
|
|
60
|
-
{exportTemplateButtonText}
|
|
61
|
-
</Button>
|
|
62
|
-
),
|
|
63
|
-
...(extraButtons || []),
|
|
64
|
-
<Button key="cancel" onClick={handleClose}>
|
|
65
|
-
取消
|
|
66
|
-
</Button>,
|
|
67
|
-
<Button key="submit" type="primary" onClick={form.submit}>
|
|
68
|
-
确定
|
|
69
|
-
</Button>,
|
|
70
|
-
]}
|
|
71
|
-
>
|
|
72
|
-
<Form
|
|
73
|
-
form={form}
|
|
74
|
-
labelCol={labelCol}
|
|
75
|
-
wrapperCol={{ span: 24 - labelCol.span }}
|
|
76
|
-
scrollToFirstError
|
|
77
|
-
onFinish={handleSubmit}
|
|
78
|
-
{...restProps}
|
|
79
|
-
>
|
|
80
|
-
{children && typeof children === "function" ? children({ form }) : children}
|
|
81
|
-
<Form.Item label="附件" name="file" rules={[{ required: true, message: "附件不能为空" }]}>
|
|
82
|
-
<Upload accept=".xls,.xlsx" listType="text" maxCount={1} />
|
|
83
|
-
</Form.Item>
|
|
84
|
-
</Form>
|
|
85
|
-
</Modal>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
ImportFile.displayName = "ImportFile";
|
|
90
|
-
|
|
91
|
-
export default ImportFile;
|
|
1
|
+
import{Form as e,Modal as t,Button as o}from"antd";import{getFileUrl as l}from"../../utils/index.js";import n from"../Upload/index.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const s=s=>{const{visible:a,onCancel:c,onConfirm:m,title:p="导入",templateUrl:d,labelCol:x={span:4},children:f,exportTemplateButtonText:u="导出模板",extraButtons:C,...h}=s,[b]=e.useForm(),k=()=>{b.resetFields(),c()};return r(t,{title:p,open:a,onCancel:k,width:600,maskClosable:!1,footer:[d&&r(o,{onClick:()=>{t.confirm({title:"提示",content:"确定要下载excel模板吗?",okText:"确定",cancelText:"取消",onOk:()=>{const e=l();window.open(e+d)}})},children:u},"export"),...C||[],r(o,{onClick:k,children:"取消"},"cancel"),r(o,{type:"primary",onClick:b.submit,children:"确定"},"submit")],children:i(e,{form:b,labelCol:x,wrapperCol:{span:24-x.span},scrollToFirstError:!0,onFinish:e=>{m(e),k()},...h,children:[f&&"function"==typeof f?f({form:b}):f,r(e.Item,{label:"附件",name:"file",rules:[{required:!0,message:"附件不能为空"}],children:r(n,{accept:".xls,.xlsx",listType:"text",maxCount:1})})]})})};s.displayName="ImportFile";export{s as default};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import BasicLeftTree from "../Basic";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 属地左侧树组件
|
|
6
|
-
*/
|
|
7
|
-
function AreaLeftTree(props) {
|
|
8
|
-
return (
|
|
9
|
-
<BasicLeftTree treeData={Area} nameKey="label" idKey="value" {...props} />
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
AreaLeftTree.displayName = "AreaLeftTree";
|
|
14
|
-
|
|
15
|
-
export default AreaLeftTree;
|
|
1
|
+
import e from"../../../json/area.json";import r from"../Basic/index.js";import{jsx as a}from"react/jsx-runtime";function t(t){return a(r,{treeData:e,nameKey:"label",idKey:"value",...t})}t.displayName="AreaLeftTree";export{t as default};
|
|
@@ -1,171 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { getTreeNodePaths } from "../../../utils";
|
|
4
|
-
|
|
5
|
-
const { Search } = Input;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 基础左侧树组件(不建议直接使用此组件,二次继承使用)
|
|
9
|
-
*/
|
|
10
|
-
const BasicLeftTree = (props) => {
|
|
11
|
-
const {
|
|
12
|
-
onGetData,
|
|
13
|
-
onSelect,
|
|
14
|
-
onGetNodePaths,
|
|
15
|
-
onGetNodePathsIsIncludeOneself = true,
|
|
16
|
-
expandedKeys: externalExpandedKeys,
|
|
17
|
-
treeData = [],
|
|
18
|
-
nameKey = "name",
|
|
19
|
-
idKey = "id",
|
|
20
|
-
childrenKey = "children",
|
|
21
|
-
...restProps
|
|
22
|
-
} = props;
|
|
23
|
-
|
|
24
|
-
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
25
|
-
const [searchValue, setSearchValue] = useState("");
|
|
26
|
-
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setExpandedKeys(externalExpandedKeys);
|
|
30
|
-
}, [externalExpandedKeys]);
|
|
31
|
-
|
|
32
|
-
// 展开所有包含匹配项的父节点
|
|
33
|
-
const getAllExpandedKeys = (data, searchValue, keys = []) => {
|
|
34
|
-
data.forEach((node) => {
|
|
35
|
-
if (node[childrenKey]) {
|
|
36
|
-
if (node[nameKey].includes(searchValue)
|
|
37
|
-
|| node[childrenKey].some(child => child[nameKey].includes(searchValue))) {
|
|
38
|
-
keys.push(node[idKey]);
|
|
39
|
-
}
|
|
40
|
-
getAllExpandedKeys(node[childrenKey], searchValue, keys);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
return keys;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// 过滤树数据,只保留匹配的节点
|
|
47
|
-
const filterTreeData = (data, searchValue) => {
|
|
48
|
-
if (!searchValue) {
|
|
49
|
-
return data;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return data.reduce((acc, node) => {
|
|
53
|
-
// 检查当前节点是否匹配
|
|
54
|
-
const isMatch = node[nameKey].includes(searchValue);
|
|
55
|
-
|
|
56
|
-
// 递归处理子节点
|
|
57
|
-
const filteredChildren = node[childrenKey] ? filterTreeData(node[childrenKey], searchValue) : [];
|
|
58
|
-
|
|
59
|
-
// 如果当前节点匹配或者有匹配的子节点,则保留该节点
|
|
60
|
-
if (isMatch || filteredChildren.length > 0) {
|
|
61
|
-
acc.push({
|
|
62
|
-
...node,
|
|
63
|
-
[childrenKey]: filteredChildren.length > 0 ? filteredChildren : undefined,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return acc;
|
|
68
|
-
}, []);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const handleExpand = (newExpandedKeys) => {
|
|
72
|
-
setExpandedKeys(newExpandedKeys);
|
|
73
|
-
setAutoExpandParent(false);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const handleSelect = (selectedKeys, event) => {
|
|
77
|
-
if (selectedKeys.length > 0) {
|
|
78
|
-
const selectedNodeId = selectedKeys[0];
|
|
79
|
-
const parentNodes = getTreeNodePaths({
|
|
80
|
-
data: treeData,
|
|
81
|
-
targetId: selectedNodeId,
|
|
82
|
-
idKey,
|
|
83
|
-
childrenKey,
|
|
84
|
-
isIncludeOneself: onGetNodePathsIsIncludeOneself,
|
|
85
|
-
});
|
|
86
|
-
onGetNodePaths?.(parentNodes);
|
|
87
|
-
}
|
|
88
|
-
onSelect?.(selectedKeys, event);
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
const onFilterTreeData = (value) => {
|
|
92
|
-
setSearchValue(value);
|
|
93
|
-
setAutoExpandParent(true);
|
|
94
|
-
|
|
95
|
-
if (!value) {
|
|
96
|
-
setExpandedKeys([]);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const expandedKeys = getAllExpandedKeys(treeData, value);
|
|
101
|
-
|
|
102
|
-
setExpandedKeys(expandedKeys);
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const onSearch = async (value) => {
|
|
106
|
-
if (value === searchValue)
|
|
107
|
-
return;
|
|
108
|
-
onFilterTreeData(value);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// 渲染带高亮的标题
|
|
112
|
-
const renderTitle = (name) => {
|
|
113
|
-
if (!searchValue)
|
|
114
|
-
return name;
|
|
115
|
-
|
|
116
|
-
const index = name.indexOf(searchValue);
|
|
117
|
-
if (index === -1)
|
|
118
|
-
return name;
|
|
119
|
-
|
|
120
|
-
const beforeStr = name.substring(0, index);
|
|
121
|
-
const afterStr = name.substring(index + searchValue.length);
|
|
122
|
-
|
|
123
|
-
return (
|
|
124
|
-
<span>
|
|
125
|
-
{beforeStr}
|
|
126
|
-
<span style={{ color: "#f50" }}>{searchValue}</span>
|
|
127
|
-
{afterStr}
|
|
128
|
-
</span>
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// 递归处理树节点标题显示
|
|
133
|
-
const processTreeData = (data) => {
|
|
134
|
-
return data.map(node => ({
|
|
135
|
-
...node,
|
|
136
|
-
[nameKey]: renderTitle(node[nameKey]),
|
|
137
|
-
[childrenKey]: node[childrenKey] ? processTreeData(node[childrenKey]) : undefined,
|
|
138
|
-
}));
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// 过滤并处理树数据
|
|
142
|
-
const filteredTreeData = filterTreeData(treeData, searchValue);
|
|
143
|
-
const processedTreeData = processTreeData(filteredTreeData);
|
|
144
|
-
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
onGetData?.(treeData);
|
|
147
|
-
}, [treeData]);
|
|
148
|
-
|
|
149
|
-
return (
|
|
150
|
-
<div style={{ width: 300 }}>
|
|
151
|
-
<Search
|
|
152
|
-
style={{ marginBottom: 8 }}
|
|
153
|
-
placeholder="输入关键字进行过滤"
|
|
154
|
-
onSearch={onSearch}
|
|
155
|
-
/>
|
|
156
|
-
<Tree
|
|
157
|
-
onExpand={handleExpand}
|
|
158
|
-
onSelect={handleSelect}
|
|
159
|
-
autoExpandParent={autoExpandParent}
|
|
160
|
-
expandedKeys={expandedKeys}
|
|
161
|
-
treeData={processedTreeData}
|
|
162
|
-
fieldNames={{ title: nameKey, key: idKey, children: childrenKey }}
|
|
163
|
-
{...restProps}
|
|
164
|
-
/>
|
|
165
|
-
</div>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
BasicLeftTree.displayName = "BasicLeftTree";
|
|
170
|
-
|
|
171
|
-
export default BasicLeftTree;
|
|
1
|
+
import{Input as e,Tree as t}from"antd";import{useState as n,useEffect as r}from"react";import{getTreeNodePaths as s}from"../../../utils/index.js";import{jsxs as d,jsx as i}from"react/jsx-runtime";const{Search:a}=e,o=e=>{const{onGetData:o,onSelect:c,onGetNodePaths:l,onGetNodePathsIsIncludeOneself:h=!0,expandedKeys:u,treeData:m=[],nameKey:f="name",idKey:p="id",childrenKey:y="children",...g}=e,[x,K]=n([]),[v,I]=n(""),[N,S]=n(!0);r(()=>{K(u)},[u]);const D=(e,t,n=[])=>(e.forEach(e=>{e[y]&&((e[f].includes(t)||e[y].some(e=>e[f].includes(t)))&&n.push(e[p]),D(e[y],t,n))}),n),E=(e,t)=>t?e.reduce((e,n)=>{const r=n[f].includes(t),s=n[y]?E(n[y],t):[];return(r||s.length>0)&&e.push({...n,[y]:s.length>0?s:void 0}),e},[]):e,G=e=>{if(!v)return e;const t=e.indexOf(v);if(-1===t)return e;const n=e.substring(0,t),r=e.substring(t+v.length);return d("span",{children:[n,i("span",{style:{color:"#f50"},children:v}),r]})},O=e=>e.map(e=>({...e,[f]:G(e[f]),[y]:e[y]?O(e[y]):void 0})),P=E(m,v),b=O(P);return r(()=>{o?.(m)},[m]),d("div",{style:{width:300},children:[i(a,{style:{marginBottom:8},placeholder:"输入关键字进行过滤",onSearch:async e=>{e!==v&&(e=>{if(I(e),S(!0),!e)return void K([]);const t=D(m,e);K(t)})(e)}}),i(t,{onExpand:e=>{K(e),S(!1)},onSelect:(e,t)=>{if(e.length>0){const t=e[0],n=s({data:m,targetId:t,idKey:p,childrenKey:y,isIncludeOneself:h});l?.(n)}c?.(e,t)},autoExpandParent:N,expandedKeys:x,treeData:b,fieldNames:{title:f,key:p,children:y},...g})]})};o.displayName="BasicLeftTree";export{o as default};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import BasicLeftTree from "../../Basic";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 部门左侧树组件(港务局版本)
|
|
7
|
-
*/
|
|
8
|
-
function DepartmentLeftTree(props) {
|
|
9
|
-
const {
|
|
10
|
-
params = {},
|
|
11
|
-
...restProps
|
|
12
|
-
} = props;
|
|
13
|
-
|
|
14
|
-
const [treeData, setTreeData] = useState([]);
|
|
15
|
-
|
|
16
|
-
const getData = async () => {
|
|
17
|
-
const { data } = await request("/basicInfo/department/listTree", "post", params);
|
|
18
|
-
setTreeData(data);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
getData();
|
|
23
|
-
}, []);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<BasicLeftTree treeData={treeData} childrenKey="childrenList" {...restProps} />
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
DepartmentLeftTree.displayName = "DepartmentLeftTree";
|
|
31
|
-
|
|
32
|
-
export default DepartmentLeftTree;
|
|
1
|
+
import{request as t}from"@cqsjjb/jjb-common-lib/http";import{useState as e,useEffect as r}from"react";import a from"../../Basic/index.js";import{jsx as i}from"react/jsx-runtime";function o(o){const{params:m={},...n}=o,[s,c]=e([]);return r(()=>{(async()=>{const{data:e}=await t("/basicInfo/department/listTree","post",m);c(e)})()},[]),i(a,{treeData:s,childrenKey:"childrenList",...n})}o.displayName="DepartmentLeftTree";export{o as default};
|
|
@@ -1,42 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary";
|
|
4
|
-
import BasicLeftTree from "../Basic";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 数据字典左侧树组件
|
|
8
|
-
*/
|
|
9
|
-
function DictionaryLeftTree(props) {
|
|
10
|
-
const {
|
|
11
|
-
appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT,
|
|
12
|
-
dictValue = "",
|
|
13
|
-
nameKey = "dictLabel",
|
|
14
|
-
idKey = "dictValue",
|
|
15
|
-
...restProps
|
|
16
|
-
} = props;
|
|
17
|
-
|
|
18
|
-
const [treeData, setTreeData] = useState([]);
|
|
19
|
-
|
|
20
|
-
const getData = async () => {
|
|
21
|
-
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey)) {
|
|
22
|
-
console.error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
setTreeData([]);
|
|
27
|
-
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
|
|
28
|
-
setTreeData(data);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
dictValue && getData();
|
|
33
|
-
}, [dictValue]);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<BasicLeftTree treeData={treeData} nameKey={nameKey} idKey={idKey} {...restProps} />
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
DictionaryLeftTree.displayName = "DictionaryLeftTree";
|
|
41
|
-
|
|
42
|
-
export default DictionaryLeftTree;
|
|
1
|
+
import{request as e}from"@cqsjjb/jjb-common-lib/http";import{useState as t,useEffect as i}from"react";import{DICTIONARY_APP_KEY_ENUM as a}from"../../../enum/dictionary/index.js";import r from"../Basic/index.js";import{jsx as o}from"react/jsx-runtime";function c(c){const{appKey:n=a.DEFAULT,dictValue:m="",nameKey:d="dictLabel",idKey:s="dictValue",...p}=c,[l,u]=t([]);return i(()=>{m&&(async()=>{if(!Object.values(a).includes(n))return void console.error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");u([]);const{data:t}=await e("/config/dict-trees/list/by/dictValues","get",{appKey:n,dictValue:m});u(t)})()},[m]),o(r,{treeData:l,nameKey:d,idKey:s,...p})}c.displayName="DictionaryLeftTree";export{c as default};
|
|
@@ -1,254 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { dynamicLoadJs } from "../../utils";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 定位组件弹窗
|
|
7
|
-
*/
|
|
8
|
-
const MapSelector = (props) => {
|
|
9
|
-
const {
|
|
10
|
-
visible,
|
|
11
|
-
onClose,
|
|
12
|
-
longitude,
|
|
13
|
-
latitude,
|
|
14
|
-
onConfirm,
|
|
15
|
-
area = "",
|
|
16
|
-
showArea = false,
|
|
17
|
-
disable = false,
|
|
18
|
-
} = props;
|
|
19
|
-
|
|
20
|
-
const mapContainerRef = useRef(null);
|
|
21
|
-
const mapInstanceRef = useRef(null);
|
|
22
|
-
const local = useRef(null);
|
|
23
|
-
const [loading, setLoading] = useState(false);
|
|
24
|
-
const [currentLongitude, setCurrentLongitude] = useState(longitude || "");
|
|
25
|
-
const [currentLatitude, setCurrentLatitude] = useState(latitude || "");
|
|
26
|
-
const [localSearch, setLocalSearch] = useState("");
|
|
27
|
-
const [currentArea, setCurrentArea] = useState("");
|
|
28
|
-
|
|
29
|
-
// 当外部经纬度变化时,更新内部状态
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
setCurrentLongitude(longitude || "");
|
|
32
|
-
setCurrentLatitude(latitude || "");
|
|
33
|
-
setCurrentArea(area || "");
|
|
34
|
-
}, [longitude, latitude, area]);
|
|
35
|
-
|
|
36
|
-
// 初始化地图
|
|
37
|
-
const initMap = async () => {
|
|
38
|
-
if (!window.BMapGL) {
|
|
39
|
-
await dynamicLoadJs("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setLoading(true);
|
|
43
|
-
|
|
44
|
-
// 确保DOM已经渲染
|
|
45
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
46
|
-
|
|
47
|
-
if (mapContainerRef.current) {
|
|
48
|
-
// 只有在没有地图实例时才创建新地图
|
|
49
|
-
if (!mapInstanceRef.current) {
|
|
50
|
-
const map = new window.BMapGL.Map(mapContainerRef.current);
|
|
51
|
-
mapInstanceRef.current = map;
|
|
52
|
-
|
|
53
|
-
map.centerAndZoom(
|
|
54
|
-
new window.BMapGL.Point(
|
|
55
|
-
longitude || "119.69457721306945",
|
|
56
|
-
latitude || "39.940504336846665",
|
|
57
|
-
),
|
|
58
|
-
16,
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
map.enableScrollWheelZoom(true);
|
|
62
|
-
|
|
63
|
-
// 如果有初始坐标,添加标记
|
|
64
|
-
if (longitude && latitude) {
|
|
65
|
-
const point = new window.BMapGL.Point(longitude, latitude);
|
|
66
|
-
const marker = new window.BMapGL.Marker(point);
|
|
67
|
-
map.addOverlay(marker);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 添加点击事件
|
|
71
|
-
if (!disable) {
|
|
72
|
-
map.addEventListener("click", (event) => {
|
|
73
|
-
map.clearOverlays();
|
|
74
|
-
const point = new window.BMapGL.Point(event.latlng.lng, event.latlng.lat);
|
|
75
|
-
const marker = new window.BMapGL.Marker(point);
|
|
76
|
-
map.addOverlay(marker);
|
|
77
|
-
setCurrentLatitude(event.latlng.lat);
|
|
78
|
-
setCurrentLongitude(event.latlng.lng);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
setLoading(false);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// 搜索功能
|
|
88
|
-
const handleLocalSearch = () => {
|
|
89
|
-
if (localSearch && mapInstanceRef.current) {
|
|
90
|
-
local.current = new window.BMapGL.LocalSearch(mapInstanceRef.current, {
|
|
91
|
-
renderOptions: { map: mapInstanceRef.current },
|
|
92
|
-
});
|
|
93
|
-
local.current.search(localSearch);
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
// 清空
|
|
98
|
-
const handleLocalClear = () => {
|
|
99
|
-
setLocalSearch("");
|
|
100
|
-
if (mapInstanceRef.current) {
|
|
101
|
-
local.current.search("");
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// 关闭弹窗
|
|
106
|
-
const handleClose = () => {
|
|
107
|
-
setLocalSearch("");
|
|
108
|
-
if (onClose)
|
|
109
|
-
onClose();
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// 确认选择
|
|
113
|
-
const handleConfirm = () => {
|
|
114
|
-
if (onConfirm) {
|
|
115
|
-
onConfirm(currentLongitude, currentLatitude, { area: currentArea });
|
|
116
|
-
}
|
|
117
|
-
handleClose();
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
// 监听visible变化
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
let initTimer;
|
|
123
|
-
|
|
124
|
-
if (visible) {
|
|
125
|
-
// 延迟初始化地图,确保DOM完全渲染
|
|
126
|
-
initTimer = setTimeout(() => {
|
|
127
|
-
initMap();
|
|
128
|
-
}, 100);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return () => {
|
|
132
|
-
if (initTimer) {
|
|
133
|
-
clearTimeout(initTimer);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
}, [visible]);
|
|
137
|
-
|
|
138
|
-
const handleAfterClose = () => {
|
|
139
|
-
if (mapInstanceRef.current) {
|
|
140
|
-
try {
|
|
141
|
-
mapInstanceRef.current.clearOverlays();
|
|
142
|
-
mapInstanceRef.current.destroy();
|
|
143
|
-
mapInstanceRef.current = null;
|
|
144
|
-
}
|
|
145
|
-
catch (e) {
|
|
146
|
-
console.warn("Error destroying map on unmount:", e);
|
|
147
|
-
}
|
|
148
|
-
mapInstanceRef.current = null;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
// 组件卸载时清理地图
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
return () => {
|
|
155
|
-
handleAfterClose();
|
|
156
|
-
};
|
|
157
|
-
}, []);
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<Modal
|
|
161
|
-
open={visible}
|
|
162
|
-
title="坐标"
|
|
163
|
-
onCancel={handleClose}
|
|
164
|
-
width={1000}
|
|
165
|
-
destroyOnHidden={false}
|
|
166
|
-
maskClosable={false}
|
|
167
|
-
afterClose={handleAfterClose}
|
|
168
|
-
footer={[
|
|
169
|
-
<Button key="back" onClick={handleClose}>
|
|
170
|
-
取消
|
|
171
|
-
</Button>,
|
|
172
|
-
!disable && (
|
|
173
|
-
<Button key="submit" type="primary" onClick={handleConfirm}>
|
|
174
|
-
确定
|
|
175
|
-
</Button>
|
|
176
|
-
),
|
|
177
|
-
]}
|
|
178
|
-
>
|
|
179
|
-
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
180
|
-
{
|
|
181
|
-
showArea && (
|
|
182
|
-
<Row gutter={24}>
|
|
183
|
-
<Col span={12}>
|
|
184
|
-
<Form.Item label="所属区域">
|
|
185
|
-
<Select value={currentArea} onChange={e => setCurrentArea(e)} allowClear>
|
|
186
|
-
<Select.Option value="1">东港区</Select.Option>
|
|
187
|
-
<Select.Option value="2">西港区</Select.Option>
|
|
188
|
-
</Select>
|
|
189
|
-
</Form.Item>
|
|
190
|
-
</Col>
|
|
191
|
-
</Row>
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
{
|
|
195
|
-
!disable && (
|
|
196
|
-
<Row gutter={24}>
|
|
197
|
-
<Col span={12}>
|
|
198
|
-
<Form.Item label="关键字搜索">
|
|
199
|
-
<Input value={localSearch} onChange={e => setLocalSearch(e.target.value)} allowClear />
|
|
200
|
-
</Form.Item>
|
|
201
|
-
</Col>
|
|
202
|
-
<Col span={12}>
|
|
203
|
-
<Form.Item label=" " colon={false} style={{ textAlign: "right" }}>
|
|
204
|
-
<Button type="primary" onClick={handleLocalSearch}>
|
|
205
|
-
搜索
|
|
206
|
-
</Button>
|
|
207
|
-
<Button onClick={handleLocalClear} style={{ marginLeft: 8 }}>
|
|
208
|
-
重置
|
|
209
|
-
</Button>
|
|
210
|
-
</Form.Item>
|
|
211
|
-
</Col>
|
|
212
|
-
</Row>
|
|
213
|
-
)
|
|
214
|
-
}
|
|
215
|
-
<Row gutter={24}>
|
|
216
|
-
<Col span={12}>
|
|
217
|
-
<Form.Item label="经度">
|
|
218
|
-
<Input disabled value={currentLongitude} />
|
|
219
|
-
</Form.Item>
|
|
220
|
-
</Col>
|
|
221
|
-
<Col span={12}>
|
|
222
|
-
<Form.Item label="纬度">
|
|
223
|
-
<Input disabled value={currentLatitude} />
|
|
224
|
-
</Form.Item>
|
|
225
|
-
</Col>
|
|
226
|
-
</Row>
|
|
227
|
-
</Form>
|
|
228
|
-
<div
|
|
229
|
-
ref={mapContainerRef}
|
|
230
|
-
style={{ width: "100%", height: "500px", position: "relative" }}
|
|
231
|
-
>
|
|
232
|
-
<Spin size="large" tip="地图正在加载中..." spinning={loading}>
|
|
233
|
-
<div style={{
|
|
234
|
-
position: "absolute",
|
|
235
|
-
top: 0,
|
|
236
|
-
left: 0,
|
|
237
|
-
right: 0,
|
|
238
|
-
bottom: 0,
|
|
239
|
-
display: "flex",
|
|
240
|
-
justifyContent: "center",
|
|
241
|
-
alignItems: "center",
|
|
242
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
243
|
-
zIndex: 1000,
|
|
244
|
-
}}
|
|
245
|
-
/>
|
|
246
|
-
</Spin>
|
|
247
|
-
</div>
|
|
248
|
-
</Modal>
|
|
249
|
-
);
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
MapSelector.displayName = "MapSelector";
|
|
253
|
-
|
|
254
|
-
export default MapSelector;
|
|
1
|
+
import{Modal as e,Form as n,Row as l,Col as r,Select as t,Input as a,Button as i,Spin as o}from"antd";import{useRef as c,useState as d,useEffect as s}from"react";import{dynamicLoadJs as p}from"../../utils/index.js";import{jsxs as u,jsx as h}from"react/jsx-runtime";const w=w=>{const{visible:m,onClose:b,longitude:g,latitude:y,onConfirm:f,area:C="",showArea:v=!1,disable:k=!1}=w,L=c(null),M=c(null),O=c(null),[B,G]=d(!1),[x,I]=d(g||""),[A,F]=d(y||""),[K,N]=d(""),[z,E]=d("");s(()=>{I(g||""),F(y||""),E(C||"")},[g,y,C]);const P=()=>{N(""),b&&b()};s(()=>{let e;return m&&(e=setTimeout(()=>{(async()=>{if(window.BMapGL||(window?.base?.loadDynamicResource?await window.base.loadDynamicResource({url:"https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize",type:"script"}):await p("https://api.map.baidu.com/api?v=1.0&type=webgl&ak=OElqFYoKiAH8KFtph8ftLKF5NlNrbCUr&callback=initialize")),G(!0),await new Promise(e=>setTimeout(e,100)),L.current){if(!M.current){const e=new window.BMapGL.Map(L.current);if(M.current=e,e.centerAndZoom(new window.BMapGL.Point(g||"119.69457721306945",y||"39.940504336846665"),16),e.enableScrollWheelZoom(!0),g&&y){const n=new window.BMapGL.Point(g,y),l=new window.BMapGL.Marker(n);e.addOverlay(l)}k||e.addEventListener("click",n=>{e.clearOverlays();const l=new window.BMapGL.Point(n.latlng.lng,n.latlng.lat),r=new window.BMapGL.Marker(l);e.addOverlay(r),F(n.latlng.lat),I(n.latlng.lng)})}G(!1)}})()},100)),()=>{e&&clearTimeout(e)}},[m]);const j=()=>{if(M.current){try{M.current.clearOverlays(),M.current.destroy(),M.current=null}catch(e){console.warn("Error destroying map on unmount:",e)}M.current=null}};return s(()=>()=>{j()},[]),u(e,{open:m,title:"坐标",onCancel:P,width:1e3,destroyOnHidden:!1,maskClosable:!1,afterClose:j,footer:[h(i,{onClick:P,children:"取消"},"back"),!k&&h(i,{type:"primary",onClick:()=>{f&&f(x,A,{area:z}),P()},children:"确定"},"submit")],children:[u(n,{labelAlign:"right",labelCol:{span:6},wrapperCol:{span:18},children:[v&&h(l,{gutter:24,children:h(r,{span:12,children:h(n.Item,{label:"所属区域",children:u(t,{value:z,onChange:e=>E(e),allowClear:!0,children:[h(t.Option,{value:"1",children:"东港区"}),h(t.Option,{value:"2",children:"西港区"})]})})})}),!k&&u(l,{gutter:24,children:[h(r,{span:12,children:h(n.Item,{label:"关键字搜索",children:h(a,{value:K,onChange:e=>N(e.target.value),allowClear:!0})})}),h(r,{span:12,children:u(n.Item,{label:" ",colon:!1,style:{textAlign:"right"},children:[h(i,{type:"primary",onClick:()=>{K&&M.current&&(O.current=new window.BMapGL.LocalSearch(M.current,{renderOptions:{map:M.current}}),O.current.search(K))},children:"搜索"}),h(i,{onClick:()=>{N(""),M.current&&O.current.search("")},style:{marginLeft:8},children:"重置"})]})})]}),u(l,{gutter:24,children:[h(r,{span:12,children:h(n.Item,{label:"经度",children:h(a,{disabled:!0,value:x})})}),h(r,{span:12,children:h(n.Item,{label:"纬度",children:h(a,{disabled:!0,value:A})})})]})]}),h("div",{ref:L,style:{width:"100%",height:"500px",position:"relative"},children:h(o,{size:"large",tip:"地图正在加载中...",spinning:B,children:h("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",justifyContent:"center",alignItems:"center",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:1e3}})})})]})};w.displayName="MapSelector";export{w as default};
|