fix: 修改“岗位管理”-pagination翻页、变换page大小时排序的错误。

This commit is contained in:
Kevin Zhang 2023-10-05 00:41:14 +08:00
parent 0217e53b87
commit 9563c073cf

View File

@ -16,7 +16,7 @@ const statusMap = useUserStoreHook().dictionaryMap["common.status"];
export function usePostHook() { export function usePostHook() {
const defaultSort: Sort = { const defaultSort: Sort = {
prop: "post_sort", prop: "postSort",
order: "ascending" order: "ascending"
}; };
@ -117,7 +117,7 @@ export function usePostHook() {
sortState.value = sort; sortState.value = sort;
// 表格列的排序变化的时候,需要重置分页 // 表格列的排序变化的时候,需要重置分页
pagination.currentPage = 1; pagination.currentPage = 1;
getPostList(sort); getPostList();
} }
async function onSearch(tableRef) { async function onSearch(tableRef) {
@ -126,7 +126,7 @@ export function usePostHook() {
// 点击搜索的时候,需要清空表格上列的排序 // 点击搜索的时候,需要清空表格上列的排序
tableRef.getTableRef().clearSort(); tableRef.getTableRef().clearSort();
// 使用默认排序发起请求 // 使用默认排序发起请求
getPostList(defaultSort); getPostList();
} }
function resetForm(formEl, tableRef) { function resetForm(formEl, tableRef) {
@ -144,11 +144,9 @@ export function usePostHook() {
onSearch(tableRef); onSearch(tableRef);
} }
async function getPostList(sort: Sort = defaultSort) { async function getPostList() {
pageLoading.value = true; pageLoading.value = true;
if (sort != null) { CommonUtils.fillSortParams(searchFormParams, sortState.value);
CommonUtils.fillSortParams(searchFormParams, sort);
}
CommonUtils.fillPaginationParams(searchFormParams, pagination); CommonUtils.fillPaginationParams(searchFormParams, pagination);
const { data } = await getPostListApi(toRaw(searchFormParams)).finally( const { data } = await getPostListApi(toRaw(searchFormParams)).finally(