From 94a1d6dc204b406613df44c84d0aebbacf4a379d Mon Sep 17 00:00:00 2001 From: xlsea Date: Tue, 11 Jun 2024 10:14:20 +0800 Subject: [PATCH] =?UTF-8?q?perf(sj=5F1.0.0=5Fbeta1):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=90=BA=E5=B8=A6=E5=8F=82=E6=95=B0=E8=B7=AF=E7=94=B1=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/hooks/src/use-table.ts | 5 ++++ src/hooks/common/table.ts | 1 + src/typings/naive-ui.d.ts | 2 +- src/views/job/batch/index.vue | 48 +++++------------------------- src/views/job/task/index.vue | 3 +- src/views/retry/log/index.vue | 14 +++------ src/views/workflow/batch/index.vue | 25 +++++----------- src/views/workflow/task/index.vue | 2 +- 8 files changed, 30 insertions(+), 70 deletions(-) diff --git a/packages/hooks/src/use-table.ts b/packages/hooks/src/use-table.ts index 6c2ae07..da17be5 100644 --- a/packages/hooks/src/use-table.ts +++ b/packages/hooks/src/use-table.ts @@ -29,6 +29,8 @@ export type TableConfig = { apiFn: A; /** api params */ apiParams?: Parameters[0]; + /** search params */ + searchParams?: Parameters[0]; /** transform api response to table data */ transformer: Transformer>>; /** columns factory */ @@ -133,6 +135,9 @@ export default function useHookTable(config: TableConfig< } if (immediate) { + if (config.searchParams) { + updateSearchParams(config.searchParams); + } getData(); } diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index 962deaf..5d3c728 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -36,6 +36,7 @@ export function useTable(config: NaiveUI.NaiveTabl } = useHookTable, TableColumn>>>({ apiFn, apiParams, + searchParams: config.searchParams, columns: config.columns, transformer: res => { const { data: records = [], page: current = 1, size = 10, total = 0 } = res.data || {}; diff --git a/src/typings/naive-ui.d.ts b/src/typings/naive-ui.d.ts index c8e6f25..7074643 100644 --- a/src/typings/naive-ui.d.ts +++ b/src/typings/naive-ui.d.ts @@ -42,7 +42,7 @@ declare namespace NaiveUI { type NaiveTableConfig = Pick< import('@sa/hooks').TableConfig, TableColumn>>>, - 'apiFn' | 'apiParams' | 'columns' | 'immediate' + 'apiFn' | 'apiParams' | 'columns' | 'immediate' | 'searchParams' > & { /** * whether to display the total items count diff --git a/src/views/job/batch/index.vue b/src/views/job/batch/index.vue index 8026c45..075c640 100644 --- a/src/views/job/batch/index.vue +++ b/src/views/job/batch/index.vue @@ -1,9 +1,8 @@