master
parent
6f87ced6f1
commit
6cd0ad0182
|
|
@ -57,7 +57,7 @@ const FormBuilder = (props) => {
|
|||
</Button>
|
||||
)}
|
||||
{showCancelButton && (
|
||||
<Button onClick={handleCancel} style={{ marginRight: 8 }}>
|
||||
<Button onClick={handleCancel}>
|
||||
{cancelButtonText}
|
||||
</Button>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -90,15 +90,17 @@ function HiddenInfo(props) {
|
|||
{ label: "隐患状态", children: getLabelName({ list: HIDDEN_STATE_ENUM, status: info.state }) },
|
||||
{ label: "隐患描述", children: info.hiddenDesc },
|
||||
{ label: "隐患部位", children: info.hiddenPart },
|
||||
...(info.source === 2 || info.source === 3
|
||||
...(
|
||||
(info.source === 2 || info.source === 3) && (info.hiddenCheckListCO && Object.keys(info.hiddenCheckListCO).length > 0)
|
||||
? [
|
||||
{ label: "风险点(单元)", children: "todo" },
|
||||
{ label: "辨识部位", children: "todo" },
|
||||
{ label: "存在风险", children: "todo" },
|
||||
{ label: "风险分级", children: "todo" },
|
||||
{ label: "隐患清单", children: "todo" },
|
||||
{ label: "风险点(单元)", children: info.hiddenCheckListCO.listRiskPoints },
|
||||
{ label: "辨识部位", children: info.hiddenCheckListCO.identifiedLocations },
|
||||
{ label: "存在风险", children: info.hiddenCheckListCO.existingRisks },
|
||||
{ label: "风险分级", children: info.hiddenCheckListCO.riskLevel },
|
||||
{ label: "隐患清单", children: info.hiddenCheckListCO.listName },
|
||||
]
|
||||
: []),
|
||||
: []
|
||||
),
|
||||
{
|
||||
label: "隐患上报位置(经纬度)",
|
||||
children: [info.longitude && `经度:${info.longitude}`, info.latitude && `纬度:${info.latitude}`].filter(Boolean).join(" "),
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ export interface BasicSelectTreeProps extends Omit<TreeSelectProps, "fieldNames"
|
|||
onGetLabel?: (label: string) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Record<string, any>[], processedData: Record<string, any>[]) => void;
|
||||
/** 是否只允许选择最后一级,默认 false */
|
||||
onlyLastLevel?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { TreeSelect } from "antd";
|
||||
import { useEffect } from "react";
|
||||
import { getTreeNodePaths, processTreeDataByLevel } from "../../../utils";
|
||||
import { getTreeNodePaths, processTreeDataByLevel, processTreeDataForOnlyLastLevel } from "../../../utils";
|
||||
|
||||
/**
|
||||
* 基础下拉树组件(不建议直接使用此组件,二次继承使用)
|
||||
|
|
@ -18,11 +18,12 @@ function BasicSelectTree(props) {
|
|||
idKey = "id",
|
||||
childrenKey = "children",
|
||||
level,
|
||||
onlyLastLevel = false,
|
||||
...restProps
|
||||
} = props;
|
||||
|
||||
// 根据 level 处理树数据
|
||||
const processedTreeData = level
|
||||
let processedTreeData = level
|
||||
? processTreeDataByLevel({
|
||||
data: treeData,
|
||||
level,
|
||||
|
|
@ -31,6 +32,9 @@ function BasicSelectTree(props) {
|
|||
})
|
||||
: treeData;
|
||||
|
||||
// 根据 onlyLastLevel 处理树数据
|
||||
processedTreeData = processTreeDataForOnlyLastLevel({ data: processedTreeData, childrenKey, onlyLastLevel });
|
||||
|
||||
const handleChange = (value, label, extra) => {
|
||||
if (value) {
|
||||
const parentNodes = getTreeNodePaths({
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ function useTable(service, options) {
|
|||
usePagination = true,
|
||||
defaultType = "advance",
|
||||
defaultCurrent = 1,
|
||||
defaultPageSize = 10,
|
||||
defaultPageSize = 20,
|
||||
defaultPagination = { current: defaultCurrent, pageSize: defaultPageSize },
|
||||
...restRestOptions
|
||||
} = restOptions;
|
||||
|
|
|
|||
|
|
@ -301,3 +301,22 @@ export function processTreeDataByLevel(
|
|||
/** 子节点 */
|
||||
[key: string]: any;
|
||||
}[];
|
||||
|
||||
/**
|
||||
* 根据 onlyLastLevel 属性处理树数据,添加 selectable 属性控制节点是否可选择
|
||||
*/
|
||||
export function processTreeDataForOnlyLastLevel(
|
||||
options: {
|
||||
/** 树形数据 */
|
||||
data: any[];
|
||||
/** 子节点字段名 */
|
||||
childrenKey: string;
|
||||
/** 是否只允许选择最后一级 */
|
||||
onlyLastLevel?: boolean;
|
||||
},
|
||||
): {
|
||||
/** 是否允许选择 */
|
||||
selectable: boolean;
|
||||
/** 子节点 */
|
||||
[key: string]: any;
|
||||
}[];
|
||||
|
|
|
|||
|
|
@ -462,6 +462,33 @@ export const processTreeDataByLevel = (options) => {
|
|||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据 onlyLastLevel 属性处理树数据,添加 selectable 属性控制节点是否可选择
|
||||
*/
|
||||
export const processTreeDataForOnlyLastLevel = (options) => {
|
||||
const { data, childrenKey, onlyLastLevel = false } = options;
|
||||
if (!onlyLastLevel)
|
||||
return data;
|
||||
|
||||
return data.map((item) => {
|
||||
// 检查是否有子节点
|
||||
const hasChildren = item[childrenKey] && item[childrenKey].length > 0;
|
||||
|
||||
// 如果有子节点,则不可选择
|
||||
const processedItem = {
|
||||
...item,
|
||||
selectable: !hasChildren,
|
||||
};
|
||||
|
||||
// 递归处理子节点
|
||||
if (hasChildren) {
|
||||
processedItem[childrenKey] = processTreeDataForOnlyLastLevel({ data: item[childrenKey], childrenKey, onlyLastLevel });
|
||||
}
|
||||
|
||||
return processedItem;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取文件url
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue