refactor(types): 重构组件类型定义提升类型安全性和可维护性

- 将内部 Data 接口重命名为具体业务含义的接口
- 导出原本私有的类型定义以供外部使用
master
LiuJiaNan 2026-05-08 09:55:46 +08:00
parent 25e9dfb228
commit e352f8396e
17 changed files with 68 additions and 61 deletions

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicCascaderProps } from "../Basic"; import type { BasicCascaderProps } from "../Basic";
interface Data { export interface AreaCascaderItem {
value: string; value: string;
label: string; label: string;
children: Data[]; children: AreaCascaderItem[];
} }
/** /**
@ -12,9 +12,9 @@ interface Data {
*/ */
export interface AreaCascaderProps extends Omit<BasicCascaderProps, "options" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> { export interface AreaCascaderProps extends Omit<BasicCascaderProps, "options" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> {
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: AreaCascaderItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: AreaCascaderItem[], processedData: AreaCascaderItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicCascaderProps } from "../Basic"; import type { BasicCascaderProps } from "../Basic";
interface Data { export interface DictionaryCascaderItem {
dictValue: string; dictValue: string;
dictLabel: string; dictLabel: string;
children: Data[]; children: DictionaryCascaderItem[];
[key: string]: any; [key: string]: any;
} }
@ -21,9 +21,9 @@ export interface DictionaryCascaderProps extends Omit<BasicCascaderProps, "optio
/** 树形数据 value 字段,默认 dictValue */ /** 树形数据 value 字段,默认 dictValue */
idKey?: string; idKey?: string;
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: DictionaryCascaderItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: DictionaryCascaderItem[], processedData: DictionaryCascaderItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicCascaderProps } from "../Basic"; import type { BasicCascaderProps } from "../Basic";
interface Data { export interface IndustryCascaderItem {
dict_value: string; dict_value: string;
dict_label: string; dict_label: string;
childrenList: Data[]; childrenList: IndustryCascaderItem[];
} }
/** /**
@ -12,9 +12,9 @@ interface Data {
*/ */
export interface IndustryCascaderProps extends Omit<BasicCascaderProps, "options" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> { export interface IndustryCascaderProps extends Omit<BasicCascaderProps, "options" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> {
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: IndustryCascaderItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: IndustryCascaderItem[], processedData: IndustryCascaderItem[]) => void;
} }
/** /**

View File

@ -7,7 +7,14 @@ import type { ReactElement, ReactNode } from "react";
import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender"; import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
import type { DeepPartial } from "./FormBuilder"; import type { DeepPartial } from "./FormBuilder";
/**
* Form.List name
*/
export type FormListOptionName<Values> = [number, NamePath<Values>]; export type FormListOptionName<Values> = [number, NamePath<Values>];
/**
* Form.List
*/
export type FormListOptionDependencies<Values> = Array<(NamePath<Values> | number)[]> | NamePath<Values>; export type FormListOptionDependencies<Values> = Array<(NamePath<Values> | number)[]> | NamePath<Values>;
/** /**
@ -72,12 +79,12 @@ export interface FormListUniqueProps<Values = any, AllValues = Values> {
/** /**
* *
*/ */
type WhenTrue<Condition extends boolean, T> = Condition extends true ? never : T; export type WhenTrue<Condition extends boolean, T> = Condition extends true ? never : T;
/** /**
* *
*/ */
type FormOptionProperty<IsOnlyForLabel extends boolean, IsCustomizeRender extends boolean, T> = WhenTrue<IsOnlyForLabel, WhenTrue<IsCustomizeRender, T>>; export type FormOptionProperty<IsOnlyForLabel extends boolean, IsCustomizeRender extends boolean, T> = WhenTrue<IsOnlyForLabel, WhenTrue<IsCustomizeRender, T>>;
/** /**
* *

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicLeftTreeProps } from "../Basic"; import type { BasicLeftTreeProps } from "../Basic";
interface Data { export interface AreaLeftTreeItem {
value: string; value: string;
label: string; label: string;
children: Data[]; children: AreaLeftTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -13,9 +13,9 @@ interface Data {
*/ */
export interface AreaLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> { export interface AreaLeftTreeProps extends Omit<BasicLeftTreeProps, "treeData" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> {
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: AreaLeftTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: AreaLeftTreeItem[], processedData: AreaLeftTreeItem[]) => void;
} }
/** /**

View File

@ -2,10 +2,10 @@ import type { FC } from "react";
import type { DepartmentSelectTreeProps } from "../../../SelectTree/Department/Gwj"; import type { DepartmentSelectTreeProps } from "../../../SelectTree/Department/Gwj";
import type { BasicLeftTreeProps } from "../../Basic"; import type { BasicLeftTreeProps } from "../../Basic";
interface Data { export interface DepartmentLeftTreeItem {
id: string; id: string;
name: string; name: string;
childrenList: Data[]; childrenList: DepartmentLeftTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -18,9 +18,9 @@ export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeD
/** 查询的企业类型 */ /** 查询的企业类型 */
searchType?: DepartmentSelectTreeProps["searchType"]; searchType?: DepartmentSelectTreeProps["searchType"];
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: DepartmentLeftTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: DepartmentLeftTreeItem[], processedData: DepartmentLeftTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicLeftTreeProps } from "../Basic"; import type { BasicLeftTreeProps } from "../Basic";
interface Data { export interface DictionaryLeftTreeItem {
dictValue: string; dictValue: string;
dictLabel: string; dictLabel: string;
children: Data[]; children: DictionaryLeftTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -21,9 +21,9 @@ export interface DictionaryLeftTreeProps extends Omit<BasicLeftTreeProps, "treeD
/** 树形数据 value 字段,默认 dictValue */ /** 树形数据 value 字段,默认 dictValue */
idKey?: string; idKey?: string;
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: DictionaryLeftTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: DictionaryLeftTreeItem[], processedData: DictionaryLeftTreeItem[]) => void;
} }
/** /**

View File

@ -1,7 +1,7 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectProps } from "../Basic"; import type { BasicSelectProps } from "../Basic";
interface Data { export interface DictionarySelectItem {
dictValue: string; dictValue: string;
dictLabel: string; dictLabel: string;
[key: string]: any; [key: string]: any;
@ -20,9 +20,9 @@ export interface DictionarySelectProps extends Omit<BasicSelectProps, "data" | "
/** 树形数据 value 字段,默认 dictValue */ /** 树形数据 value 字段,默认 dictValue */
idKey?: string; idKey?: string;
/** 获取选中的项 */ /** 获取选中的项 */
onGetOption?: (option: Data | Data[]) => void; onGetOption?: (option: DictionarySelectItem | DictionarySelectItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[]) => void; onGetData?: (data: DictionarySelectItem[]) => void;
} }
/** /**

View File

@ -1,7 +1,7 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectProps } from "../../Basic"; import type { BasicSelectProps } from "../../Basic";
interface Data { export interface PersonnelSelectItem {
id: string; id: string;
name: string; name: string;
corpinfoId: string; corpinfoId: string;
@ -59,9 +59,9 @@ export interface PersonnelSelectProps extends Omit<BasicSelectProps, "data" | "p
/** 额外请求参数 */ /** 额外请求参数 */
extraParams?: ExtraParams; extraParams?: ExtraParams;
/** 获取选中的项 */ /** 获取选中的项 */
onGetOption?: (option: Data | Data[]) => void; onGetOption?: (option: PersonnelSelectItem | PersonnelSelectItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[]) => void; onGetData?: (data: PersonnelSelectItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../Basic"; import type { BasicSelectTreeProps } from "../Basic";
interface Data { export interface AreaSelectTreeItem {
value: string; value: string;
label: string; label: string;
children: Data[]; children: AreaSelectTreeItem[];
} }
/** /**
@ -12,9 +12,9 @@ interface Data {
*/ */
export interface AreaSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> { export interface AreaSelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> {
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: AreaSelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: AreaSelectTreeItem[], processedData: AreaSelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../../Basic"; import type { BasicSelectTreeProps } from "../../Basic";
interface Data { export interface DepartmentSelectTreeItem {
id: string; id: string;
name: string; name: string;
childrenList: Data[]; childrenList: DepartmentSelectTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -47,9 +47,9 @@ export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "t
/** 查询的企业类型默认currentcurrent 接收 eqCorpinfoId 或者 eqParentIdall 不接受任何参数inType 接收 inType 或者 enterpriseType */ /** 查询的企业类型默认currentcurrent 接收 eqCorpinfoId 或者 eqParentIdall 不接受任何参数inType 接收 inType 或者 enterpriseType */
searchType?: "current" | "all" | "inType"; searchType?: "current" | "all" | "inType";
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: DepartmentSelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: DepartmentSelectTreeItem[], processedData: DepartmentSelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../Basic"; import type { BasicSelectTreeProps } from "../Basic";
interface Data { export interface DictionarySelectTreeItem {
dictValue: string; dictValue: string;
dictLabel: string; dictLabel: string;
children: Data[]; children: DictionarySelectTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -21,9 +21,9 @@ export interface DictionarySelectTreeProps extends Omit<BasicSelectTreeProps, "t
/** 树形数据 value 字段,默认 dictValue */ /** 树形数据 value 字段,默认 dictValue */
idKey?: string; idKey?: string;
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: DictionarySelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: DictionarySelectTreeItem[], processedData: DictionarySelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../../Basic"; import type { BasicSelectTreeProps } from "../../Basic";
interface Data { export interface HiddenLevelSelectTreeItem {
dictValue: string; dictValue: string;
dictLabel: string; dictLabel: string;
children: Data[]; children: HiddenLevelSelectTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -19,9 +19,9 @@ export interface HiddenLevelSelectTreeProps extends Omit<BasicSelectTreeProps, "
/** 是否显示重大隐患,默认 true */ /** 是否显示重大隐患,默认 true */
isShowMajor?: boolean; isShowMajor?: boolean;
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: HiddenLevelSelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: HiddenLevelSelectTreeItem[], processedData: HiddenLevelSelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../../Basic"; import type { BasicSelectTreeProps } from "../../Basic";
interface Data { export interface HiddenPartSelectTreeItem {
hiddenregionId: string; hiddenregionId: string;
hiddenregion: string; hiddenregion: string;
children: Data[]; children: HiddenPartSelectTreeItem[];
[key: string]: any; [key: string]: any;
} }
@ -25,9 +25,9 @@ export interface HiddenPartSelectTreeProps extends Omit<BasicSelectTreeProps, "t
/** 是否需要企业id默认 false */ /** 是否需要企业id默认 false */
isNeedCorpInfoId?: boolean; isNeedCorpInfoId?: boolean;
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: HiddenPartSelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: HiddenPartSelectTreeItem[], processedData: HiddenPartSelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,10 +1,10 @@
import type { FC } from "react"; import type { FC } from "react";
import type { BasicSelectTreeProps } from "../Basic"; import type { BasicSelectTreeProps } from "../Basic";
interface Data { export interface IndustrySelectTreeItem {
dict_value: string; dict_value: string;
dict_label: string; dict_label: string;
childrenList: Data[]; childrenList: IndustrySelectTreeItem[];
} }
/** /**
@ -12,9 +12,9 @@ interface Data {
*/ */
export interface IndustrySelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> { export interface IndustrySelectTreeProps extends Omit<BasicSelectTreeProps, "treeData" | "placeholder" | "nameKey" | "idKey" | "childrenKey" | "onGetNodePaths" | "onGetData"> {
/** 获取父级节点 */ /** 获取父级节点 */
onGetNodePaths?: (nodes: Data[]) => void; onGetNodePaths?: (nodes: IndustrySelectTreeItem[]) => void;
/** 获取数据 */ /** 获取数据 */
onGetData?: (data: Data[], processedData: Data[]) => void; onGetData?: (data: IndustrySelectTreeItem[], processedData: IndustrySelectTreeItem[]) => void;
} }
/** /**

View File

@ -1,4 +1,4 @@
export interface FileItem { export interface GetFileItem {
/** 文件路径 */ /** 文件路径 */
filePath: string; filePath: string;
/** 文件名称 */ /** 文件名称 */
@ -33,9 +33,9 @@ export interface MultipleGetFileOptions extends BaseParams {
dataSource: Record<string, any>[]; dataSource: Record<string, any>[];
} }
export type SingleFileResponse = FileItem[]; export type SingleFileResponse = GetFileItem[];
export type MultipleFileResponse = Array<Record<string, any> & { files: FileItem[] }>; export type MultipleFileResponse = Array<Record<string, any> & { files: GetFileItem[] }>;
export interface GetFileFunction { export interface GetFileFunction {
(options: SingleGetFileOptions): Promise<SingleFileResponse>; (options: SingleGetFileOptions): Promise<SingleFileResponse>;

View File

@ -1,4 +1,4 @@
interface Data { interface UserInfoData {
corpinfoId: string; corpinfoId: string;
corpinfoName: string; corpinfoName: string;
departmentId: string; departmentId: string;
@ -12,7 +12,7 @@ interface Data {
[key: string]: any; [key: string]: any;
} }
export type getUserInfoFunction = () => Promise<Data>; export type getUserInfoFunction = () => Promise<UserInfoData>;
/** /**
* *