diff --git a/src/modules/09_leave/components/05_Leave/Tab1.vue b/src/modules/09_leave/components/05_Leave/Tab1.vue index 9c1e1101b..9454ec890 100644 --- a/src/modules/09_leave/components/05_Leave/Tab1.vue +++ b/src/modules/09_leave/components/05_Leave/Tab1.vue @@ -28,9 +28,7 @@ const querySting = ref({ type: leaveStore.filter.type, //*Id ประเภทการลา status: leaveStore.filter.status, //*สถานะการของลา page: 1, //*สถานะการของลา - pageSize: 10, //*สถานะการของลา - sortBy: "dateSendLeave", - descending: true, + rowsPerPage: 10, keyword: leaveStore.filter.keyword, //keyword ค้นหา profileType: "ALL", //profileType }); @@ -47,13 +45,18 @@ async function fecthLeaveList() { : querySting.value.type); if (querySting.value.status != null && querySting.value.type != null) { + // เอาฟิลrowsPerPage ออก + const { rowsPerPage, ...queryStingData } = querySting.value; showLoader(); await http - .post(config.API.leaveList(), querySting.value) + .post(config.API.leaveList(), { + ...queryStingData, + pageSize: querySting.value.rowsPerPage, + }) .then(async (res) => { - const data = res.data.result; + const data = await res.data.result; totalList.value = Math.ceil( - res.data.result.total / querySting.value.pageSize + res.data.result.total / querySting.value.rowsPerPage ); total.value = res.data.result.total; await leaveStore.fetchListLeave(data.data); /** ส่งข้อมูลไป stores*/ @@ -87,7 +90,7 @@ function getSearch() { } watch( - () => querySting.value.pageSize, + () => querySting.value.rowsPerPage, async () => { getSearch(); } diff --git a/src/modules/09_leave/components/05_Leave/Tab2.vue b/src/modules/09_leave/components/05_Leave/Tab2.vue index dad4bbe93..2920c3161 100644 --- a/src/modules/09_leave/components/05_Leave/Tab2.vue +++ b/src/modules/09_leave/components/05_Leave/Tab2.vue @@ -30,9 +30,7 @@ const querySting = ref({ type: leaveStore.filter.type, //*Id ประเภทการลา status: leaveStore.filter.status, //*สถานะการของลา page: 1, //*สถานะการของลา - pageSize: 10, //*สถานะการของลา - sortBy: "dateSendLeave", - descending: true, + rowsPerPage: 10, //*สถานะการของลา keyword: leaveStore.filter.keyword, //keyword ค้นหา profileType: "ALL", //profileType }); @@ -48,13 +46,17 @@ async function fecthLeaveList() { : querySting.value.type); if (querySting.value.status != null && querySting.value.type != null) { + const { rowsPerPage, ...queryStingData } = querySting.value; showLoader(); await http - .post(config.API.leaveListDelete(), querySting.value) + .post(config.API.leaveList(), { + ...queryStingData, + pageSize: querySting.value.rowsPerPage, + }) .then((res) => { const data = res.data.result; totalList.value = Math.ceil( - res.data.result.total / querySting.value.pageSize + res.data.result.total / querySting.value.rowsPerPage ); total.value = res.data.result.total; fetchListLeaveReject(data.data); /** ส่งข้อมูลไป stores*/ @@ -88,7 +90,7 @@ function getSearch() { } watch( - () => querySting.value.pageSize, + () => querySting.value.rowsPerPage, async () => { getSearch(); } diff --git a/src/modules/09_leave/components/05_Leave/TableList.vue b/src/modules/09_leave/components/05_Leave/TableList.vue index f75cdd5e7..df655646a 100644 --- a/src/modules/09_leave/components/05_Leave/TableList.vue +++ b/src/modules/09_leave/components/05_Leave/TableList.vue @@ -236,7 +236,7 @@ function redirectToDetail(id: string) { function updatePagination(newPagination: any) { pagination.value.page = 1; - pagination.value.pageSize = newPagination.rowsPerPage; + pagination.value.rowsPerPage = newPagination.rowsPerPage; } /** @@ -280,7 +280,6 @@ onMounted(() => { :paging="true" dense class="custom-header-table" - v-model:pagination="pagination" :visible-columns="leaveStore.visibleColumns" :rows-per-page-options="[10, 25, 50, 100]" @update:pagination="updatePagination" @@ -311,7 +310,9 @@ onMounted(() => {
{{ - (pagination.page - 1) * pagination.pageSize + props.rowIndex + 1 + (pagination.page - 1) * pagination.rowsPerPage + + props.rowIndex + + 1 }}
diff --git a/src/modules/09_leave/interface/request/leave.ts b/src/modules/09_leave/interface/request/leave.ts index b629ba1df..e09249b0f 100644 --- a/src/modules/09_leave/interface/request/leave.ts +++ b/src/modules/09_leave/interface/request/leave.ts @@ -10,7 +10,7 @@ interface QuerySting { type: string; //*Id ประเภทการลา status: string; //*สถานะการของลา page: number; //*หน้า - pageSize: number; //*จำนวนแถวต่อหน้า + rowsPerPage: number; //*จำนวนแถวต่อหน้า keyword: string; //keyword ค้นหา profileType: string; sortBy?: string; diff --git a/src/modules/09_leave/stores/LeaveStore.ts b/src/modules/09_leave/stores/LeaveStore.ts index 93cce6878..f9377bf8a 100644 --- a/src/modules/09_leave/stores/LeaveStore.ts +++ b/src/modules/09_leave/stores/LeaveStore.ts @@ -31,7 +31,7 @@ export const useLeavelistDataStore = defineStore("leave", () => { /**ข้อมูลใน Table*/ const mainData = ref([]); - const rows = ref([]); + const rows = ref([]); const columns = ref([]); const visibleColumns = ref([]); @@ -70,7 +70,7 @@ export const useLeavelistDataStore = defineStore("leave", () => { status: e.status && convertSatatus(e.status), })); mainData.value = datalist; - rows.value = mainData.value; + rows.value = datalist; } /** @@ -173,7 +173,7 @@ export const useLeavelistDataStore = defineStore("leave", () => { dataToobar.value = val.map((e: any) => ({ id: e.id, name: e.name, - code:e.code + code: e.code, })); }