import { ReactNode } from 'react'; import { Service, Options, Result } from 'ahooks/lib/useRequest/src/types'; import type { TreeSelectProps } from 'antd'; import { ProFormOtherProps } from '../ProForm/propsType'; export interface TreeDataProps { label?: string; value?: string; children?: TreeDataProps[]; [key: string]: any; } type AllValueType = string | number; type Key = string | number; export interface FieldNamesType { label?: string; value: string; children?: string; } export interface ProTreeProps extends PropTreeSelectProps { /** 树标题 */ title?: string; /** value */ value?: AllValueType | string[]; /** 选中的树节点value */ checkedValues?: any; /** 是否展示展开全部按钮,默认不展示 */ showExpand?: boolean; /** 默认 label、value、children */ fieldNames?: FieldNamesType; open?: boolean; /** 展示类型、默认treeSelect 树选择形式 */ mode?: 'tree' | 'list' | 'treeSelect'; /** 开启后、提交给后端 [{ label:xx, value: ""}] 形式 */ labelInValue?: boolean; /** 查看模式、同 disabled 一样 */ isView?: boolean; /** 使用ProEnum 的数据源 */ code?: string; /** 是否展示 code-label 形式 */ showCodeName?: boolean; /** 是否展示搜索输入框 */ showSearch?: boolean; /** 静态数据源 */ dataSource?: TreeDataProps[]; /** 禁用 */ disabled?: boolean; /** 复选模式下只读是否全显示节点 hide--隐藏未勾选 */ disabledMode?: string; /** 全选的标识给后端 */ allValue?: string | number; /** 提示语,treeSelect时使用 */ placeholder?: string; /** 父子节点选中状态不再关联 */ checkStrictly?: boolean; /** 树底部操作项 */ footer?: ReactNode; /** 树容器高度 */ height?: string; /** 树节点文本超长是否展示... */ showEllipse?: boolean; /** 树节点文本宽度 */ ellipseWidth?: string; /** value改变的回调 */ onChange?: (values: string[] | AllValueType) => void; /** 点击树节点触发 */ onSelect?: (values: string[] | AllValueType, info?: any) => any; /** 复选情况下点击checkbox触发,参照antd */ onCheck?: (values: string[] | AllValueType, info?: any) => any; /** 自定义展示 */ optionRender?: (item: any, searchStr: string) => string | ReactNode; /** 对后台返回数据进行格式化 */ transformResponse?: (data: any) => TreeDataProps[]; /** tags 集合 */ tags?: string[]; otherProps?: ProFormOtherProps; /** 远程请求接口 */ useRequest?: { service: Service; options?: Options; }; /** 自定义配置操作按钮函数,返回react node节点 */ menu?: (key: Key, item?: any) => ReactNode[]; /** 点击树节点是否开启loading遮罩,默认false */ loading?: boolean; /** antd属性 */ showLine?: boolean; className?: string; /** 是否支持多选 */ multiple?: boolean; /** 是否自动展开父节点 */ autoExpandParent?: boolean; /** 可勾选 */ checkable?: boolean; /** 可勾选 */ treeCheckable?: boolean; /** 默认展开所有树节点 */ defaultExpandAll?: boolean; /** 默认展开对应树节点 */ defaultExpandParent?: boolean; /** 默认展开指定的树节点 */ defaultExpandedKeys?: Key[]; /** (受控)展开指定的树节点 */ expandedKeys?: Key[]; /** (受控)选中复选框的树节点 */ checkedKeys?: Key[] | { checked: Key[]; halfChecked: Key[]; }; /** 默认选中复选框的树节点 */ defaultCheckedKeys?: Key[]; /** (受控)设置选中的树节点 */ selectedKeys?: Key[]; /** 默认选中的树节点 */ defaultSelectedKeys?: Key[]; selectable?: boolean; loadedKeys?: Key[]; style?: any; showIcon?: boolean; prefixCls?: string; children?: any; blockNode?: boolean; /** 点中的树节点key,表单模式下value有值该配置优先级降低 */ selectedKey?: string | number | undefined; } export interface DataProps { label?: string; value?: string; disabled?: boolean; disableCheckbox?: boolean; selectable?: boolean; checkable?: boolean; title?: string; } export interface DataOption { label?: string; value?: string; disabled?: boolean; disableCheckbox?: boolean; selectable?: boolean; checkable?: boolean; children?: DataProps[]; title?: string; [key: string]: any; } export interface BaseOptionType { disabled?: boolean; checkable?: boolean; disableCheckbox?: boolean; children?: BaseOptionType[]; [name: string]: any; } export interface DefaultOptionType extends BaseOptionType { value?: any; title?: ReactNode; label?: ReactNode; key?: Key; children?: DefaultOptionType[]; } export interface PropTreeSelectProps extends Omit { /** 是否查看模式 */ isView?: boolean; /** 是否根据输入项进行筛选, 默认true */ filterTreeNode?: boolean; /** 输入项过滤对应的 treeNode 属性, 默认label */ treeNodeFilterProp?: string; /** 是否展开所有树 */ treeDefaultExpandAll?: boolean; /** 是否支持复选、多选,默认多选 */ treeCheckable?: boolean; /** 输入框宽度,默认100% */ width?: any; /** 枚举code-从localStorage里面根据次code取枚举值 */ code?: string; /** 数据源 */ dataSource?: DataOption[]; /** 兼容 2.0 版本、3.0 使用view 模式,查看模式值 */ defaultDisableValue?: string; /** 格式化接口响应数据 */ transformResponse?: (data: any) => DataOption[]; /** 是否展示 tooltip、当 label 特别长的时候使用 */ tooltip?: boolean; /** 是否展示 code-label 形式 */ showCodeName?: boolean; /** 集成表单 form 的属性 */ otherProps?: ProFormOtherProps; onSearch?: (value: string, useRequest: Result) => void; /** 远程请求接口 */ useRequest?: { service: Service; options?: Options; }; } export interface ProSelectAction { /** 获取发生请求的 useRequest 的 ref */ useRequestRef: Result; } export interface TreeNodeData extends DataOption { title: string; value: string; children?: TreeNodeData[]; icon?: ReactNode; hideNodeClass?: string; } export interface TreeSelectFormProps { type?: string; label?: string; name?: string; fieldProps?: PropTreeSelectProps; [key: string]: any; } export interface ResponseData { status: number; message: string; data: any; success?: boolean; code?: number; } export {};