From 6ed93ee5e21e2d0818837a069fc71d903bcf7ea9 Mon Sep 17 00:00:00 2001 From: fangshun Date: Tue, 2 Apr 2024 11:14:09 +0800 Subject: [PATCH] fix: add sort Signed-off-by: fangshun --- src/services/Metric.ts | 2 +- src/services/Volume.ts | 4 ++-- src/services/data-contracts.ts | 4 ++++ src/views/dashboard/components/EventList.vue | 17 +++++++++----- .../components/LocalVolumeEvents.vue | 23 +++++++++++++++++-- swagger.json | 18 ++++++++++++--- 6 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/services/Metric.ts b/src/services/Metric.ts index d68c149..d477a1a 100644 --- a/src/services/Metric.ts +++ b/src/services/Metric.ts @@ -24,7 +24,7 @@ import { ContentType, HttpClient, RequestParams } from "./http-client"; export class Metric extends HttpClient { /** - * @description EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type) + * @description EventList 排序 resourceType枚举(Cluster;StorageNode;DiskNode;Pool;Volume;DiskVolume;Disk) sort枚举 (time、name、type) sortDir:升序"ASC" 降序"DESC" * * @tags Metric * @name EventsList diff --git a/src/services/Volume.ts b/src/services/Volume.ts index f87db97..d20f46c 100644 --- a/src/services/Volume.ts +++ b/src/services/Volume.ts @@ -36,7 +36,7 @@ import { ContentType, HttpClient, RequestParams } from "./http-client"; export class Volume extends HttpClient { /** - * @description list Volume 排序sortBy:"time","name","namespace" sortDir:升序"ASC" 降序"DESC" + * @description list Volume sortBy排序:"time","name","namespace" sortDir:升序"ASC" 降序"DESC" 默认按时间降序 * * @tags Volume * @name VolumesList @@ -106,7 +106,7 @@ export class Volume extends HttpClient diff --git a/src/services/data-contracts.ts b/src/services/data-contracts.ts index ea14fb3..731e943 100644 --- a/src/services/data-contracts.ts +++ b/src/services/data-contracts.ts @@ -2216,6 +2216,8 @@ export interface EventsListParams { resourceType?: string; /** sort */ sort?: string; + /** sortDir */ + sortDir?: string; } export interface NodesListParams { @@ -2410,6 +2412,8 @@ export interface VolumesEventsDetailParams { action?: string; /** sort */ sort?: string; + /** sortDir */ + sortDir?: string; /** volumeName */ volumeName: string; } diff --git a/src/views/dashboard/components/EventList.vue b/src/views/dashboard/components/EventList.vue index 06dfe34..196d342 100644 --- a/src/views/dashboard/components/EventList.vue +++ b/src/views/dashboard/components/EventList.vue @@ -48,7 +48,7 @@ import { computed, reactive, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useQueryTable, useDateFormat, createDialog } from '@dao-style/extend'; -import type { ApiEventAction, OperationsListParams } from '@/services/data-contracts'; +import type { ApiEventAction, EventsListParams } from '@/services/data-contracts'; import MonacoEditorDialog from '@/components/dialogs/MonacoEditorDialog.vue'; import type { DaoTableSort, SearchOption, SearchValue, @@ -141,10 +141,9 @@ const sortMap: Record = { time: 'time', }; -const queryEvents = async (req: OperationsListParams) => { +const queryEvents = async (req: EventsListParams) => { const { data } = await MetricApi.eventsList({ ...req, - sort: sortMap[sort.value.id], resourceName: search.resourceName?.[0] as string, resourceType: search.resourceType?.[0] as string, }); @@ -160,13 +159,19 @@ const [{ handleRefresh, }, { handleSearch, + filterData, }] = useQueryTable(queryEvents, { page: 1, pageSize: 10, - name: '', + sort: 'name', + sortDir: 'DESC', }); -const sortChangeEvent = () => { - sort.value.desc = true; + +const sortChangeEvent = ({ id, desc }: { id: string, desc: boolean }) => { + sort.value.id = id; + sort.value.desc = desc; + filterData.sort = sortMap[sort.value.id]; + filterData.sortDir = sort.value.desc ? 'DESC' : 'ASC'; handleRefresh(); }; diff --git a/src/views/local-volumes/components/LocalVolumeEvents.vue b/src/views/local-volumes/components/LocalVolumeEvents.vue index 19e7bc8..3758356 100644 --- a/src/views/local-volumes/components/LocalVolumeEvents.vue +++ b/src/views/local-volumes/components/LocalVolumeEvents.vue @@ -3,9 +3,11 @@ id="local-volume-event-list" :data="state.items" :columns="columns" + :sort="initialSort" :page-size="pagination.pageSize" :current-page="pagination.page" :total="pagination.total" + @sort-change="handleSortChange" @page-change="handleChangePage" @size-change="handleChangePageSize" @refresh="handleRefresh" @@ -47,7 +49,7 @@