import type { ButtonType } from 'antd/lib/button'; import React, { CSSProperties, ReactNode } from 'react'; import { candidateButtons } from './candidate'; import type { IObject } from '../../interface'; /** * 定义业务数据接口类型 */ export interface IBussData extends IObject { /** * @description 业务类型 */ busType?: string; /** * @description 单据(列表页面为当前选中数据行)数据状态 */ data?: IObject; /** * @description 物理主键字段 * @default 'phid' */ keyField?: string | string[]; /** * @description 单据编码字段 * @default 'bill_no' */ billNoField?: string; /** * @description 单据名称字段 * @default 'bill_name' */ billNameField?: string; /** * @description 单据日期字段 * @default 'bill_dt' */ billDtField?: string; /** * @description 所属项目字段 * @default 'phid_pc' */ projectField?: string; /** * @description 所属组织字段 * @default 'phid_org' */ orgField?: string; /** * @description 所属部门字段 * @default 'phid_dept' */ deptField?: string; /** * @description 附件标志字段 * @default 'asr_flag' */ asrField?: string; /** * @description 工作流状态字段 * @default 'wf_flag' */ wfField?: string; /** * @description 审核状态字段 * @default 'app_status' */ appField?: string; /** * @description 审核人字段 * @default 'phid_app' */ approverField?: string; /** * @description 审核时间字段 * @default 'app_dt' */ appDtField?: string; /** * @description 归档状态字段 * @default 'arc_flag' */ arcField?: string; /** * @description 记账状态字段 * @default 'tr_flag' */ trField?: string; /** * @description IMP方案id字段 * @default 'phid_schemeid' */ schemeIdField?: string; } export type BussDataType = (params: { id: string; }) => Promise | IBussData; type ToolBarType = keyof typeof candidateButtons | { type: 'flex'; }; type IClickParams = { id: string; text: string; toolbar: Object; origin: Object; }; export interface IToolBarItemProps { /** * @description 设置按钮的key */ id: string; /** * @description 设置按钮的图标 */ icon?: string | React.ReactNode; /** * @description 设置多语言的key,默认取id属性值 */ langKey?: string; /** * @description 设置按钮权限的key,默认取id属性值 */ rightKey?: string; /** * @description 设置按钮类型 * @default text */ type?: ButtonType; /** * @description 设置按钮大小 * @default small */ size?: 'small' | 'middle' | 'large' | 'simple'; /** * @description 设置按钮的文本 */ text?: ReactNode; /** * @description 是否隐藏 */ hidden?: boolean; /** * @description 是否不可点击 */ disabled?: boolean; /** * @description 是否简约显示,只显示icon */ simple?: boolean; /** * @description 点击按钮时回调 */ onClick?: (event: IClickParams) => void; /** * @description 配置分组按钮 */ children?: Array; /** * @description 按钮的样式 */ style?: CSSProperties; /** * @description 返回业务数据的函数,用于按钮公共业务封装使用,(btnId: string) => Promise<{}> | {} */ getData?: BussDataType; /** * @description 按钮的扩展属性,一般用于注入antd的默认属性 */ antProps?: IObject; } export type ToolBarItemType = Array; export interface IToolBarProps { /** * @description 阻止事件向往冒泡 * @default true */ stopPropagation?: boolean; /** * 所属容器id,用于限定订阅消息的事件区间 */ containerId?: string; /** * @description 更多按钮的icon */ moreIcon?: ReactNode | ((buttons: Array) => React.ReactNode); /** * @description 自定义按钮图标颜色 */ iconColor?: string; /** * @description 显示按钮图标 * @default true */ showIcon?: boolean; /** * @description 设置按钮类型 * @default text */ type?: ButtonType; /** * @description 设置按钮大小 * @default small */ size?: 'small' | 'middle' | 'large' | 'simple'; /** * @description ui元数据的路径,用于updateUI更新toolbar的元数据 */ confKey?: string[]; /** * @description 配置 buttons 子项 */ buttons: Array; /** * @description buttons组件内部更新后,用于同步外部buttons状态 */ onButtonsChange?: (buttons: Array) => void; /** * @description 设置buttons的排列位置 * @default left */ direction?: 'left' | 'right' | 'center' | 'space-between' | 'space-around'; /** * @description 点击按钮时的回调事件 */ onClick?: (event: IClickParams) => void; /** * @description 设置样式属性 */ style?: CSSProperties; /** * @description 样式类 */ className?: string; /** * @description 设置失效状态的按钮 id 数组 */ disabledKeys?: Array; /** * @description 设置隐藏状态的按钮 id 数组 */ hiddenKeys?: Array; /** * @description 页面类型,一般为业务类型,用于自动获取权限接口 */ rightName?: string; /** * @description 同一个页面拆分成不同功能菜单时,需要配置此属性来区分不同菜单按钮权限(rightName存在时有效) */ funcName?: string; /** * @description 返回业务数据的函数,用于按钮公共业务封装使用,(btnId: string) => Promise<{}> | {} */ getData?: BussDataType; /** * @description 将toolbar元素钉在可视范围 * @default false */ affix?: boolean | { target?: () => Window | HTMLElement | null; offsetTop?: number; offsetBottom?: number; }; /** * @description 徽标数,用于显示需要处理的消息或提醒 */ badge?: ((id: string) => number | ReactNode) | Record; /** * @description dropdown下拉按钮切换时的事件,用于处理楼工报表控件的显示隐藏问题 */ onOpenChange?: (open: boolean, button?: Record) => void; } export {};