import { RenderFunction, SetupContext, Ref, ComputedRef, ComponentPublicInstance, ComponentInternalInstance } from 'vue' import { VxeFormInstance, VxeFormProps, VxeFormDefines } from './form' import { VxeFormItemProps } from './form-item' import { VxeToolbarInstance, VxeToolbarProps, VxeToolbarPropTypes } from './toolbar' import { VxePagerInstance, VxePagerProps, VxePagerDefines } from './pager' import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf, SlotVNodeType } from './component' import { VxeTableDataRow, VxeTableDefines, VxeTableEmits, VxeTableConstructor, VxeTableProps, TablePublicMethods, VxeTableMethods, VxeTablePrivateMethods } from './table' /* eslint-disable no-use-before-define */ /** * 组件 - 配置式表格 * @example import { VxeGrid } from 'vxe-table' */ export const VxeGrid: VXEComponent, VxeGridEventProps, VxeGridSlots> /** * 组件 - 配置式表格 */ export const Grid: typeof VxeGrid export type VxeGridInstance = ComponentPublicInstance, VxeGridConstructor> export interface VxeGridConstructor extends VxeComponentBase, VxeGridMethods { props: Readonly> context: SetupContext instance: ComponentInternalInstance reactData: GridReactData getRefMaps(): GridPrivateRef getComputeMaps(): GridPrivateComputed renderVN: RenderFunction } export interface GridPrivateRef { refElem: Ref refTable: Ref, VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods>> refForm: Ref refToolbar: Ref refPager: Ref } export interface VxeGridPrivateRef extends GridPrivateRef { } export interface GridPrivateComputed { computeProxyOpts: ComputedRef computePagerOpts: ComputedRef computeFormOpts: ComputedRef computeToolbarOpts: ComputedRef computeZoomOpts: ComputedRef } export interface VxeGridPrivateComputed extends GridPrivateComputed { } export interface GridReactData { tableLoading: boolean proxyInited: boolean isZMax: boolean tableData: D[] filterData: VxeTableDefines.FilterCheckedParams[] formData: any sortData: VxeTableDefines.SortCheckedParams[] tZindex: number tablePage: { total: number pageSize: number currentPage: number } } export type VxeGridEmits = [ ...VxeTableEmits, 'page-change', 'form-submit', 'form-submit-invalid', 'form-reset', 'form-collapse', 'form-toggle-collapse', 'proxy-query', 'proxy-delete', 'proxy-save', 'toolbar-button-click', 'toolbar-tool-click', 'zoom' ] export interface GridMethods extends GridPublicMethods { dispatchEvent(type: ValueOf, params: any, evnt?: Event): void } export interface GridPublicMethods { /** * 给数据代理提交指令 * @param code 指令编码 */ commitProxy(code: string | VxeToolbarPropTypes.ButtonConfig, ...args: any[]): Promise /** * 获取表单项列表 */ getFormItems(): VxeFormItemProps[] getFormItems(itemIndex?: number): VxeFormItemProps /** * 切换表格最大化/还原 */ zoom(): Promise /** * 判断是否最大化显示 */ isMaximized(): boolean /** * 如果表格处于常规状态,则最大化表格 */ maximize(): Promise /** * 如果表格处于最大化状态,则还原表格 */ revert(): Promise /** * 获取数据代理信息 */ getProxyInfo(): { data: D[] filter: any form: any sort: VxeTableDefines.SortCheckedParams | { [key: string]: any } sorts: VxeTableDefines.SortCheckedParams[] pager: { total: number pageSize: number currentPage: number } pendingRecords: D[] } | null /** * 设置数据代理信息 */ // setProxyInfo(options: { // /** // * 修改表格数据 // */ // data?: any[] // /** // * 修改表单数据 // */ // form?: { // [key: string]: any // }, // /** // * 修改分页数据 // */ // pager?: { // pageSize?: number // currentPage?: number // } // }): Promise } export interface VxeGridMethods extends GridMethods, TablePublicMethods { } export interface GridPrivateMethods { callSlot(slotFunc: ((params: T) => SlotVNodeType | SlotVNodeType[]) | string | null, params: T): SlotVNodeType[] extendTableMethods(methodKeys: T[]): any triggerToolbarCommitEvent(params: VxeToolbarPropTypes.ButtonConfig | VxeToolbarPropTypes.ToolConfig, evnt: Event): Promise triggerToolbarBtnEvent(button: VxeToolbarPropTypes.ButtonConfig, evnt: Event): void triggerToolbarTolEvent(button: VxeToolbarPropTypes.ToolConfig, evnt: Event): void triggerZoomEvent(evnt: Event): void getParentHeight(): number getExcludeHeight(): number } export interface VxeGridPrivateMethods extends GridPrivateMethods { } export namespace VxeGridPropTypes { export type Size = SizeType export type Layouts = ('Form' | 'Toolbar' | 'Top' | 'Table' | 'Bottom' | 'Pager')[] export type Columns = VxeTableDefines.ColumnOptions[] export interface PagerConfig extends VxePagerProps { enabled?: boolean slots?: any } export interface PagerOpts extends PagerConfig { } interface ProxyAjaxQueryPageParams { total: number pageSize: number currentPage: number } interface ProxyAjaxQuerySortCheckedParams { column: VxeTableDefines.ColumnInfo order: string sortBy: string field: string property: string } interface ProxyAjaxQueryParams { $grid: VxeGridConstructor page: ProxyAjaxQueryPageParams sort: ProxyAjaxQuerySortCheckedParams sorts: ProxyAjaxQuerySortCheckedParams[] filters: VxeTableDefines.FilterCheckedParams[] form: { [key: string]: any } } interface ProxyAjaxQueryAllParams { $table: VxeTableConstructor $grid: VxeGridConstructor sort: ProxyAjaxQuerySortCheckedParams sorts: ProxyAjaxQuerySortCheckedParams[] filters: VxeTableDefines.FilterCheckedParams[] form: { [key: string]: any } options: any } interface ProxyAjaxDeleteParams { $grid: VxeGridConstructor body: { removeRecords: D[] } } interface ProxyAjaxSaveParams { $grid: VxeGridConstructor body: { insertRecords: D[] updateRecords: D[] removeRecords: D[] pendingRecords: D[] } } export interface ProxyConfig { enabled?: boolean autoLoad?: boolean message?: boolean seq?: boolean sort?: boolean filter?: boolean form?: boolean response?: { list?: string | null | ((params: { data: any $grid: VxeGridConstructor }) => any[]) result?: string | ((params: { data: any $grid: VxeGridConstructor }) => any[]) total?: string | ((params: { data: any $grid: VxeGridConstructor }) => number) message?: string | ((params: { data: any $grid: VxeGridConstructor }) => string) } ajax?: { query?(params: ProxyAjaxQueryParams, ...args: any[]): Promise queryAll?(params: ProxyAjaxQueryAllParams, ...args: any[]): Promise delete?(params: ProxyAjaxDeleteParams, ...args: any[]): Promise save?(params: ProxyAjaxSaveParams, ...args: any[]): Promise } [key: string]: any /** * 已废弃,请使用 proxy-config.response * @deprecated */ props?: { /** * 已废弃,请使用 proxy-config.response.list * @deprecated */ list?: string | null /** * 已废弃,请使用 proxy-config.response.result * @deprecated */ result?: string /** * 已废弃,请使用 proxy-config.response.total * @deprecated */ total?: string /** * 已废弃,请使用 proxy-config.response.message * @deprecated */ message?: string } } export interface ProxyOpts extends ProxyConfig { } export interface ToolbarOpts extends ToolbarConfig { } export interface ToolbarConfig extends VxeToolbarProps { enabled?: boolean zoom?: boolean | { escRestore?: boolean iconIn?: string iconOut?: string } slots?: { buttons?: string | ((params: { [key: string]: any }) => SlotVNodeType | SlotVNodeType[]) tools?: string | ((params: { [key: string]: any }) => SlotVNodeType | SlotVNodeType[]) } } export interface FormConfig extends VxeFormProps { enabled?: boolean items?: VxeFormItemProps[] } export interface FormOpts extends FormConfig { inited?: boolean } export interface ZoomConfig { escRestore?: boolean } export interface ZoomOpts extends ZoomConfig { } } export type VxeGridProps = VxeTableProps & { layouts?: VxeGridPropTypes.Layouts columns?: VxeGridPropTypes.Columns pagerConfig?: VxeGridPropTypes.PagerConfig proxyConfig?: VxeGridPropTypes.ProxyConfig toolbarConfig?: VxeGridPropTypes.ToolbarConfig formConfig?: VxeGridPropTypes.FormConfig zoomConfig?: VxeGridPropTypes.ZoomConfig } export namespace VxeGridDefines { interface GridEventParams extends VxeEvent { $grid: VxeGridConstructor } export interface KeydownEventParams extends GridEventParams, VxeTableDefines.KeydownEventParams { } export interface PasteEventParams extends GridEventParams, VxeTableDefines.PasteEventParams { } export interface CopyEventParams extends GridEventParams, VxeTableDefines.CopyEventParams { } export interface CutEventParams extends GridEventParams, VxeTableDefines.CutEventParams { } export interface CurrentChangeEventParams extends GridEventParams, VxeTableDefines.CurrentChangeEventParams { } export interface RadioChangeEventParams extends GridEventParams, VxeTableDefines.RadioChangeEventParams { } export interface CheckboxChangeEventParams extends GridEventParams, VxeTableDefines.CheckboxChangeEventParams { } export interface CheckboxAllEventParams extends GridEventParams, VxeTableDefines.CheckboxAllEventParams { } export interface CheckboxRangeStartEventParams extends GridEventParams, VxeTableDefines.CheckboxRangeStartEventParams { } export interface CheckboxRangeChangeEventParams extends GridEventParams, VxeTableDefines.CheckboxRangeChangeEventParams { } export interface CheckboxRangeEndEventParams extends GridEventParams, VxeTableDefines.CheckboxRangeEndEventParams { } export interface CellClickEventParams extends GridEventParams, VxeTableDefines.CellClickEventParams { } export interface CellDblclickEventParams extends GridEventParams, VxeTableDefines.CellDblclickEventParams { } export interface CellMenuEventParams extends GridEventParams, VxeTableDefines.CellMenuEventParams { } export interface CellMouseenterEventParams extends GridEventParams, VxeTableDefines.CellMouseenterEventParams { } export interface CellMouseleaveEventParams extends GridEventParams, VxeTableDefines.CellMouseleaveEventParams { } export interface HeaderCellClickEventParams extends GridEventParams, VxeTableDefines.HeaderCellClickEventParams { } export interface HeaderCellDblclickEventParams extends GridEventParams, VxeTableDefines.HeaderCellDblclickEventParams { } export interface HeaderCellMenuEventParams extends GridEventParams, VxeTableDefines.HeaderCellMenuEventParams { } export interface FooterCellClickEventParams extends GridEventParams, VxeTableDefines.FooterCellClickEventParams { } export interface FooterCellDblclickEventParams extends GridEventParams, VxeTableDefines.FooterCellDblclickEventParams { } export interface FooterCellMenuEventParams extends GridEventParams, VxeTableDefines.FooterCellMenuEventParams { } export interface SortChangeEventParams extends GridEventParams, VxeTableDefines.SortChangeEventParams { } export interface FilterChangeEventParams extends GridEventParams, VxeTableDefines.FilterChangeEventParams { } export interface FilterVisibleEventParams extends GridEventParams, VxeTableDefines.FilterVisibleEventParams { } export interface ResizableChangeEventParams extends GridEventParams, VxeTableDefines.ResizableChangeEventParams { } export interface ToggleRowExpandEventParams extends GridEventParams, VxeTableDefines.ToggleRowExpandEventParams { } export interface ToggleTreeExpandEventParams extends GridEventParams, VxeTableDefines.ToggleTreeExpandEventParams { } export interface MenuClickEventParams extends GridEventParams, VxeTableDefines.MenuClickEventParams { } export interface EditClosedEventParams extends GridEventParams, VxeTableDefines.EditClosedEventParams { } export interface EditActivedEventParams extends GridEventParams, VxeTableDefines.EditActivedEventParams { } export interface EditDisabledEventParams extends GridEventParams, VxeTableDefines.EditDisabledEventParams { } export interface ValidErrorEventParams extends GridEventParams, VxeTableDefines.ValidErrorEventParams { } export interface ScrollEventParams extends GridEventParams, VxeTableDefines.ScrollEventParams { } export interface CustomEventParams extends GridEventParams, VxeTableDefines.CustomEventParams { } export interface ProxyQueryEventParams extends GridEventParams { status: boolean isReload: boolean isInited: boolean } export interface ProxyDeleteEventParams extends GridEventParams { status: boolean } export interface ProxySaveEventParams extends GridEventParams { status: boolean } export interface PageChangeEventParams extends GridEventParams, VxePagerDefines.PageChangeEventParams { } export interface FormSubmitEventParams extends GridEventParams, VxeFormDefines.SubmitEventParams { } export interface FormSubmitInvalidEventParams extends GridEventParams, VxeFormDefines.SubmitInvalidParams { } export interface FormResetEventParams extends GridEventParams, VxeFormDefines.ResetEventParams { } export interface FormCollapseEventParams extends GridEventParams, VxeFormDefines.CollapseEventParams { } export interface ToolbarButtonClickParams { code: string button: VxeToolbarPropTypes.ButtonConfig } export interface ToolbarButtonClickEventParams extends GridEventParams, ToolbarButtonClickParams { } export interface ToolbarToolClickParams { code: string tool: VxeToolbarPropTypes.ToolConfig } export interface ToolbarToolClickEventParams extends GridEventParams, ToolbarToolClickParams { } export interface ZoomParams { type: 'max' | 'revert' } export interface ZoomEventParams extends GridEventParams, ZoomParams { } } export interface VxeGridEventProps { onKeydown?: VxeGridEvents.Keydown onPaste?: VxeGridEvents.Paste onCopy?: VxeGridEvents.Copy onCut?: VxeGridEvents.Cut onCurrentChange?: VxeGridEvents.CurrentChange onRadioChange?: VxeGridEvents.RadioChange onCheckboxChange?: VxeGridEvents.CheckboxChange onCheckboxAll?: VxeGridEvents.CheckboxAll onCheckboxRangeStart?: VxeGridEvents.CheckboxRangeStart onCheckboxRangeChange?: VxeGridEvents.CheckboxRangeChange onCheckboxRangeEnd?: VxeGridEvents.CheckboxRangeEnd onCellClick?: VxeGridEvents.CellClick onCellDblclick?: VxeGridEvents.CellDblclick onCellMenu?: VxeGridEvents.CellMenu onCellMouseenter?: VxeGridEvents.CellMouseenter onCellMouseleave?: VxeGridEvents.CellMouseleave onHeaderCellClick?: VxeGridEvents.HeaderCellClick onHeaderCellDblclick?: VxeGridEvents.HeaderCellDblclick onHeaderCellMenu?: VxeGridEvents.HeaderCellMenu onFooterCellClick?: VxeGridEvents.FooterCellClick onFooterCellDblclick?: VxeGridEvents.FooterCellDblclick onFooterCellMenu?: VxeGridEvents.FooterCellMenu onSortChange?: VxeGridEvents.SortChange onFilterChange?: VxeGridEvents.FilterChange onFilterVisible?: VxeGridEvents.FilterVisible onResizableChange?: VxeGridEvents.ResizableChange onToggleRowExpand?: VxeGridEvents.ToggleRowExpand onToggleTreeExpand?: VxeGridEvents.ToggleTreeExpand onMenuClick?: VxeGridEvents.MenuClick onEditClosed?: VxeGridEvents.EditClosed onEditActived?: VxeGridEvents.EditActived onEditDisabled?: VxeGridEvents.EditDisabled onValidError?: VxeGridEvents.ValidError onScroll?: VxeGridEvents.Scroll onCustom?: VxeGridEvents.Custom // grid onProxyQuery?: VxeGridEvents.ProxyQuery onProxyDelete?: VxeGridEvents.ProxyDelete onProxySave?: VxeGridEvents.ProxySave onPageChange?: VxeGridEvents.PageChange onFormSubmit?: VxeGridEvents.FormSubmit onFormSubmitInvalid?: VxeGridEvents.FormSubmitInvalid onFormReset?: VxeGridEvents.FormReset onFormCollapse?: VxeGridEvents.FormCollapse onToolbarButtonClick?: VxeGridEvents.ToolbarButtonClick onToolbarToolClick?: VxeGridEvents.ToolbarToolClick onZoom?: VxeGridEvents.Zoom } export interface VxeGridListeners { keydown?: VxeGridEvents.Keydown paste?: VxeGridEvents.Paste copy?: VxeGridEvents.Copy cut?: VxeGridEvents.Cut currentChange?: VxeGridEvents.CurrentChange radioChange?: VxeGridEvents.RadioChange checkboxChange?: VxeGridEvents.CheckboxChange checkboxAll?: VxeGridEvents.CheckboxAll checkboxRangeStart?: VxeGridEvents.CheckboxRangeStart checkboxRangeChange?: VxeGridEvents.CheckboxRangeChange checkboxRangeEnd?: VxeGridEvents.CheckboxRangeEnd cellClick?: VxeGridEvents.CellClick cellDblclick?: VxeGridEvents.CellDblclick cellMenu?: VxeGridEvents.CellMenu cellMouseenter?: VxeGridEvents.CellMouseenter cellMouseleave?: VxeGridEvents.CellMouseleave headerCellClick?: VxeGridEvents.HeaderCellClick headerCellDblclick?: VxeGridEvents.HeaderCellDblclick headerCellMenu?: VxeGridEvents.HeaderCellMenu footerCellClick?: VxeGridEvents.FooterCellClick footerCellDblclick?: VxeGridEvents.FooterCellDblclick footerCellMenu?: VxeGridEvents.FooterCellMenu sortChange?: VxeGridEvents.SortChange filterChange?: VxeGridEvents.FilterChange filterVisible?: VxeGridEvents.FilterVisible resizableChange?: VxeGridEvents.ResizableChange toggleRowExpand?: VxeGridEvents.ToggleRowExpand toggleTreeExpand?: VxeGridEvents.ToggleTreeExpand menuClick?: VxeGridEvents.MenuClick editClosed?: VxeGridEvents.EditClosed editActived?: VxeGridEvents.EditActived editDisabled?: VxeGridEvents.EditDisabled validError?: VxeGridEvents.ValidError scroll?: VxeGridEvents.Scroll custom?: VxeGridEvents.Custom // grid proxyQuery?: VxeGridEvents.ProxyQuery proxyDelete?: VxeGridEvents.ProxyDelete proxySave?: VxeGridEvents.ProxySave pageChange?: VxeGridEvents.PageChange formSubmit?: VxeGridEvents.FormSubmit formSubmitInvalid?: VxeGridEvents.FormSubmitInvalid formReset?: VxeGridEvents.FormReset formCollapse?: VxeGridEvents.FormCollapse toolbarButtonClick?: VxeGridEvents.ToolbarButtonClick toolbarToolClick?: VxeGridEvents.ToolbarToolClick zoom?: VxeGridEvents.Zoom } export namespace VxeGridEvents { export type Keydown = (params: VxeGridDefines.KeydownEventParams) => void export type Paste = (params: VxeGridDefines.PasteEventParams) => void export type Copy = (params: VxeGridDefines.CopyEventParams) => void export type Cut = (params: VxeGridDefines.CutEventParams) => void export type CurrentChange = (params: VxeGridDefines.CurrentChangeEventParams) => void export type RadioChange = (params: VxeGridDefines.RadioChangeEventParams) => void export type CheckboxChange = (params: VxeGridDefines.CheckboxChangeEventParams) => void export type CheckboxAll = (params: VxeGridDefines.CheckboxAllEventParams) => void export type CheckboxRangeStart = (params: VxeGridDefines.CheckboxRangeStartEventParams) => void export type CheckboxRangeChange = (params: VxeGridDefines.CheckboxRangeChangeEventParams) => void export type CheckboxRangeEnd = (params: VxeGridDefines.CheckboxRangeEndEventParams) => void export type CellClick = (params: VxeGridDefines.CellClickEventParams) => void export type CellDblclick = (params: VxeGridDefines.CellDblclickEventParams) => void export type CellMenu = (params: VxeGridDefines.CellMenuEventParams) => void export type CellMouseenter = (params: VxeGridDefines.CellMouseenterEventParams) => void export type CellMouseleave = (params: VxeGridDefines.CellMouseleaveEventParams) => void export type HeaderCellClick = (params: VxeGridDefines.HeaderCellClickEventParams) => void export type HeaderCellDblclick = (params: VxeGridDefines.HeaderCellDblclickEventParams) => void export type HeaderCellMenu = (params: VxeGridDefines.HeaderCellMenuEventParams) => void export type FooterCellClick = (params: VxeGridDefines.FooterCellClickEventParams) => void export type FooterCellDblclick = (params: VxeGridDefines.FooterCellDblclickEventParams) => void export type FooterCellMenu = (params: VxeGridDefines.FooterCellMenuEventParams) => void export type SortChange = (params: VxeGridDefines.SortChangeEventParams) => void export type FilterChange = (params: VxeGridDefines.FilterChangeEventParams) => void export type FilterVisible = (params: VxeGridDefines.FilterVisibleEventParams) => void export type ResizableChange = (params: VxeGridDefines.ResizableChangeEventParams) => void export type ToggleRowExpand = (params: VxeGridDefines.ToggleRowExpandEventParams) => void export type ToggleTreeExpand = (params: VxeGridDefines.ToggleTreeExpandEventParams) => void export type MenuClick = (params: VxeGridDefines.MenuClickEventParams) => void export type EditClosed = (params: VxeGridDefines.EditClosedEventParams) => void export type EditActived = (params: VxeGridDefines.EditActivedEventParams) => void export type EditDisabled = (params: VxeGridDefines.EditDisabledEventParams) => void export type ValidError = (params: VxeGridDefines.ValidErrorEventParams) => void export type Scroll = (params: VxeGridDefines.ScrollEventParams) => void export type Custom = (params: VxeGridDefines.CustomEventParams) => void export type ProxyQuery = (params: VxeGridDefines.ProxyQueryEventParams) => void export type ProxyDelete = (params: VxeGridDefines.ProxyDeleteEventParams) => void export type ProxySave = (params: VxeGridDefines.ProxySaveEventParams) => void export type PageChange = (params: VxeGridDefines.PageChangeEventParams) => void export type FormSubmit = (params: VxeGridDefines.FormSubmitEventParams) => void export type FormSubmitInvalid = (params: VxeGridDefines.FormSubmitInvalidEventParams) => void export type FormReset = (params: VxeGridDefines.FormResetEventParams) => void export type FormCollapse = (params: VxeGridDefines.FormCollapseEventParams) => void export type ToolbarButtonClick = (params: VxeGridDefines.ToolbarButtonClickEventParams) => void export type ToolbarToolClick = (params: VxeGridDefines.ToolbarToolClickEventParams) => void export type Zoom = (params: VxeGridDefines.ZoomEventParams) => void } export interface VxeGridSlots { /** * 自定义空数据时显示模板 */ empty?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义加载中模板 */ loading?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义表单模板 */ form?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义工具栏模板 */ toolbar?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义表格顶部模板 */ top?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 表格底部模板 */ bottom?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义分页模板 */ pager?(params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined }): any /** * 自定义插槽模板 */ [key: string]: ((params: { $table: VxeTableConstructor $grid: VxeGridConstructor | null | undefined row: D rowIndex: number $rowIndex: number _rowIndex: number column: VxeTableDefines.ColumnInfo columnIndex: number $columnIndex: number _columnIndex: number checked?: boolean indeterminate?: boolean items: D[] [key: string]: any }) => any) | undefined }