From 0217e53b872119cd8154c5b648eaea4e01aff66b Mon Sep 17 00:00:00 2001 From: Kevin Zhang Date: Wed, 4 Oct 2023 23:28:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E2=80=9C=E5=B2=97?= =?UTF-8?q?=E4=BD=8D=E7=AE=A1=E7=90=86=E2=80=9D-=E6=9F=A5=E8=AF=A2+?= =?UTF-8?q?=E9=87=8D=E7=BD=AE+=E6=8E=92=E5=BA=8F=E7=9A=84=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/post/index.vue | 2 +- src/views/system/post/utils/hook.tsx | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/views/system/post/index.vue b/src/views/system/post/index.vue index c080705..b0dec38 100644 --- a/src/views/system/post/index.vue +++ b/src/views/system/post/index.vue @@ -110,7 +110,7 @@ function openDialog(type: "add" | "update", row?: PostPageResponse) { type="primary" :icon="useRenderIcon(Search)" :loading="pageLoading" - @click="onSearch" + @click="onSearch(tableRef)" > 搜索 diff --git a/src/views/system/post/utils/hook.tsx b/src/views/system/post/utils/hook.tsx index 1985291..3c6d092 100644 --- a/src/views/system/post/utils/hook.tsx +++ b/src/views/system/post/utils/hook.tsx @@ -16,8 +16,8 @@ const statusMap = useUserStoreHook().dictionaryMap["common.status"]; export function usePostHook() { const defaultSort: Sort = { - prop: "createTime", - order: "descending" + prop: "post_sort", + order: "ascending" }; const pagination: PaginationProps = { @@ -80,6 +80,7 @@ export function usePostHook() { { label: "岗位排序", prop: "postSort", + sortable: "custom", minWidth: 120 }, { @@ -114,13 +115,18 @@ export function usePostHook() { function onSortChanged(sort: Sort) { sortState.value = sort; - onSearch(); + // 表格列的排序变化的时候,需要重置分页 + pagination.currentPage = 1; + getPostList(sort); } - async function onSearch() { - // 点击搜索的时候 需要重置分页 + async function onSearch(tableRef) { + // 点击搜索的时候,需要重置分页 pagination.currentPage = 1; - getPostList(); + // 点击搜索的时候,需要清空表格上列的排序 + tableRef.getTableRef().clearSort(); + // 使用默认排序发起请求 + getPostList(defaultSort); } function resetForm(formEl, tableRef) { @@ -134,9 +140,8 @@ export function usePostHook() { // Form组件的resetFields方法无法清除datepicker里面的数据。 searchFormParams.beginTime = undefined; searchFormParams.endTime = undefined; - tableRef.getTableRef().clearSort(); // 重置分页并查询 - onSearch(); + onSearch(tableRef); } async function getPostList(sort: Sort = defaultSort) {