refactor(types): 重构组件类型定义提升类型安全性和可维护性
- 将内部 Data 接口重命名为具体业务含义的接口 - 导出原本私有的类型定义以供外部使用master
parent
25e9dfb228
commit
e352f8396e
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicCascaderProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface AreaCascaderItem {
|
||||
value: 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"> {
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: AreaCascaderItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: AreaCascaderItem[], processedData: AreaCascaderItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicCascaderProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DictionaryCascaderItem {
|
||||
dictValue: string;
|
||||
dictLabel: string;
|
||||
children: Data[];
|
||||
children: DictionaryCascaderItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ export interface DictionaryCascaderProps extends Omit<BasicCascaderProps, "optio
|
|||
/** 树形数据 value 字段,默认 dictValue */
|
||||
idKey?: string;
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: DictionaryCascaderItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: DictionaryCascaderItem[], processedData: DictionaryCascaderItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicCascaderProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface IndustryCascaderItem {
|
||||
dict_value: 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"> {
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: IndustryCascaderItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: IndustryCascaderItem[], processedData: IndustryCascaderItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -7,7 +7,14 @@ import type { ReactElement, ReactNode } from "react";
|
|||
import type { FORM_ITEM_RENDER_TYPE_MAP } from "../../enum/formItemRender";
|
||||
import type { DeepPartial } from "./FormBuilder";
|
||||
|
||||
/**
|
||||
* Form.List name 类型
|
||||
*/
|
||||
export type FormListOptionName<Values> = [number, NamePath<Values>];
|
||||
|
||||
/**
|
||||
* Form.List 依赖项类型
|
||||
*/
|
||||
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>>;
|
||||
|
||||
/**
|
||||
* 表单配置项公共字段
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicLeftTreeProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface AreaLeftTreeItem {
|
||||
value: string;
|
||||
label: string;
|
||||
children: Data[];
|
||||
children: AreaLeftTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -13,9 +13,9 @@ interface Data {
|
|||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ import type { FC } from "react";
|
|||
import type { DepartmentSelectTreeProps } from "../../../SelectTree/Department/Gwj";
|
||||
import type { BasicLeftTreeProps } from "../../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DepartmentLeftTreeItem {
|
||||
id: string;
|
||||
name: string;
|
||||
childrenList: Data[];
|
||||
childrenList: DepartmentLeftTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -18,9 +18,9 @@ export interface DepartmentLeftTreeProps extends Omit<BasicLeftTreeProps, "treeD
|
|||
/** 查询的企业类型 */
|
||||
searchType?: DepartmentSelectTreeProps["searchType"];
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: DepartmentLeftTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: DepartmentLeftTreeItem[], processedData: DepartmentLeftTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicLeftTreeProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DictionaryLeftTreeItem {
|
||||
dictValue: string;
|
||||
dictLabel: string;
|
||||
children: Data[];
|
||||
children: DictionaryLeftTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ export interface DictionaryLeftTreeProps extends Omit<BasicLeftTreeProps, "treeD
|
|||
/** 树形数据 value 字段,默认 dictValue */
|
||||
idKey?: string;
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: DictionaryLeftTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: DictionaryLeftTreeItem[], processedData: DictionaryLeftTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DictionarySelectItem {
|
||||
dictValue: string;
|
||||
dictLabel: string;
|
||||
[key: string]: any;
|
||||
|
|
@ -20,9 +20,9 @@ export interface DictionarySelectProps extends Omit<BasicSelectProps, "data" | "
|
|||
/** 树形数据 value 字段,默认 dictValue */
|
||||
idKey?: string;
|
||||
/** 获取选中的项 */
|
||||
onGetOption?: (option: Data | Data[]) => void;
|
||||
onGetOption?: (option: DictionarySelectItem | DictionarySelectItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[]) => void;
|
||||
onGetData?: (data: DictionarySelectItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectProps } from "../../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface PersonnelSelectItem {
|
||||
id: string;
|
||||
name: string;
|
||||
corpinfoId: string;
|
||||
|
|
@ -59,9 +59,9 @@ export interface PersonnelSelectProps extends Omit<BasicSelectProps, "data" | "p
|
|||
/** 额外请求参数 */
|
||||
extraParams?: ExtraParams;
|
||||
/** 获取选中的项 */
|
||||
onGetOption?: (option: Data | Data[]) => void;
|
||||
onGetOption?: (option: PersonnelSelectItem | PersonnelSelectItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[]) => void;
|
||||
onGetData?: (data: PersonnelSelectItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface AreaSelectTreeItem {
|
||||
value: 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"> {
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: AreaSelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: AreaSelectTreeItem[], processedData: AreaSelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DepartmentSelectTreeItem {
|
||||
id: string;
|
||||
name: string;
|
||||
childrenList: Data[];
|
||||
childrenList: DepartmentSelectTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -47,9 +47,9 @@ export interface DepartmentSelectTreeProps extends Omit<BasicSelectTreeProps, "t
|
|||
/** 查询的企业类型,默认current,current 接收 eqCorpinfoId 或者 eqParentId,all 不接受任何参数,inType 接收 inType 或者 enterpriseType */
|
||||
searchType?: "current" | "all" | "inType";
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: DepartmentSelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: DepartmentSelectTreeItem[], processedData: DepartmentSelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface DictionarySelectTreeItem {
|
||||
dictValue: string;
|
||||
dictLabel: string;
|
||||
children: Data[];
|
||||
children: DictionarySelectTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ export interface DictionarySelectTreeProps extends Omit<BasicSelectTreeProps, "t
|
|||
/** 树形数据 value 字段,默认 dictValue */
|
||||
idKey?: string;
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: DictionarySelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: DictionarySelectTreeItem[], processedData: DictionarySelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface HiddenLevelSelectTreeItem {
|
||||
dictValue: string;
|
||||
dictLabel: string;
|
||||
children: Data[];
|
||||
children: HiddenLevelSelectTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -19,9 +19,9 @@ export interface HiddenLevelSelectTreeProps extends Omit<BasicSelectTreeProps, "
|
|||
/** 是否显示重大隐患,默认 true */
|
||||
isShowMajor?: boolean;
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: HiddenLevelSelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: HiddenLevelSelectTreeItem[], processedData: HiddenLevelSelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface HiddenPartSelectTreeItem {
|
||||
hiddenregionId: string;
|
||||
hiddenregion: string;
|
||||
children: Data[];
|
||||
children: HiddenPartSelectTreeItem[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
|
|
@ -25,9 +25,9 @@ export interface HiddenPartSelectTreeProps extends Omit<BasicSelectTreeProps, "t
|
|||
/** 是否需要企业id,默认 false */
|
||||
isNeedCorpInfoId?: boolean;
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: HiddenPartSelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: HiddenPartSelectTreeItem[], processedData: HiddenPartSelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import type { FC } from "react";
|
||||
import type { BasicSelectTreeProps } from "../Basic";
|
||||
|
||||
interface Data {
|
||||
export interface IndustrySelectTreeItem {
|
||||
dict_value: 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"> {
|
||||
/** 获取父级节点 */
|
||||
onGetNodePaths?: (nodes: Data[]) => void;
|
||||
onGetNodePaths?: (nodes: IndustrySelectTreeItem[]) => void;
|
||||
/** 获取数据 */
|
||||
onGetData?: (data: Data[], processedData: Data[]) => void;
|
||||
onGetData?: (data: IndustrySelectTreeItem[], processedData: IndustrySelectTreeItem[]) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export interface FileItem {
|
||||
export interface GetFileItem {
|
||||
/** 文件路径 */
|
||||
filePath: string;
|
||||
/** 文件名称 */
|
||||
|
|
@ -33,9 +33,9 @@ export interface MultipleGetFileOptions extends BaseParams {
|
|||
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 {
|
||||
(options: SingleGetFileOptions): Promise<SingleFileResponse>;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
interface Data {
|
||||
interface UserInfoData {
|
||||
corpinfoId: string;
|
||||
corpinfoName: string;
|
||||
departmentId: string;
|
||||
|
|
@ -12,7 +12,7 @@ interface Data {
|
|||
[key: string]: any;
|
||||
}
|
||||
|
||||
export type getUserInfoFunction = () => Promise<Data>;
|
||||
export type getUserInfoFunction = () => Promise<UserInfoData>;
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
|
|
|
|||
Loading…
Reference in New Issue