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 @@
diff --git a/src/views/job/task/index.vue b/src/views/job/task/index.vue
index 9463821..1ee93d3 100644
--- a/src/views/job/task/index.vue
+++ b/src/views/job/task/index.vue
@@ -250,7 +250,8 @@ async function handleTriggerJob(id: string) {
}
function goToBatch(jobId: string) {
- routerPushByKey('job_batch', { query: { jobId } });
+ const findItem = data.value.find(item => item.id === jobId)!;
+ routerPushByKey('job_batch', { state: { jobName: findItem.jobName } });
}
function body(): Api.Job.ExportJob {
diff --git a/src/views/retry/log/index.vue b/src/views/retry/log/index.vue
index bc07353..82b2dc2 100644
--- a/src/views/retry/log/index.vue
+++ b/src/views/retry/log/index.vue
@@ -17,6 +17,7 @@ const appStore = useAppStore();
const detailData = ref();
/** 详情页可见状态 */
const { bool: detailVisible, setTrue: openDetail } = useBoolean(false);
+const retryStatus = history.state.retryStatus;
const { columns, columnChecks, data, getData, loading, mobilePagination, searchParams, resetSearchParams } = useTable({
apiFn: fetchRetryLogPageList,
@@ -32,6 +33,9 @@ const { columns, columnChecks, data, getData, loading, mobilePagination, searchP
bizNo: null,
retryStatus: null
},
+ searchParams: {
+ retryStatus
+ },
columns: () => [
{
type: 'selection',
@@ -168,16 +172,6 @@ async function loadRetryInfo(row: Api.RetryLog.RetryLog) {
const res = await fetchRetryLogById(row.id!);
detailData.value = (res.data as Api.RetryLog.RetryLog) || null;
}
-
-function initParams() {
- const retryStatus = history.state.retryStatus;
- if (retryStatus) {
- searchParams.retryStatus = retryStatus;
- getData();
- }
-}
-
-initParams();
diff --git a/src/views/workflow/batch/index.vue b/src/views/workflow/batch/index.vue
index 1451507..8a4bbfc 100644
--- a/src/views/workflow/batch/index.vue
+++ b/src/views/workflow/batch/index.vue
@@ -1,6 +1,6 @@
diff --git a/src/views/workflow/task/index.vue b/src/views/workflow/task/index.vue
index f2a3308..8a75ecf 100644
--- a/src/views/workflow/task/index.vue
+++ b/src/views/workflow/task/index.vue
@@ -238,7 +238,7 @@ function copy(id: string) {
}
function batch(id: string) {
- router.push({ path: '/workflow/batch', query: { workflowId: id } });
+ router.push({ path: '/workflow/batch', state: { workflowId: id } });
}
async function execute(id: string) {