fix:sortBy ,descending
- ทำ sortBy เฉพาะ API ที่มีการทำ paging
This commit is contained in:
parent
4308f8887f
commit
1f18b56fbf
13 changed files with 98 additions and 67 deletions
|
|
@ -38,6 +38,14 @@ const props = defineProps({
|
|||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
sortBy: {
|
||||
type: String,
|
||||
default: "dateSendLeave",
|
||||
},
|
||||
descending: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
@ -56,11 +64,10 @@ const table = ref<any>(null);
|
|||
const currentPage = ref<number>(1);
|
||||
|
||||
const pagination = ref<PropsTable.Pagination>({
|
||||
sortBy: "dateSendLeave",
|
||||
descending: true,
|
||||
sortBy: props.sortBy,
|
||||
descending: props.descending,
|
||||
page: 1,
|
||||
rowsPerPage: Number(props.pageSize),
|
||||
|
||||
rowsNumber: Number(props.total),
|
||||
});
|
||||
|
||||
|
|
@ -94,9 +101,20 @@ function filterTable() {
|
|||
);
|
||||
}
|
||||
|
||||
/** function updatePagination*/
|
||||
function updatePagination(p: number, ps: number) {
|
||||
emit("update:Pagination", p, ps);
|
||||
/**
|
||||
* ฟังก์ชันอัปเดตการแบ่งหน้า
|
||||
* @param p หน้า
|
||||
* @param ps ขนาดหน้า
|
||||
* @param sortBy เรียงลำดับตาม
|
||||
* @param descending เรียงลำดับจากน้อยไปมาก
|
||||
*/
|
||||
function updatePagination(
|
||||
p: number,
|
||||
ps: number,
|
||||
sortBy?: string,
|
||||
descending?: boolean
|
||||
) {
|
||||
emit("update:Pagination", p, ps, sortBy, descending);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -108,7 +126,12 @@ function onTableRequest(requestProps: PropsTable.RequestProps) {
|
|||
if (!newPagination?.page || !newPagination?.rowsPerPage) return;
|
||||
currentPage.value = newPagination.page;
|
||||
pagination.value = { ...newPagination };
|
||||
updatePagination(newPagination.page, newPagination.rowsPerPage);
|
||||
updatePagination(
|
||||
newPagination.page,
|
||||
newPagination.rowsPerPage,
|
||||
newPagination.sortBy,
|
||||
newPagination.descending
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue