import { ComponentType } from './componentType';

export interface BasicColumn {
  label?: string;
  prop?: string;
  width?: number;
  align?: string;
  //编辑表格
  edit?: boolean;
  editRow?: boolean;
  editable?: boolean;
  editComponent?: ComponentType;
  editComponentProps?: Recordable;
  editRule?: boolean | ((text: string, record: Recordable) => Promise<string>);
  editValueMap?: (value: any) => string;
  onEditRow?: () => void;
  // 权限编码控制是否显示
  auth?: string[];
  // 业务控制是否显示
  ifShow?: boolean | ((column: BasicColumn) => boolean);
  editCellRender?: Recordable;
  render?: Function;
  type?: string;
}

export interface TableActionType {
  reload: (opt) => Promise<void>;
  emit?: any;
  getColumns: (opt?) => BasicColumn[];
  setColumns: (columns: BasicColumn[] | string[]) => void;
  redoHeight: () => void;
}

export interface TableSetting {
  width?: number;
  redo?: boolean;
  size?: boolean;
  setting?: boolean;
  fullscreen?: boolean;
  striped?: boolean;
  query?: boolean;
}

export interface BasicTableProps {
  title?: string;
  dataSource?: Function | any[];
  columns: any[];
  pagination?: object;
  showPagination?: boolean;
  actionColumn?: object;
  canResize?: boolean;
  resizeHeightOffset?: number;
  loading?: boolean;
  showTableSetting?: boolean;
  tableSetting?: TableSetting;
  titleTooltip?: string;
  striped?: boolean;
  request?: Function;
  isKeepRowKeys?: boolean;
}
