zy-react-library 1.0.79 → 1.0.80
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/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({
|
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
|
*/
|