From 439e3b0f076280311b7cd4251a95820730242780 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期三, 07 八月 2024 10:43:33 +0800 Subject: [PATCH] 一些更新 --- src/components/Table/src/hooks/useTable.ts | 45 ++++++++++++++++++++++++++------------------- 1 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/components/Table/src/hooks/useTable.ts b/src/components/Table/src/hooks/useTable.ts index 323eb23..1e353ab 100644 --- a/src/components/Table/src/hooks/useTable.ts +++ b/src/components/Table/src/hooks/useTable.ts @@ -1,12 +1,13 @@ import type { BasicTableProps, TableActionType, FetchParams, BasicColumn } from '../types/table'; import type { PaginationProps } from '../types/pagination'; -import type { DynamicProps } from '/#/utils'; -import type { FormActionType } from '/@/components/Form'; +import type { DynamicProps } from '#/utils'; +import type { FormActionType } from '@/components/Form'; import type { WatchStopHandle } from 'vue'; -import { getDynamicProps } from '/@/utils'; +import { getDynamicProps } from '@/utils'; import { ref, onUnmounted, unref, watch, toRaw } from 'vue'; -import { isProdMode } from '/@/utils/env'; -import { error } from '/@/utils/log'; +import { isProdMode } from '@/utils/env'; +import { error } from '@/utils/log'; +import type { Key } from 'ant-design-vue/lib/table/interface'; type Props = Partial<DynamicProps<BasicTableProps>>; @@ -88,11 +89,14 @@ getRawDataSource: () => { return getTableInstance().getRawDataSource(); }, + getSearchInfo: () => { + return getTableInstance().getSearchInfo(); + }, getColumns: ({ ignoreIndex = false }: { ignoreIndex?: boolean } = {}) => { const columns = getTableInstance().getColumns({ ignoreIndex }) || []; return toRaw(columns); }, - setColumns: (columns: BasicColumn[]) => { + setColumns: (columns: BasicColumn[] | string[]) => { getTableInstance().setColumns(columns); }, setTableData: (values: any[]) => { @@ -101,8 +105,8 @@ setPagination: (info: Partial<PaginationProps>) => { return getTableInstance().setPagination(info); }, - deleteSelectRowByKey: (key: string) => { - getTableInstance().deleteSelectRowByKey(key); + deleteSelectRowByKey: (keyValue: Key) => { + getTableInstance().deleteSelectRowByKey(keyValue); }, getSelectRowKeys: () => { return toRaw(getTableInstance().getSelectRowKeys()); @@ -113,8 +117,8 @@ clearSelectedRowKeys: () => { getTableInstance().clearSelectedRowKeys(); }, - setSelectedRowKeys: (keys: string[] | number[]) => { - getTableInstance().setSelectedRowKeys(keys); + setSelectedRowKeys: (keyValues: Key[]) => { + getTableInstance().setSelectedRowKeys(keyValues); }, getPaginationRef: () => { return getTableInstance().getPaginationRef(); @@ -125,17 +129,17 @@ updateTableData: (index: number, key: string, value: any) => { return getTableInstance().updateTableData(index, key, value); }, - deleteTableDataRecord: (rowKey: string | number | string[] | number[]) => { - return getTableInstance().deleteTableDataRecord(rowKey); + deleteTableDataRecord: (keyValues: Key | Key[]) => { + return getTableInstance().deleteTableDataRecord(keyValues); }, insertTableDataRecord: (record: Recordable | Recordable[], index?: number) => { return getTableInstance().insertTableDataRecord(record, index); }, - updateTableDataRecord: (rowKey: string | number, record: Recordable) => { - return getTableInstance().updateTableDataRecord(rowKey, record); + updateTableDataRecord: (keyValue: Key, record: Recordable) => { + return getTableInstance().updateTableDataRecord(keyValue, record); }, - findTableDataRecord: (rowKey: string | number) => { - return getTableInstance().findTableDataRecord(rowKey); + findTableDataRecord: (keyValue: Key) => { + return getTableInstance().findTableDataRecord(keyValue); }, getRowSelection: () => { return toRaw(getTableInstance().getRowSelection()); @@ -155,12 +159,15 @@ expandAll: () => { getTableInstance().expandAll(); }, - expandRows: (keys: string[]) => { - getTableInstance().expandRows(keys); - }, collapseAll: () => { getTableInstance().collapseAll(); }, + expandRows: (keyValues: Key[]) => { + getTableInstance().expandRows(keyValues); + }, + collapseRows: (keyValues: Key[]) => { + getTableInstance().collapseRows(keyValues); + }, scrollTo: (pos: string) => { getTableInstance().scrollTo(pos); }, -- Gitblit v1.9.3