import { CellType, CellEditor, CellValue } from '@/lib/types/cell'; import { GroupPin } from '@/lib/types/group'; import { VNode } from 'vue'; export interface GroupColumn { // 移除 isGroup: boolean; group: string; title: string; children: Column[]; } /** * column prop 入参 */ export type Column = SingleColumn | GroupColumn; export interface SingleColumn { field: string; // 表头信息 title: string | (() => VNode[] | VNode); width?: number; pin?: GroupPin; // 内容信息 cellType?: CellType | ((rowData: Record) => CellType); formatter?: (cellValue: any) => string; renderer?: (cellValue: any) => VNode[] | VNode; editor?: CellEditor; calculator?: [string | string[], (rowData: Record) => CellValue]; // 仅树父节点支持 nodeCollector?: (total: CellValue, current: CellValue) => CellValue; totalCollector?: ( total: CellValue | Object, data: { rowData: any, currentValue: CellValue, hasChildren: boolean, hasParent: boolean, } ) => CellValue | Object; totalFormatter?: (cellValue: any) => string; // 列的功能 fillHandle?: boolean | DragDirection[]; // 自定义 class customClass?: string; // 总计自定义展示 totalRender?: (cellValue: any) => any; } export interface IndexColumnWithoutIndexStatus extends SingleColumn { // 自用计算所得数据 top: number; height: number; group: string; groupTitle?: string; left: number; width: number; // 可索引项目 id: string; field: string; index: number; } /** * column 便于索引查找的结构 */ export interface IndexColumn extends IndexColumnWithoutIndexStatus { isFirst: boolean; isLast: boolean; isFirstInGroup: boolean; isLastInGroup: boolean; } export interface ColumnGroup { ids: string[]; width: number; } export interface ColumnGroupRecord { left: ColumnGroup; right: ColumnGroup; scroll: ColumnGroup; } export interface ColumnLocation { pin: IndexColumn['pin']; index: number; } export enum FormulaType { range = 'range', select = 'select', } export enum DragDirection { top = 'top', bottom = 'bottom', left = 'left', right = 'right', }