import { ProTableComponent } from './table.component'; export interface ProTableData { /** * 选择框或单选框状态值 */ checked?: boolean; /** * 选择框或单选框 `disabled` 值 */ disabled?: boolean; /** * 是否展开状态 */ expand?: boolean; [key: string]: any; } export interface ProTableColumn { /** * 列标题 */ title: string; /** * 列数据在数据项中对应的 key */ index?: string | ((data: ProTableData) => any) | { index: string; value: ((value: any) => any); }; /** * 类型 * - `no` 行号,计算规则:`index + noIndex` * - `link` 链接,务必指定 `click` * - `badge` [徽标](https://ng.ant.design/components/badge/zh),务必指定 `badge` 参数配置徽标对应值 * - `tag` [标签](https://ng.ant.design/components/tag/zh),务必指定 `tag` 参数配置标签对应值 * - `img` 图片且居中(若 `className` 存在则优先) * - `currency` 货币且居右(若 `className` 存在则优先) * - `date` 日期格式且居中(若 `className` 存在则优先),使用 `date` 自定义格式 * - `operation` 操作列按钮组 * - `widget` 使用自定义小部件动态创建 */ type?: '' | 'no' | 'link' | 'badge' | 'tag' | 'img' | 'currency' | 'number' | 'date' | 'operation' | 'widget'; style?: ((record: T) => string) | string; class?: ((record: T) => string) | string; /** * type为link的链接回调 */ click?: (record: T, instance?: ProTableComponent) => any; /** * type为img的配置项,默认都为60px */ img?: { width?: string; height?: string; }; /** * type为currency的配置项 * currencyCode: 默认 CNY * display: 默认 symbol-narrow */ currency?: { currencyCode?: string; display?: 'code' | 'symbol' | 'symbol-narrow' | string | boolean; digitsInfo?: string; locale?: string; }; /** * type为badge的配置项 */ badge?: ProTableBadgeType | null; /** * type为tag的配置项 */ tag?: ProTableTagType | null; /** * type为date的配置项 * format: 默认 yyyy-MM-dd HH:mm */ date?: { format?: string; timezone?: string; locale?: string; }; /** * type为operation的配置项 */ operation?: ProTableOperation[]; /** * 自定义小部件 */ widget?: ProTableWidgetColumn; /** * 权限控制,控制列的显示 */ acl?: () => boolean; /** * 在列显示的情况下控制行的显示 */ hidden?: (data: ProTableData) => boolean; /** * 列宽度 */ width?: string; /** * 左侧距离,用于固定左侧列,当为 true 时自动计算,为 false 时停止固定 * 如果有checkbox或者radio,left会自动加上checkbox或者radio的width */ left?: string | boolean; /** * 右侧距离,用于固定右侧列,当为 true 时自动计算,为 false 时停止固定 */ right?: string | boolean; /** * 设置列内容的对齐方式 */ align?: 'left' | 'right' | 'center'; /** * 是否折行显示 */ breakWord?: boolean; /** * 默认超过宽度将自动省略,是否显示tooltip,暂不支持固定列一起使用 */ ellipsis?: boolean; /** * 列不显示 */ show?: boolean; } export interface ProTableWidgetColumn { type: string; params?: (options: { record: T; column: ProTableColumn; }) => {}; } export interface ProTablePageChange { /** * 回调类型 */ type: 'pageIndex' | 'pageSize'; /** * 当前页码 */ pageIndex: number; /** * 每页数量 */ pageSize: number; } export interface ProTableSelectChange { checkbox?: T[]; /** * `radio` 参数 */ radio?: T; } export interface STColumnBadge { [key: number]: STColumnBadgeValue; [key: string]: STColumnBadgeValue; } export interface STColumnBadgeValue { /** * 文本 */ text?: string; /** * 徽标颜色值 */ color?: 'success' | 'processing' | 'default' | 'error' | 'warning'; } export interface ProTableOperation { /** * 名称 */ title?: string; /** * 类型 */ type?: 'link' | 'popConfirm'; /** * 提示信息 */ popConfirmTitle?: string; /** * 点击事件 */ click?: (record: T, instance?: ProTableComponent) => any; show?: ((data: ProTableData) => boolean) | boolean; style?: ((record: T) => string) | string; class?: ((record: T) => string) | string; } export interface ProTableTagType { [key: number]: ProTableTagTypeValue; [key: string]: ProTableTagTypeValue; } export interface ProTableTagTypeValue { /** * 文本 */ text?: string; /** * 颜色值,支持预设和色值 */ color?: string; } export interface ProTableBadgeType { [key: number]: ProTableBadgeTypeValue; [key: string]: ProTableBadgeTypeValue; } export interface ProTableBadgeTypeValue { /** * 文本 */ text?: string; /** * 颜色值,支持预设和色值 */ color?: string; } /** * 单行展开事件参数 */ export interface NestedExpandData { expand: boolean; data: ProTableData; index: number; }