zy-react-library 1.0.79 → 1.0.81
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/FormBuilder/FormBuilder.js +1 -1
- package/components/HiddenInfo/gwj/index.js +9 -7
- package/components/SelectTree/Basic/index.d.ts +2 -0
- package/components/SelectTree/Basic/index.js +6 -2
- package/components/SelectTree/HiddenLevel/Gwj/index.d.ts +21 -0
- package/components/SelectTree/HiddenLevel/Gwj/index.js +72 -0
- package/hooks/useTable/index.js +1 -1
- package/package.json +1 -1
- package/utils/index.d.ts +19 -0
- package/utils/index.js +27 -0
|
@@ -90,15 +90,17 @@ function HiddenInfo(props) {
|
|
|
90
90
|
{ label: "隐患状态", children: getLabelName({ list: HIDDEN_STATE_ENUM, status: info.state }) },
|
|
91
91
|
{ label: "隐患描述", children: info.hiddenDesc },
|
|
92
92
|
{ label: "隐患部位", children: info.hiddenPart },
|
|
93
|
-
...(
|
|
93
|
+
...(
|
|
94
|
+
(info.source === 2 || info.source === 3) && (info.hiddenCheckListCO && Object.keys(info.hiddenCheckListCO).length > 0)
|
|
94
95
|
? [
|
|
95
|
-
{ label: "风险点(单元)", children:
|
|
96
|
-
{ label: "辨识部位", children:
|
|
97
|
-
{ label: "存在风险", children:
|
|
98
|
-
{ label: "风险分级", children:
|
|
99
|
-
{ label: "隐患清单", children:
|
|
96
|
+
{ label: "风险点(单元)", children: info.hiddenCheckListCO.listRiskPoints },
|
|
97
|
+
{ label: "辨识部位", children: info.hiddenCheckListCO.identifiedLocations },
|
|
98
|
+
{ label: "存在风险", children: info.hiddenCheckListCO.existingRisks },
|
|
99
|
+
{ label: "风险分级", children: info.hiddenCheckListCO.riskLevel },
|
|
100
|
+
{ label: "隐患清单", children: info.hiddenCheckListCO.listName },
|
|
100
101
|
]
|
|
101
|
-
: []
|
|
102
|
+
: []
|
|
103
|
+
),
|
|
102
104
|
{
|
|
103
105
|
label: "隐患上报位置(经纬度)",
|
|
104
106
|
children: [info.longitude && `经度:${info.longitude}`, info.latitude && `纬度:${info.latitude}`].filter(Boolean).join(" "),
|
|
@@ -23,6 +23,8 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
|
|
|
23
23
|
onGetLabel?: (label: string) => void;
|
|
24
24
|
/** 获取数据 */
|
|
25
25
|
onGetData?: (data: Record<string, any>[], processedData: Record<string, any>[]) => void;
|
|
26
|
+
/** 是否只允许选择最后一级,默认 false */
|
|
27
|
+
onlyLastLevel?: boolean;
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TreeSelect } from "antd";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
|
|
3
|
+
import { getTreeNodePaths, processTreeDataByLevel, processTreeDataForOnlyLastLevel } from "../../../utils";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* 基础下拉树组件(不建议直接使用此组件,二次继承使用)
|
|
@@ -18,11 +18,12 @@ function BasicSelectTree(props) {
|
|
|
18
18
|
idKey = "id",
|
|
19
19
|
childrenKey = "children",
|
|
20
20
|
level,
|
|
21
|
+
onlyLastLevel = false,
|
|
21
22
|
...restProps
|
|
22
23
|
} = props;
|
|
23
24
|
|
|
24
25
|
// 根据 level 处理树数据
|
|
25
|
-
|
|
26
|
+
let processedTreeData = level
|
|
26
27
|
? processTreeDataByLevel({
|
|
27
28
|
data: treeData,
|
|
28
29
|
level,
|
|
@@ -31,6 +32,9 @@ function BasicSelectTree(props) {
|
|
|
31
32
|
})
|
|
32
33
|
: treeData;
|
|
33
34
|
|
|
35
|
+
// 根据 onlyLastLevel 处理树数据
|
|
36
|
+
processedTreeData = processTreeDataForOnlyLastLevel({ data: processedTreeData, childrenKey, onlyLastLevel });
|
|
37
|
+
|
|
34
38
|
const handleChange = (value, label, extra) => {
|
|
35
39
|
if (value) {
|
|
36
40
|
const parentNodes = getTreeNodePaths({
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FC } from "react";
|
|
2
|
+
import type { BasicSelectTreeProps } from "../../Basic";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件属性
|
|
6
|
+
*/
|
|
7
|
+
export interface HiddenLevelSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey" | "level"> {
|
|
8
|
+
/** 是否显示忽略隐患,默认 true */
|
|
9
|
+
isShowNeglect?: boolean;
|
|
10
|
+
/** 是否显示较大隐患,默认 true */
|
|
11
|
+
isShowLarger?: boolean;
|
|
12
|
+
/** 是否显示重大隐患,默认 true */
|
|
13
|
+
isShowMajor?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 隐患级别下拉树组件(港务局版本)
|
|
18
|
+
*/
|
|
19
|
+
declare const HiddenLevelSelectTree: FC<HiddenLevelSelectTreeProps>;
|
|
20
|
+
|
|
21
|
+
export default HiddenLevelSelectTree;
|
|
@@ -0,0 +1,72 @@
|
|
|
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 HiddenLevelSelectTree(props) {
|
|
10
|
+
const {
|
|
11
|
+
isShowNeglect = true,
|
|
12
|
+
isShowLarger = true,
|
|
13
|
+
isShowMajor = true,
|
|
14
|
+
...restProps
|
|
15
|
+
} = props;
|
|
16
|
+
|
|
17
|
+
const [treeData, setTreeData] = useState([]);
|
|
18
|
+
|
|
19
|
+
// 过滤隐患级别的树数据
|
|
20
|
+
const filterTreeData = (treeData) => {
|
|
21
|
+
// 隐患级别的特定ID
|
|
22
|
+
const HIDDEN_LEVEL_IDS = {
|
|
23
|
+
neglect: "hiddenLevel1001", // 忽略隐患
|
|
24
|
+
larger: "jdyh001", // 较大隐患
|
|
25
|
+
major: "hiddenLevel0002", // 重大隐患
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 递归过滤树数据
|
|
29
|
+
const filterTree = (nodes) => {
|
|
30
|
+
if (!nodes || !Array.isArray(nodes))
|
|
31
|
+
return [];
|
|
32
|
+
|
|
33
|
+
return nodes.filter((node) => {
|
|
34
|
+
// 根据不同的ID和对应的props来决定是否显示
|
|
35
|
+
if (node.dictValue === HIDDEN_LEVEL_IDS.neglect)
|
|
36
|
+
return isShowNeglect;
|
|
37
|
+
if (node.dictValue === HIDDEN_LEVEL_IDS.larger)
|
|
38
|
+
return isShowLarger;
|
|
39
|
+
if (node.dictValue === HIDDEN_LEVEL_IDS.major)
|
|
40
|
+
return isShowMajor;
|
|
41
|
+
|
|
42
|
+
// 如果有子节点,递归过滤子节点
|
|
43
|
+
if (node.children && node.children.length > 0)
|
|
44
|
+
node.children = filterTree(node.children);
|
|
45
|
+
|
|
46
|
+
// 默认显示其他节点
|
|
47
|
+
return true;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return filterTree(treeData);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const getData = async () => {
|
|
55
|
+
setTreeData([]);
|
|
56
|
+
const { data } = await request("/config/dict-trees/list/by/dictValues", "get", { appKey: DICTIONARY_APP_KEY_ENUM.GWJ, dictValue: "hiddenLevel" });
|
|
57
|
+
const filterData = filterTreeData(data);
|
|
58
|
+
setTreeData(filterData);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
getData();
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<BasicSelectTree treeData={treeData} nameKey="dictLabel" idKey="dictValue" {...restProps} />
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
HiddenLevelSelectTree.displayName = "HiddenLevelSelectTree";
|
|
71
|
+
|
|
72
|
+
export default HiddenLevelSelectTree;
|
package/hooks/useTable/index.js
CHANGED
|
@@ -115,7 +115,7 @@ function useTable(service, options) {
|
|
|
115
115
|
usePagination = true,
|
|
116
116
|
defaultType = "advance",
|
|
117
117
|
defaultCurrent = 1,
|
|
118
|
-
defaultPageSize =
|
|
118
|
+
defaultPageSize = 20,
|
|
119
119
|
defaultPagination = { current: defaultCurrent, pageSize: defaultPageSize },
|
|
120
120
|
...restRestOptions
|
|
121
121
|
} = restOptions;
|
package/package.json
CHANGED
package/utils/index.d.ts
CHANGED
|
@@ -301,3 +301,22 @@ export function processTreeDataByLevel(
|
|
|
301
301
|
/** 子节点 */
|
|
302
302
|
[key: string]: any;
|
|
303
303
|
}[];
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* 根据 onlyLastLevel 属性处理树数据,添加 selectable 属性控制节点是否可选择
|
|
307
|
+
*/
|
|
308
|
+
export function processTreeDataForOnlyLastLevel(
|
|
309
|
+
options: {
|
|
310
|
+
/** 树形数据 */
|
|
311
|
+
data: any[];
|
|
312
|
+
/** 子节点字段名 */
|
|
313
|
+
childrenKey: string;
|
|
314
|
+
/** 是否只允许选择最后一级 */
|
|
315
|
+
onlyLastLevel?: boolean;
|
|
316
|
+
},
|
|
317
|
+
): {
|
|
318
|
+
/** 是否允许选择 */
|
|
319
|
+
selectable: boolean;
|
|
320
|
+
/** 子节点 */
|
|
321
|
+
[key: string]: any;
|
|
322
|
+
}[];
|
package/utils/index.js
CHANGED
|
@@ -462,6 +462,33 @@ export const processTreeDataByLevel = (options) => {
|
|
|
462
462
|
});
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
+
/**
|
|
466
|
+
* 根据 onlyLastLevel 属性处理树数据,添加 selectable 属性控制节点是否可选择
|
|
467
|
+
*/
|
|
468
|
+
export const processTreeDataForOnlyLastLevel = (options) => {
|
|
469
|
+
const { data, childrenKey, onlyLastLevel = false } = options;
|
|
470
|
+
if (!onlyLastLevel)
|
|
471
|
+
return data;
|
|
472
|
+
|
|
473
|
+
return data.map((item) => {
|
|
474
|
+
// 检查是否有子节点
|
|
475
|
+
const hasChildren = item[childrenKey] && item[childrenKey].length > 0;
|
|
476
|
+
|
|
477
|
+
// 如果有子节点,则不可选择
|
|
478
|
+
const processedItem = {
|
|
479
|
+
...item,
|
|
480
|
+
selectable: !hasChildren,
|
|
481
|
+
};
|
|
482
|
+
|
|
483
|
+
// 递归处理子节点
|
|
484
|
+
if (hasChildren) {
|
|
485
|
+
processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return processedItem;
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
|
|
465
492
|
/**
|
|
466
493
|
* 获取文件url
|
|
467
494
|
*/
|