import type { SelectProps, TableProps, PaginationProps } from 'ant-design-vue' import type { Component, ComponentPublicInstance, Reactive, Ref } from 'vue' /** * 表格列对应的类型枚举 * @public */ export type SuperTableColumnType = 'text' | 'link' | 'button' | 'tag' | 'image' | 'component' | 'sort' /** * 查询表单项对应的类型枚举 * @public */ export type SuperTableFormItemType = | 'input' | 'inputGroup' | 'inputNumber' | 'inputNumberRange' | 'select' | 'treeSelect' | 'cascader' | 'datePicker' | 'rangePicker' | 'component' /** * 表格列吸附方式类型 * @public */ export type SuperTableColumnFixedType = 'left' | 'right' | false /** * 排序方式类型 * @public */ export type SuperTableSortOrders = 'ascend' | 'descend' | null /** * 场景存储类型 * @public */ export type SuperTableSceneStorageType = 'local' | 'api' /** * 表格数据项类型 * @public */ export type SuperTableDataItem = Record /** * 查询项 input addonAfter 点击回调参数 * @public */ export interface SuperTableFormItemAddonAfterContext { /** 查询项名称 */ name: string /** 当前值 */ value: any /** 当前查询项配置 */ formItem: SuperTableFormItem } /** * 查询项 input addonAfter 配置 * @public */ export interface SuperTableFormItemAddonAfter { /** 按钮文案 */ text?: string /** 按钮自定义 class */ className?: string /** 是否显示 */ show?: boolean /** 是否禁用 */ disabled?: boolean /** 点击回调 */ onClick?: (context: SuperTableFormItemAddonAfterContext) => void } /** * 查询条件配置接口 * @public */ export interface SuperTableFormItem { /** 查询项类型 */ type: SuperTableFormItemType /** 查询项对应的字段名称 */ name: string /** 绑定数据时v-model对应的name,默认为value */ modelPropName?: string /** 查询项标签 */ label: string /** 查询项提示信息,展示在标签旁的 tooltip 中 */ tooltip?: string | number /** 传递给查询项的props */ props?: Record /** 选项值 */ value?: any /** 自定义组件 */ component?: Component /** 查询项宽度系数 */ span?: number /** 是否显示 */ visible?: boolean /** 带select前缀的组合输入框配置 */ addonBeforeProps?: SelectProps /** input 的后置附加按钮配置 */ addonAfter?: SuperTableFormItemAddonAfter /** addonAfter 兼容错拼字段(不推荐) */ addonAffter?: SuperTableFormItemAddonAfter /** addonAfter 兼容错拼字段(不推荐) */ addonAter?: SuperTableFormItemAddonAfter /** 改变时保持静默,不要触发搜索(等价于 requestOnChange: false,且优先于全局 requestOnFormItemChange) */ quiet?: boolean /** * 该项变更是否触发 request(与全局 requestOnFormItemChange 共同生效) * - true:在通过输入类提交规则后,且全局为 true 时请求 * - false:不请求 * - 未传:仅看全局与 quiet */ requestOnChange?: boolean /** 是否展示label,默认展示 */ showLabel?: boolean /** 固定选项,不允许删除,高级搜索时一定会默认展示 */ fixed?: boolean /** 分组标识,高级筛选字段选择下拉框按此字段分组 */ group?: string /** * 是否在本地持久化该项的值(与 advancedFilterItems 等同表 superTable_* 的 useStorage) * 仅在 enableScene 为 false 时生效:每次发起查询时写入,下次进入页面恢复;无缓存则用配置默认值 */ cache?: boolean /** * 默认选中,开启后表现为: * 1. 高级搜索弹窗打开时会默认选中对应的搜索项 * 2. 没有配置默认场景时,会根据选中的项目生成一个默认场景 */ selected?: boolean /** @internal 以下为内置属性,不允许修改 */ /** 默认值 */ _defaultValue?: any /** 排序 */ _order?: number /** 是否选中 */ _selected?: boolean /** 在选中场景中的排序 */ _orderInScene?: number [key: string]: any } /** * 表格列配置接口 * @public */ export interface SuperTableColumn { /** 列对应的key */ key: string /** 展示类型:text-文本,button-按钮,link-链接,tag-标签,component-自定义组件 */ type?: SuperTableColumnType | ((row: SuperTableDataItem, index: number) => SuperTableColumnType) /** 标题 */ title: string /** 标题对应的提示信息 */ titleTooltip?: string | ((row: SuperTableDataItem, index: number) => string) /** 表格内容 */ content?: string | ((row: SuperTableDataItem, index: number) => any) /** 表格内容字段路径(优先于 content) */ dataIndex?: string /** 自定义渲染函数(与 dataIndex 组合时优先于 content) */ customRender?: (value: any, row: SuperTableDataItem, index: number) => any /** 表格内容对应的提示信息 */ tooltip?: string | boolean | ((row: SuperTableDataItem, index: number) => string) /** 表格内容解析自定义组件 */ component?: Component /** 表格内容解析用到的组件对应的props */ props?: Record | ((row: SuperTableDataItem, index: number) => Record) /** 自定义单元格插槽名,命中后优先使用具名插槽渲染 */ slotName?: string /** 是否可复制 */ copyable?: boolean /** 是否超出显示省略号 */ ellipsis?: boolean /** 是否可见 */ visible?: boolean /** 宽度 */ width?: number /** 最小宽度,拖拽时生效,默认 50 */ minWidth?: number /** 最大宽度,拖拽时生效,默认无限制 */ maxWidth?: number /** 固定列位置 */ fixed?: SuperTableColumnFixedType /** 排序 */ sorter?: boolean | ((a: SuperTableDataItem, b: SuperTableDataItem) => number) /** 默认排序 */ defaultSortOrder?: SuperTableSortOrders /** 列索引 */ index?: number /** visible=false 时是否在展开区域展示,默认展示 */ showInExpand?: boolean /** 透传给 a-descriptions-item 的属性 */ expandItemProps?: Record /** 单元格多元素排布方向(用于折叠列表) */ flexDirection?: 'row' | 'column' /** 展开区域(描述组件)排布方向,默认 'row' */ expandFlexDirection?: 'row' | 'column' /** 最大可见行数(基于 offsetTop 行检测,设置后启用内联展开/收起替代 popover/dropdown) */ maxRows?: number /** 未使用字段分组标识 */ group?: string /** 分组标题(不传则取 group 值) */ groupTitle?: string [key: string]: any } /** * 场景中保存的查询条件配置接口 * @public */ export interface SuperTableQuerySceneItem { /** 字段名称 */ name: string /** 字段类型 */ type: SuperTableFormItemType /** 字段值 */ value: any } /** * 查询场景接口 * @public */ export interface SuperTableQueryScene { /** 场景唯一标识 */ code: string /** 场景名称 */ name: string /** 配置类型 */ type?: string /** 配置详情 */ value?: string /** 查询项列表 */ items: SuperTableQuerySceneItem[] /** 是否是私有配置 */ asPrivate?: boolean /** 是否是自定义场景 */ isCustom?: boolean } /** * 默认场景配置接口 * @public */ export interface SuperTableDefaultSceneConfig { /** 场景名称 */ name?: string /** 场景唯一标识,多个自定义场景时必填 */ code?: string /** 查询项列表 */ items: { /** 字段名称 */ name: string /** 字段值 */ value: any }[] } /** * 场景状态接口 * @public */ export interface SuperTableSceneState { /** 查询场景列表 */ list: SuperTableQueryScene[] /** 是否正在加载场景 */ loading: boolean /** 是否正在保存场景 */ submiting: boolean /** 是否已经加载过场景 */ loaded: boolean } /** * 提供给弹窗使用的表格全局状态接口 * @public */ export interface SuperTableContext { /** 场景类型 */ sceneType: string /** 场景状态 */ sceneState: Reactive /** 查询场景 */ queryScene(): void /** 新增/更新场景 */ updateScene(scene: SuperTableQueryScene | SuperTableQueryScene[]): void /** 删除场景 */ deleteScene(sceneCode: string): void /** 当前生效中的查询参数 */ selectedFormItems: SuperTableQuerySceneItem[] /** 禁用添加场景功能 */ allowCreateScene: Ref } /** * 场景请求配置接口 * @public */ export interface SuperTableSceneRequestConfig { /** 查询场景列表 */ querySceneList: (params: { type: string }) => Promise<{ code: number; data: SuperTableQueryScene[]; msg: string }> /** 创建场景 */ createScene: (params: { type: string name: string value: string asPrivate?: boolean }) => Promise<{ code: number; data: string; msg: string }> /** 更新场景 */ updateScene: (params: { code: string name: string value: string }) => Promise<{ code: number; msg: string }> /** 删除场景 */ deleteScene: (params: string[]) => Promise<{ code: number; msg: string }> } /** * 数据请求方法类型 * @public */ export type SuperTableRequestFunction = (options: { /** 查询参数 */ params: Record /** 分页大小 */ pageSize?: number /** 当前页码 */ pageNum?: number [key: string]: any }) => Promise<{ total: number; data: Record[] }> /** * Antd表格属性扩展接口 * @public */ export interface SuperTableAntdProps extends Omit { pagination: PaginationProps columns: SuperTableColumn[] dataSource: SuperTableDataItem[] } /** * 表单操作方法接口 * @public */ export interface SuperTableFormOperations { /** * 获取表单项配置 * @param name - 表单项名称 * @returns 表单项配置 */ getFormItem(name: string): SuperTableFormItem | undefined /** * 设置表单项配置 * @param name - 表单项名称 * @param keyPath - 配置路径 * @param newConfig - 新的配置值 */ setFormItem(name: string, keyPath: string, newConfig: any): void /** * 获取表单值 * @param name - 表单项名称或名称数组,不传则获取所有值 * @returns 表单值对象 */ getFormValues(name?: string | string[]): Record /** * 设置表单值 * @param values - 要设置的表单值对象 */ setFormValues(values: Record): void /** * 获取单个表单项值 * @param name - 表单项名称 * @returns 表单项值 */ getFormValue(name: string): any /** * 设置单个表单项值 * @param name - 表单项名称 * @param value - 要设置的值 */ setFormValue(name: string, value: any): void } /** reload / request 触发来源 */ export type SuperTableFetchSource = 'auto' | 'scene' | 'form' | 'manual' | 'reset' | 'pagination' /** reload 入参:传 boolean 时 true 表示 force 且 source 为 manual */ export type SuperTableReloadOptions = | boolean | { force?: boolean source?: SuperTableFetchSource /** 为 false 时不将页码重置为 1 */ resetPage?: boolean } /** * 表格操作方法接口 * @public */ export interface SuperTableTableOperations { /** * 获取表格数据 * @returns 表格数据数组 */ getTableData(): SuperTableDataItem[] /** * 设置表格数据 * @param data - 要设置的表格数据 */ setTableData(data: SuperTableDataItem[]): void /** * 设置表格数据项 * @param index - 数据项索引 * @param data - 要设置的数据项 */ setTableDataItem(index: number, data: Partial): void /** * 按当前查询条件调用 request,默认重置到第 1 页 */ reload(options?: SuperTableReloadOptions): void /** * @deprecated 请改用 reload,将在下一个大版本移除 */ onRefresh(options?: SuperTableReloadOptions): void } /** * 查询区操作栏扩展插槽作用域参数(`searchActionsExtraBefore` / `searchActionsExtraAfter` / 兼容 `searchActionsExtra`) * @public */ export interface SuperTableSearchActionsExtraSlotProps { /** 与表格当前请求 loading 同步 */ loading: boolean /** 触发查询,行为等价于点击「查询」 */ search: () => void /** 重置查询条件,行为等价于点击「重置」 */ reset: () => void } /** * 插槽类型 * @public */ export interface SuperTableSlots { /** 场景选择器前面的插槽 */ sceneAddonBefore?: () => any /** 场景选择器后面的插槽 */ sceneAddonAfter?: () => any /** 额外内容插槽 */ extra?: () => any /** 表格头部插槽 */ tableHead?: () => any /** 工具栏额外按钮插槽 */ toolBarExtra?: () => any /** 查询条件行操作区:内置「重置 / 查询 / 展开」之前的扩展(作用域同 `searchActionsExtraAfter`) */ searchActionsExtraBefore?: (props: SuperTableSearchActionsExtraSlotProps) => any /** 查询条件行操作区:内置按钮之后的扩展 */ searchActionsExtraAfter?: (props: SuperTableSearchActionsExtraSlotProps) => any /** * 查询条件行操作区扩展(与 `searchActionsExtraAfter` 等价,渲染在其后;建议迁移至 `searchActionsExtraAfter`) * @deprecated 请使用 `searchActionsExtraBefore` / `searchActionsExtraAfter` */ searchActionsExtra?: (props: SuperTableSearchActionsExtraSlotProps) => any /** 展开列标题插槽 */ expandColumnTitle?: () => any /** 表格底部插槽 */ tableFoot?: () => any /** 展开行内容插槽 */ expandedRowRender?: (props: { record: any }) => any /** 自定义单元格具名插槽 */ [slotName: string]: ((props?: Record) => any) | undefined } /** * 组件暴露方法类型 * @public */ export interface SuperTableExpose extends SuperTableFormOperations, SuperTableTableOperations { /** * 重置表单查询条件 */ onResetForm(): void /** 是否已初始化 */ isInitialized: Ref } /** reload / search 触发来源(SuperQuery) */ export type SuperQueryFetchSource = 'auto' | 'scene' | 'form' | 'manual' | 'reset' /** SuperQuery reload 入参 */ export type SuperQueryReloadOptions = | boolean | { force?: boolean source?: SuperQueryFetchSource } /** * SuperQuery 插槽类型 * @public */ export interface SuperQuerySlots { sceneAddonBefore?: () => any sceneAddonAfter?: () => any extra?: () => any searchActionsExtraBefore?: (props: SuperTableSearchActionsExtraSlotProps) => any searchActionsExtraAfter?: (props: SuperTableSearchActionsExtraSlotProps) => any /** @deprecated 请使用 searchActionsExtraAfter */ searchActionsExtra?: (props: SuperTableSearchActionsExtraSlotProps) => any } /** * SuperQuery 暴露方法类型 * @public */ export interface SuperQueryExpose extends SuperTableFormOperations { reload(options?: SuperQueryReloadOptions): void onResetForm(): void openAdvancedFilter(): void isInitialized: Ref } /** * SuperQuery 组件实例类型 * @public */ export type SuperQueryInstance = ComponentPublicInstance, SuperQueryExpose> /** * 组件实例类型 * @public */ export type SuperTableInstance = ComponentPublicInstance, SuperTableExpose> /** * 组件内置文案(字段均为可选,缺省回落中文语言包) * @public */ export interface SuperTableMessages { /** 场景选择 */ sceneSelect?: string /** 请选择(场景下拉 / select 占位) */ placeholder?: string /** 请输入(输入框占位) */ inputPlaceholder?: string /** 新建场景 */ createScene?: string /** 默认场景(defaultScene 未传 name 时的兜底名称) */ defaultScene?: string /** 场景管理 */ manageScene?: string /** 高级筛选 */ advancedFilter?: string /** 刷新 */ refresh?: string /** 查询 */ search?: string /** 重置 */ reset?: string /** 展开 */ expand?: string /** 收起 */ collapse?: string /** 取消固定 */ cancelFixed?: string /** 全选 */ selectAll?: string /** 搜索标题(列配置搜索占位) */ searchColumnPlaceholder?: string /** 固定在左侧 */ fixedLeft?: string /** 固定在右侧 */ fixedRight?: string /** 不固定 */ unfixed?: string /** 表格设置 */ tableSetting?: string /** 使用中字段 */ usedFields?: string /** 未使用字段 */ unusedFields?: string /** 暂未选择任何字段 */ noFieldsSelected?: string /** 确定 */ confirm?: string /** 取消 */ cancel?: string /** 保存为场景 */ saveAsScene?: string /** 场景名称 */ sceneName?: string /** 场景名称长度校验提示 */ sceneNameRule?: string /** 请输入场景名称 */ sceneNameRequired?: string /** 请添加筛选条件 */ addFilterRequired?: string /** 筛选条件 */ filterCondition?: string /** 添加筛选条件 */ addFilterCondition?: string /** 全选 (selected/total) */ selectAllCount?: (selected: number, total: number) => string /** 确定删除? */ deleteConfirm?: string /** 删除 */ delete?: string /** 编辑 */ edit?: string /** 操作(列标题) */ action?: string /** 请选择要筛选的字段名 */ fieldNamePlaceholder?: string /** 操作成功 */ operationSuccess?: string /** 更新场景 */ updateScene?: string /** 删除数据 */ deleteData?: string /** 共 X 条数据(分页总数) */ totalData?: (total: number) => string /** 展开 (n)(省略文本展开计数) */ expandCount?: (count: number) => string /** 更多(操作列下拉触发器) */ more?: string /** 其他(未分组字段兜底) */ other?: string /** 已选 (selected/total) */ selectedCount?: (selected: number, total: number) => string /** 未找到相关字段 */ noFieldsFound?: string /** 未找到相关查询项 */ noItemsFound?: string /** 添加数据 */ addData?: string /** 场景功能已关闭 */ sceneDisabled?: string } /** * 多语言配置:一个对象同时驱动组件文案、antd 内置文案与日期组件语言 * @public */ export interface SuperTableLocale { /** 组件自身文案(缺省项回落中文语言包) */ messages?: SuperTableMessages /** 透传给 antd ConfigProvider 的 locale(如 zh_CN / en_US) */ antdLocale?: Record /** dayjs locale 标识(如 'zh-cn' / 'en'),用于日期组件 */ dayjsLocale?: string }