import type { CheckboxProps, DatePickerProps, InputNumberProps, InputProps, SelectProps, SwitchProps } from 'antd'; import type { TextAreaProps } from 'antd/es/input'; import type { Dayjs } from 'dayjs'; import React, { CSSProperties, type RefObject } from 'react'; import type { ICheckboxExtraProps } from '../../../baseComponent'; import type { BaseHelpProps } from '../../base-help'; import type { ICurrentObject, IObject } from '../util'; declare type optionType = { value: any; label?: React.ReactNode; type?: 'Badge' | 'Tag' | String; color?: string; status?: 'success' | 'processing' | 'error' | 'default' | 'warning'; }; interface IBaseFormat { nullValue?: string; } interface IDateFormat extends IBaseFormat { type: 'date'; formatter: 'YYYY-MM-DD' | 'YYYY-MM-DD HH:mm' | 'HH:mm' | String; } interface IOptionFormat extends IBaseFormat { type: 'option'; formatter?: optionType[]; } interface INumberFormat extends IBaseFormat { type: 'number'; color?: string; prefix?: string; suffix?: string; precision?: number; formatter?: ',' | String | false | Function; } interface IIconFormat extends IBaseFormat { type: 'icon'; formatter: Array<{ value: any; label?: React.ReactNode; icon: string | React.ReactElement; style?: CSSProperties; }>; } interface IAttachmentFormat extends IBaseFormat { type: 'attachment'; oType: 'add' | 'edit' | 'view'; formatter?: { icon: string | React.ReactElement; style?: CSSProperties; showTip?: string; }; } interface IExprFormat extends IBaseFormat { type: 'expr'; formatter: string; } export declare type IFormat = IDateFormat | IOptionFormat | INumberFormat | IIconFormat | IExprFormat | IAttachmentFormat; export declare type IExpr = String | (($R: any, $D: any, $V: any, $DI: any) => any); declare type getEditor = (dataIndex?: string) => ICurrentObject; declare type onBeforeInit = ({ editor, row, dataIndex, table }: { editor: any; row: any; dataIndex: any; table: any; }) => boolean | void | IObject; declare type onInit = ({ editor, row, dataIndex, rowIndex, table }: { editor: any; row: any; dataIndex: any; rowIndex: any; table: any; }) => void; declare type onChange = { value: any; row: any; lastRow: any; rowIndex: number; dataIndex: any; table: any; getEditor: getEditor; originValue: any; }; interface IEditor

extends IObject { /** * @description 设置是否必输项 */ required?: boolean; /** * @description 设置编辑器内部组件的属性,不会被过滤,直接传入组件内部 */ antProps?: P; /** * @description 设置编辑器的监听事件 */ listeners?: { /** * @description 返回false阻止编辑器渲染,相当于只读 */ onBeforeInit?: onBeforeInit; onInit?: onInit; onChange?: (args: onChange) => void; }; /** * @description 设置编辑器的条件隐藏函数 */ hidden?: (params: { row: IObject; dataIndex: string; }) => Boolean; /** * @description 设置编辑器的条件禁用函数 */ disabled?: (params: { row: IObject; dataIndex: string; }) => Boolean; /** * @description 设置非编辑状态下单元格需要显示的字段 */ nameField?: string | ((params: { row: IObject; dataIndex: string; }) => string); } interface CustomizedTypeProps extends IObject { value: any; onChange: Function; onKeyDown: Function; outRef: RefObject; editorOptions: any; } type regExp = string | ((params: { row: IObject; value: any; dataIndex: string; }) => boolean | string); type regExpType = regExp | { exp: regExp; info?: string; }; export interface ICustomizedEditor extends IEditor { /** * @description 自定义组件类型(string表示注册过的业务组件) */ xtype: String | ((props: CustomizedTypeProps) => React.ReactNode); /** * @description 设置编辑器的验证表达式或函数 */ regExp?: regExpType; } /** * 文本输入框 */ export interface ITextEditor extends IEditor { /** * @description 文本输入框 */ xtype: 'input' | 'Input' | 'InputNumber' | 'TextArea'; /** * @description 设置输入框的类型 * @default text */ type?: 'text' | 'number' | 'amount' | 'percent' | 'textarea'; /** * @description 设置输入字段中的字符的最大长度 */ maxLength?: number; /** * @description 设置输入字段的最小值 */ min?: number; /** * @description 设置输入字段的最大值 */ max?: number; /** * @description 设置编辑器的验证表达式或函数 */ regExp?: regExpType; /** * @description 设置输入数字的合法数字间隔 */ step?: number; /** * @description 设置数字的精度 */ precision?: number; /** * @description 双击弹窗输入,TextArea默认开启 */ dbClickInput?: boolean; } /** * 时间选择 */ export interface IDatePickerEditor extends IEditor> { /** * @description 时间选择器 */ xtype: 'datepicker' | 'DatePicker'; /** * @description 设置时间选择器的类型(日期、日期+时间、时间、周、月、季度、年) * @default date */ type?: 'date' | 'datetime' | 'time' | 'week' | 'month' | 'quarter' | 'year'; /** * @description 设置时间格式 */ dateFormat?: 'YYYY-MM-DD' | 'YYYY-MM-DD HH:mm' | 'HH:mm' | String; } /** * 下拉选择 */ export interface ISelectEditor extends IEditor & { data?: Array; valueField?: string; labelField?: string; request?: (params: any) => any; }> { /** * @description 下拉选择器 */ xtype: 'select' | 'Select'; /** * @description 设置下拉数据源中的value字段 * @default value */ valueField?: 'value' | String; /** * @description 设置下拉数据源中的label字段 * @default label */ labelField?: 'label' | String; /** * @description 是否多选 * @default false */ multiple?: boolean; /** * @description 固定数据源 */ data?: optionType[]; /** * @description 动态数据源 */ request?: (...args: any[]) => Promise; /** * @description 是否缓存动态数据源 * @default true */ cache?: boolean; } /** * CheckBox复选框 */ export interface ICheckBoxEditor extends IEditor<(CheckboxProps & ICheckboxExtraProps) | (SwitchProps & ICheckboxExtraProps)> { /** * @description 状态切换 */ xtype: 'checkbox' | 'Checkbox'; /** * @description 选择框或开关 * @default checkbox */ type?: 'checkbox' | 'switch'; /** * @description 状态与其他行互斥的 * @default false */ incompatible?: boolean; /** * @description 互斥情况是否支持取消当前选中状态 * @default false */ canCancelChecked?: boolean; } /** * 通用帮助或业务帮助 */ export interface IHelpEditor extends IEditor { /** * @description 通用帮助 */ xtype: 'help' | 'Help'; /** * @description 设置通用帮助的类型(可以是注册过的业务帮助) */ type?: 'SingleHelp' | 'MultipleHelp' | String; /** * @description ORMMode * @default true */ ORMMode?: boolean; /** * @description 过滤条件 */ clientSqlFilter?: string | IObject | (({ ds, row, value, dataIndex, helpId }: { ds: Array; row: any; value: any; dataIndex: string; helpId: string; }) => string | IObject); /** * @description 设置下拉数据源中的value字段 * @default value */ valueField?: 'value' | String; /** * @description 设置下拉数据源中的label字段 * @default label */ labelField?: 'label' | String; /** * @description 帮助标识id,通用帮助必须设置helpId(业务帮助看需求设置) */ helpId?: string; } export {};