zy-react-library 1.0.69 → 1.0.70
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/components/Cascader/Area/index.d.ts +1 -1
- package/components/Cascader/Area/index.js +1 -8
- package/components/Cascader/Basic/index.d.ts +2 -2
- package/components/Cascader/Basic/index.js +1 -1
- package/components/Cascader/Dictionary/index.d.ts +23 -0
- package/components/Cascader/Dictionary/index.js +40 -0
- package/components/LeftTree/Area/index.d.ts +16 -0
- package/components/LeftTree/Area/index.js +15 -0
- package/components/LeftTree/Basic/index.d.ts +2 -2
- package/components/LeftTree/Basic/index.js +1 -1
- package/components/LeftTree/Department/Gwj/index.d.ts +1 -1
- package/components/LeftTree/Department/Gwj/index.js +1 -1
- package/components/LeftTree/Dictionary/index.d.ts +23 -0
- package/components/LeftTree/Dictionary/index.js +40 -0
- package/components/Map/MapSelector.d.ts +17 -1
- package/components/Map/MapSelector.js +23 -9
- package/components/Map/index.d.ts +9 -2
- package/components/Map/index.js +7 -3
- package/components/Select/Dictionary/index.d.ts +23 -0
- package/components/Select/Dictionary/index.js +40 -0
- package/components/Select/Personnel/Gwj/index.d.ts +1 -1
- package/components/SelectTree/Area/index.d.ts +1 -1
- package/components/SelectTree/Area/index.js +0 -1
- package/components/SelectTree/Basic/index.d.ts +2 -2
- package/components/SelectTree/Basic/index.js +6 -6
- package/components/SelectTree/Department/Gwj/index.d.ts +1 -1
- package/components/SelectTree/Department/Gwj/index.js +1 -1
- package/components/SelectTree/Dictionary/index.d.ts +23 -0
- package/components/SelectTree/Dictionary/index.js +40 -0
- package/enum/dictionary/index.js +7 -0
- package/enum/uploadFile/gwj/index.js +2 -0
- package/hooks/useDictionary/index.d.ts +24 -0
- package/hooks/useDictionary/index.js +50 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import type { BasicCascaderProps } from "../Basic";
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
6
6
|
*/
|
|
7
|
-
export interface AreaCascaderProps extends Omit<BasicCascaderProps, "options"> {
|
|
7
|
+
export interface AreaCascaderProps extends Omit<BasicCascaderProps, "options" | "placeholder" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
8
|
/** 占位符,默认为"属地" */
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
}
|
|
@@ -11,14 +11,7 @@ function AreaCascader(props) {
|
|
|
11
11
|
} = props;
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
|
-
<BasicCascader
|
|
15
|
-
data={Area}
|
|
16
|
-
placeholder={placeholder}
|
|
17
|
-
nameKey="label"
|
|
18
|
-
idKey="value"
|
|
19
|
-
childrenKey="children"
|
|
20
|
-
{...restProps}
|
|
21
|
-
/>
|
|
14
|
+
<BasicCascader data={Area} placeholder={placeholder} nameKey="label" idKey="value" {...restProps} />
|
|
22
15
|
);
|
|
23
16
|
}
|
|
24
17
|
|
|
@@ -4,12 +4,12 @@ import type { FC } from "react";
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
6
6
|
*/
|
|
7
|
-
export interface BasicCascaderProps extends CascaderProps {
|
|
7
|
+
export interface BasicCascaderProps extends Omit<CascaderProps, "fieldNames"> {
|
|
8
8
|
/** 树形数据 label 字段,默认 name */
|
|
9
9
|
nameKey?: string;
|
|
10
10
|
/** 树形数据 value 字段,默认 id */
|
|
11
11
|
idKey?: string;
|
|
12
|
-
/** 树形数据 children 字段,默认
|
|
12
|
+
/** 树形数据 children 字段,默认 children */
|
|
13
13
|
childrenKey?: string;
|
|
14
14
|
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
|
15
15
|
onGetNodePathsIsIncludeOneself?: boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicCascaderProps } from "../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface DictionarySelectTreeProps extends Omit<BasicCascaderProps, "options" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
|
+
/** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */
|
|
9
|
+
appKey?: string;
|
|
10
|
+
/** 要获取的字典 */
|
|
11
|
+
dictValue: string;
|
|
12
|
+
/** 树形数据 label 字段,默认 dictLabel */
|
|
13
|
+
nameKey?: string;
|
|
14
|
+
/** 树形数据 value 字段,默认 dictValue */
|
|
15
|
+
idKey?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 数据字典级联组件
|
|
20
|
+
*/
|
|
21
|
+
declare const DictionarySelectTree: FC<DictionarySelectTreeProps>;
|
|
22
|
+
|
|
23
|
+
export default DictionarySelectTree;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary";
|
|
4
|
+
import BasicCascader from "../Basic";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 数据字典级联组件
|
|
8
|
+
*/
|
|
9
|
+
function DictionarySelectTree(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
|
+
throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
23
|
+
|
|
24
|
+
setTreeData([]);
|
|
25
|
+
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
|
|
26
|
+
setTreeData(data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
dictValue && getData();
|
|
31
|
+
}, [dictValue]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<BasicCascader data={treeData} nameKey={nameKey} idKey={idKey} {...restProps} />
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
DictionarySelectTree.displayName = "DictionarySelectTree";
|
|
39
|
+
|
|
40
|
+
export default DictionarySelectTree;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicLeftTreeProps } from "../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface AreaLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 属地左侧树组件
|
|
13
|
+
*/
|
|
14
|
+
declare const AreaLeftTree: FC<AreaLeftTreeProps>;
|
|
15
|
+
|
|
16
|
+
export default AreaLeftTree;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Area from "../../../json/area.json";
|
|
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;
|
|
@@ -4,12 +4,12 @@ import type { FC } from "react";
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
6
6
|
*/
|
|
7
|
-
export interface BasicLeftTreeProps extends TreeProps {
|
|
7
|
+
export interface BasicLeftTreeProps extends Omit<TreeProps, "fieldNames"> {
|
|
8
8
|
/** 树形数据 title 字段,默认 name */
|
|
9
9
|
nameKey?: string;
|
|
10
10
|
/** 树形数据 key 字段,默认 id */
|
|
11
11
|
idKey?: string;
|
|
12
|
-
/** 树形数据 children 字段,默认
|
|
12
|
+
/** 树形数据 children 字段,默认 children */
|
|
13
13
|
childrenKey?: string;
|
|
14
14
|
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
|
15
15
|
onGetNodePathsIsIncludeOneself?: boolean;
|
|
@@ -14,7 +14,7 @@ export interface Params {
|
|
|
14
14
|
/**
|
|
15
15
|
* 组件属性
|
|
16
16
|
*/
|
|
17
|
-
export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData"> {
|
|
17
|
+
export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
|
18
18
|
/** 请求参数 */
|
|
19
19
|
params?: Params;
|
|
20
20
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicLeftTreeProps } from "../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface DictionaryLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
|
+
/** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */
|
|
9
|
+
appKey?: string;
|
|
10
|
+
/** 要获取的字典 */
|
|
11
|
+
dictValue: string;
|
|
12
|
+
/** 树形数据 label 字段,默认 dictLabel */
|
|
13
|
+
nameKey?: string;
|
|
14
|
+
/** 树形数据 value 字段,默认 dictValue */
|
|
15
|
+
idKey?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 数据字典左侧树组件
|
|
20
|
+
*/
|
|
21
|
+
declare const DictionaryLeftTree: FC<DictionaryLeftTreeProps>;
|
|
22
|
+
|
|
23
|
+
export default DictionaryLeftTree;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
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
|
+
throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
23
|
+
|
|
24
|
+
setTreeData([]);
|
|
25
|
+
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
|
|
26
|
+
setTreeData(data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
dictValue && getData();
|
|
31
|
+
}, [dictValue]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<BasicLeftTree treeData={treeData} nameKey={nameKey} idKey={idKey} {...restProps} />
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
DictionaryLeftTree.displayName = "DictionaryLeftTree";
|
|
39
|
+
|
|
40
|
+
export default DictionaryLeftTree;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { FC } from "react";
|
|
2
2
|
|
|
3
|
+
export interface OnConfirmParams {
|
|
4
|
+
/** 经度值 */
|
|
5
|
+
longitude: number | string;
|
|
6
|
+
/** 纬度值 */
|
|
7
|
+
latitude: number | string;
|
|
8
|
+
/** 额外参数 */
|
|
9
|
+
extra?: { area: string };
|
|
10
|
+
}
|
|
11
|
+
|
|
3
12
|
export interface MapSelectorProps {
|
|
4
13
|
/** 是否显示弹窗 */
|
|
5
14
|
visible: boolean;
|
|
@@ -9,10 +18,17 @@ export interface MapSelectorProps {
|
|
|
9
18
|
longitude?: number | string;
|
|
10
19
|
/** 纬度值 */
|
|
11
20
|
latitude?: number | string;
|
|
21
|
+
/** 所属区域 */
|
|
22
|
+
area?: string;
|
|
23
|
+
/** 是否显示所属区域 */
|
|
24
|
+
showArea?: boolean;
|
|
12
25
|
/** 确认选择回调 */
|
|
13
|
-
onConfirm?: (longitude: number | string, latitude: number | string) => void;
|
|
26
|
+
onConfirm?: (longitude: number | string, latitude: number | string, extra: { area: string }) => void;
|
|
14
27
|
}
|
|
15
28
|
|
|
29
|
+
/**
|
|
30
|
+
* 定位组件弹窗
|
|
31
|
+
*/
|
|
16
32
|
declare const MapSelector: FC<MapSelectorProps>;
|
|
17
33
|
|
|
18
34
|
export default MapSelector;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, Col, Form, Input, Modal, Row, Spin } from "antd";
|
|
1
|
+
import { Button, Col, Form, Input, Modal, Row, Select, Spin } from "antd";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,6 +11,8 @@ const MapSelector = (props) => {
|
|
|
11
11
|
longitude,
|
|
12
12
|
latitude,
|
|
13
13
|
onConfirm,
|
|
14
|
+
area = "",
|
|
15
|
+
showArea = false,
|
|
14
16
|
} = props;
|
|
15
17
|
|
|
16
18
|
const mapContainerRef = useRef(null);
|
|
@@ -19,12 +21,14 @@ const MapSelector = (props) => {
|
|
|
19
21
|
const [currentLongitude, setCurrentLongitude] = useState(longitude || "");
|
|
20
22
|
const [currentLatitude, setCurrentLatitude] = useState(latitude || "");
|
|
21
23
|
const [localSearch, setLocalSearch] = useState("");
|
|
24
|
+
const [currentArea, setCurrentArea] = useState("");
|
|
22
25
|
|
|
23
26
|
// 当外部经纬度变化时,更新内部状态
|
|
24
27
|
useEffect(() => {
|
|
25
28
|
setCurrentLongitude(longitude || "");
|
|
26
29
|
setCurrentLatitude(latitude || "");
|
|
27
|
-
|
|
30
|
+
setCurrentArea(area || "");
|
|
31
|
+
}, [longitude, latitude, area]);
|
|
28
32
|
|
|
29
33
|
// 初始化地图
|
|
30
34
|
const initMap = async () => {
|
|
@@ -96,7 +100,7 @@ const MapSelector = (props) => {
|
|
|
96
100
|
// 确认选择
|
|
97
101
|
const handleConfirm = () => {
|
|
98
102
|
if (onConfirm) {
|
|
99
|
-
onConfirm(currentLongitude, currentLatitude);
|
|
103
|
+
onConfirm(currentLongitude, currentLatitude, { area: currentArea });
|
|
100
104
|
}
|
|
101
105
|
handleClose();
|
|
102
106
|
};
|
|
@@ -146,19 +150,29 @@ const MapSelector = (props) => {
|
|
|
146
150
|
title="坐标"
|
|
147
151
|
onCancel={handleClose}
|
|
148
152
|
onOk={handleConfirm}
|
|
149
|
-
width={
|
|
153
|
+
width={1000}
|
|
150
154
|
destroyOnHidden={false}
|
|
151
155
|
afterClose={handleAfterClose}
|
|
152
156
|
>
|
|
153
157
|
<Form labelAlign="right" labelCol={{ span: 6 }} wrapperCol={{ span: 18 }}>
|
|
158
|
+
{
|
|
159
|
+
showArea && (
|
|
160
|
+
<Row gutter={24}>
|
|
161
|
+
<Col span={12}>
|
|
162
|
+
<Form.Item label="所属区域">
|
|
163
|
+
<Select value={currentArea} onChange={e => setCurrentArea(e)} allowClear>
|
|
164
|
+
<Select.Option value="1">东港区</Select.Option>
|
|
165
|
+
<Select.Option value="2">西港区</Select.Option>
|
|
166
|
+
</Select>
|
|
167
|
+
</Form.Item>
|
|
168
|
+
</Col>
|
|
169
|
+
</Row>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
154
172
|
<Row gutter={24}>
|
|
155
173
|
<Col span={12}>
|
|
156
174
|
<Form.Item label="关键字搜索">
|
|
157
|
-
<Input
|
|
158
|
-
value={localSearch}
|
|
159
|
-
onChange={e => setLocalSearch(e.target.value)}
|
|
160
|
-
allowClear
|
|
161
|
-
/>
|
|
175
|
+
<Input value={localSearch} onChange={e => setLocalSearch(e.target.value)} allowClear />
|
|
162
176
|
</Form.Item>
|
|
163
177
|
</Col>
|
|
164
178
|
<Col span={12}>
|
|
@@ -5,12 +5,19 @@ export interface MapProps {
|
|
|
5
5
|
longitudeProps?: string;
|
|
6
6
|
/** 纬度属性名,默认 latitude */
|
|
7
7
|
latitudeProps?: string;
|
|
8
|
-
/** 经纬度变化回调 */
|
|
9
|
-
onConfirm?: (longitude: number | string, latitude: number | string) => void;
|
|
10
8
|
/** 经纬度是否必填,默认 true */
|
|
11
9
|
required?: boolean;
|
|
10
|
+
/** 所属区域 */
|
|
11
|
+
area?: string;
|
|
12
|
+
/** 是否显示所属区域 */
|
|
13
|
+
showArea?: boolean;
|
|
14
|
+
/** 确认选择回调 */
|
|
15
|
+
onConfirm?: (longitude: number | string, latitude: number | string, extra: { area: string }) => void;
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
/**
|
|
19
|
+
* 定位组件
|
|
20
|
+
*/
|
|
14
21
|
declare const Map: FC<MapProps>;
|
|
15
22
|
|
|
16
23
|
export default Map;
|
package/components/Map/index.js
CHANGED
|
@@ -11,6 +11,8 @@ const Map = (props) => {
|
|
|
11
11
|
latitudeProps = "latitude",
|
|
12
12
|
onConfirm,
|
|
13
13
|
required = true,
|
|
14
|
+
area = "",
|
|
15
|
+
showArea = false,
|
|
14
16
|
} = props;
|
|
15
17
|
|
|
16
18
|
const form = Form.useFormInstance();
|
|
@@ -18,14 +20,14 @@ const Map = (props) => {
|
|
|
18
20
|
const [currentLongitude, setCurrentLongitude] = useState(form.getFieldValue(longitudeProps) || "");
|
|
19
21
|
const [currentLatitude, setCurrentLatitude] = useState(form.getFieldValue(latitudeProps) || "");
|
|
20
22
|
|
|
21
|
-
const handleMapConfirm = (longitudeValue, latitudeValue) => {
|
|
23
|
+
const handleMapConfirm = (longitudeValue, latitudeValue, extra) => {
|
|
22
24
|
setCurrentLongitude(longitudeValue);
|
|
23
25
|
setCurrentLatitude(latitudeValue);
|
|
24
26
|
form.setFieldsValue({
|
|
25
27
|
[longitudeProps]: longitudeValue,
|
|
26
28
|
[latitudeProps]: latitudeValue,
|
|
27
29
|
});
|
|
28
|
-
onConfirm?.(longitudeValue, latitudeValue);
|
|
30
|
+
onConfirm?.(longitudeValue, latitudeValue, extra);
|
|
29
31
|
setMapVisible(false);
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -44,7 +46,7 @@ const Map = (props) => {
|
|
|
44
46
|
<Input disabled />
|
|
45
47
|
</Form.Item>
|
|
46
48
|
<Button type="primary" onClick={() => setMapVisible(true)}>
|
|
47
|
-
|
|
49
|
+
地图定位
|
|
48
50
|
</Button>
|
|
49
51
|
</div>
|
|
50
52
|
</Form.Item>
|
|
@@ -55,6 +57,8 @@ const Map = (props) => {
|
|
|
55
57
|
onClose={() => setMapVisible(false)}
|
|
56
58
|
longitude={currentLongitude}
|
|
57
59
|
latitude={currentLatitude}
|
|
60
|
+
area={area}
|
|
61
|
+
showArea={showArea}
|
|
58
62
|
onConfirm={handleMapConfirm}
|
|
59
63
|
/>
|
|
60
64
|
</>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicSelectProps } from "../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface DictionarySelectProps extends Omit<BasicSelectProps, "data" | "nameKey" | "idKey"> {
|
|
8
|
+
/** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */
|
|
9
|
+
appKey?: string;
|
|
10
|
+
/** 要获取的字典 */
|
|
11
|
+
dictValue: string;
|
|
12
|
+
/** 树形数据 label 字段,默认 dictLabel */
|
|
13
|
+
nameKey?: string;
|
|
14
|
+
/** 树形数据 value 字段,默认 dictValue */
|
|
15
|
+
idKey?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 数据字典下拉组件
|
|
20
|
+
*/
|
|
21
|
+
declare const DictionarySelect: FC<DictionarySelectProps>;
|
|
22
|
+
|
|
23
|
+
export default DictionarySelect;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary";
|
|
4
|
+
import BasicSelect from "../Basic";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 数据字典下拉组件
|
|
8
|
+
*/
|
|
9
|
+
function DictionarySelect(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 [data, setData] = useState([]);
|
|
19
|
+
|
|
20
|
+
const getData = async () => {
|
|
21
|
+
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey))
|
|
22
|
+
throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
23
|
+
|
|
24
|
+
setData([]);
|
|
25
|
+
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
|
|
26
|
+
setData(data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
dictValue && getData();
|
|
31
|
+
}, [dictValue]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<BasicSelect treeData={data} nameKey={nameKey} idKey={idKey} {...restProps} />
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
DictionarySelect.displayName = "DictionarySelect";
|
|
39
|
+
|
|
40
|
+
export default DictionarySelect;
|
|
@@ -16,7 +16,7 @@ export interface Params {
|
|
|
16
16
|
/**
|
|
17
17
|
* 组件属性
|
|
18
18
|
*/
|
|
19
|
-
export interface PersonnelSelectProps extends Omit<BasicSelectProps, "data"> {
|
|
19
|
+
export interface PersonnelSelectProps extends Omit<BasicSelectProps, "data" | "placeholder" | "nameKey" | "idKey"> {
|
|
20
20
|
/** 请求参数 */
|
|
21
21
|
params?: Params;
|
|
22
22
|
/** 占位符,默认"人员" */
|
|
@@ -4,7 +4,7 @@ import type { BasicSelectTreeProps } from "../Basic";
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
6
6
|
*/
|
|
7
|
-
export interface AreaSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData"> {
|
|
7
|
+
export interface AreaSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
8
|
/** 占位符,默认"属地" */
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
}
|
|
@@ -4,12 +4,12 @@ import type { FC } from "react";
|
|
|
4
4
|
/**
|
|
5
5
|
* 组件属性
|
|
6
6
|
*/
|
|
7
|
-
export interface BasicSelectTreeProps extends TreeSelectProps {
|
|
7
|
+
export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"> {
|
|
8
8
|
/** 树形数据 label 字段,默认 name */
|
|
9
9
|
nameKey?: string;
|
|
10
10
|
/** 树形数据 value 字段,默认 id */
|
|
11
11
|
idKey?: string;
|
|
12
|
-
/** 树形数据 children 字段,默认
|
|
12
|
+
/** 树形数据 children 字段,默认 children */
|
|
13
13
|
childrenKey?: string;
|
|
14
14
|
/** 决定 onGetNodePaths 是否包含自身节点,默认 true */
|
|
15
15
|
onGetNodePathsIsIncludeOneself?: boolean;
|
|
@@ -16,7 +16,7 @@ function BasicSelectTree(props) {
|
|
|
16
16
|
treeData = [],
|
|
17
17
|
nameKey = "name",
|
|
18
18
|
idKey = "id",
|
|
19
|
-
childrenKey = "
|
|
19
|
+
childrenKey = "children",
|
|
20
20
|
level,
|
|
21
21
|
...restProps
|
|
22
22
|
} = props;
|
|
@@ -24,11 +24,11 @@ function BasicSelectTree(props) {
|
|
|
24
24
|
// 根据 level 处理树数据
|
|
25
25
|
const processedTreeData = level
|
|
26
26
|
? processTreeDataByLevel({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
data: treeData,
|
|
28
|
+
level,
|
|
29
|
+
childrenKey,
|
|
30
|
+
currentLevel: 1,
|
|
31
|
+
})
|
|
32
32
|
: treeData;
|
|
33
33
|
|
|
34
34
|
const handleChange = (value, label, extra) => {
|
|
@@ -5,7 +5,7 @@ import type { BasicSelectTreeProps } from "../../Basic";
|
|
|
5
5
|
/**
|
|
6
6
|
* 组件属性
|
|
7
7
|
*/
|
|
8
|
-
export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData"> {
|
|
8
|
+
export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey"> {
|
|
9
9
|
/** 请求参数 */
|
|
10
10
|
params?: Params;
|
|
11
11
|
/** 占位符,默认"部门" */
|
|
@@ -34,7 +34,7 @@ function DepartmentSelectTree(props) {
|
|
|
34
34
|
}, [JSON.stringify(params), isNeedCorpInfoId, isNeedParentId]);
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
|
-
<BasicSelectTree treeData={treeData} placeholder={placeholder} {...restProps} />
|
|
37
|
+
<BasicSelectTree treeData={treeData} placeholder={placeholder} childrenKey="childrenList" {...restProps} />
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicSelectTreeProps } from "../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface DictionarySelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey"> {
|
|
8
|
+
/** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */
|
|
9
|
+
appKey?: string;
|
|
10
|
+
/** 要获取的字典 */
|
|
11
|
+
dictValue: string;
|
|
12
|
+
/** 树形数据 label 字段,默认 dictLabel */
|
|
13
|
+
nameKey?: string;
|
|
14
|
+
/** 树形数据 value 字段,默认 dictValue */
|
|
15
|
+
idKey?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 数据字典下拉树组件
|
|
20
|
+
*/
|
|
21
|
+
declare const DictionarySelectTree: FC<DictionarySelectTreeProps>;
|
|
22
|
+
|
|
23
|
+
export default DictionarySelectTree;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { DICTIONARY_APP_KEY_ENUM } from "../../../enum/dictionary";
|
|
4
|
+
import BasicSelectTree from "../Basic";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 数据字典下拉树组件
|
|
8
|
+
*/
|
|
9
|
+
function DictionarySelectTree(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
|
+
throw new Error("传入的 appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
23
|
+
|
|
24
|
+
setTreeData([]);
|
|
25
|
+
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey, dictValue });
|
|
26
|
+
setTreeData(data);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
dictValue && getData();
|
|
31
|
+
}, [dictValue]);
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<BasicSelectTree treeData={treeData} nameKey={nameKey} idKey={idKey} {...restProps} />
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
DictionarySelectTree.displayName = "DictionarySelectTree";
|
|
39
|
+
|
|
40
|
+
export default DictionarySelectTree;
|
|
@@ -62,6 +62,7 @@ export const UPLOAD_FILE_TYPE_ENUM = {
|
|
|
62
62
|
133: 133,
|
|
63
63
|
134: 134,
|
|
64
64
|
135: 135,
|
|
65
|
+
136: 136,
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
/**
|
|
@@ -128,4 +129,5 @@ export const UPLOAD_FILE_PATH_ENUM = {
|
|
|
128
129
|
133: "branch_safety_director_approval",
|
|
129
130
|
134: "project_authority_review_signature",
|
|
130
131
|
135: "branch_manager_approval_signature",
|
|
132
|
+
136: "accident_incident",
|
|
131
133
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface getDictionaryOptions {
|
|
2
|
+
/** appKey,默认 DICTIONARY_APP_KEY_ENUM.DEFAULT(0bb989ecada5470c87635018ece9f327) */
|
|
3
|
+
appKey?: string;
|
|
4
|
+
/** 要获取的字典 */
|
|
5
|
+
dictValue: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DictionaryItem {
|
|
9
|
+
/** label */
|
|
10
|
+
dictLabel: string;
|
|
11
|
+
/** value */
|
|
12
|
+
dictValue: string;
|
|
13
|
+
/** 子级 */
|
|
14
|
+
children: DictionaryItem[];
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type getDictionaryFunction = (options: getDictionaryOptions) => Promise<DictionaryItem[]>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 获取数据字典
|
|
22
|
+
*/
|
|
23
|
+
export default function useDictionary(returnType: "array"): [boolean, getDictionaryFunction];
|
|
24
|
+
export default function useDictionary(returnType?: "object"): { loading: boolean; getDictionary: getDictionaryFunction };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { request } from "@cqsjjb/jjb-common-lib/http";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { DICTIONARY_APP_KEY_ENUM } from "../../enum/dictionary";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取数据字典
|
|
7
|
+
*/
|
|
8
|
+
function useDictionary(returnType = "object") {
|
|
9
|
+
// loading状态
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
|
|
12
|
+
// 获取数据字典
|
|
13
|
+
const getDictionary = (options) => {
|
|
14
|
+
if (!options)
|
|
15
|
+
throw new Error("请传入 options");
|
|
16
|
+
|
|
17
|
+
setLoading(true);
|
|
18
|
+
|
|
19
|
+
return new Promise((resolve, reject) => {
|
|
20
|
+
const { appKey = DICTIONARY_APP_KEY_ENUM.DEFAULT, dictValue } = options;
|
|
21
|
+
|
|
22
|
+
if (!Object.values(DICTIONARY_APP_KEY_ENUM).includes(appKey))
|
|
23
|
+
throw new Error("传入的 options.appKey 不在 DICTIONARY_APP_KEY_ENUM 中");
|
|
24
|
+
if (!dictValue)
|
|
25
|
+
throw new Error("请传入 options.dictValue");
|
|
26
|
+
|
|
27
|
+
// 发送请求
|
|
28
|
+
request(
|
|
29
|
+
"/config/dict-trees/list/by/dictValues",
|
|
30
|
+
"get",
|
|
31
|
+
{ appKey, dictValue },
|
|
32
|
+
)
|
|
33
|
+
.then((res) => {
|
|
34
|
+
resolve(res.data);
|
|
35
|
+
})
|
|
36
|
+
.catch((err) => {
|
|
37
|
+
reject(err);
|
|
38
|
+
})
|
|
39
|
+
.finally(() => {
|
|
40
|
+
setLoading(false);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (returnType === "array")
|
|
46
|
+
return [loading, getDictionary];
|
|
47
|
+
return { loading, getDictionary };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default useDictionary;
|