fix: 修改“岗位管理”-查询+重置+排序的错误。

This commit is contained in:
Kevin Zhang 2023-10-04 23:28:54 +08:00
parent 1fc2fea752
commit 0217e53b87
2 changed files with 14 additions and 9 deletions

View File

@ -110,7 +110,7 @@ function openDialog(type: "add" | "update", row?: PostPageResponse) {
type="primary" type="primary"
:icon="useRenderIcon(Search)" :icon="useRenderIcon(Search)"
:loading="pageLoading" :loading="pageLoading"
@click="onSearch" @click="onSearch(tableRef)"
> >
搜索 搜索
</el-button> </el-button>

View File

@ -16,8 +16,8 @@ const statusMap = useUserStoreHook().dictionaryMap["common.status"];
export function usePostHook() { export function usePostHook() {
const defaultSort: Sort = { const defaultSort: Sort = {
prop: "createTime", prop: "post_sort",
order: "descending" order: "ascending"
}; };
const pagination: PaginationProps = { const pagination: PaginationProps = {
@ -80,6 +80,7 @@ export function usePostHook() {
{ {
label: "岗位排序", label: "岗位排序",
prop: "postSort", prop: "postSort",
sortable: "custom",
minWidth: 120 minWidth: 120
}, },
{ {
@ -114,13 +115,18 @@ export function usePostHook() {
function onSortChanged(sort: Sort) { function onSortChanged(sort: Sort) {
sortState.value = sort; sortState.value = sort;
onSearch(); // 表格列的排序变化的时候,需要重置分页
pagination.currentPage = 1;
getPostList(sort);
} }
async function onSearch() { async function onSearch(tableRef) {
// 点击搜索的时候 需要重置分页 // 点击搜索的时候需要重置分页
pagination.currentPage = 1; pagination.currentPage = 1;
getPostList(); // 点击搜索的时候,需要清空表格上列的排序
tableRef.getTableRef().clearSort();
// 使用默认排序发起请求
getPostList(defaultSort);
} }
function resetForm(formEl, tableRef) { function resetForm(formEl, tableRef) {
@ -134,9 +140,8 @@ export function usePostHook() {
// Form组件的resetFields方法无法清除datepicker里面的数据。 // Form组件的resetFields方法无法清除datepicker里面的数据。
searchFormParams.beginTime = undefined; searchFormParams.beginTime = undefined;
searchFormParams.endTime = undefined; searchFormParams.endTime = undefined;
tableRef.getTableRef().clearSort();
// 重置分页并查询 // 重置分页并查询
onSearch(); onSearch(tableRef);
} }
async function getPostList(sort: Sort = defaultSort) { async function getPostList(sort: Sort = defaultSort) {