diff --git a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue index 5176dcf92..768e9fff2 100644 --- a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue +++ b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue @@ -1,10 +1,11 @@ + diff --git a/src/modules/13_salary/components/04_salaryLists/TabMain.vue b/src/modules/13_salary/components/04_salaryLists/TabMain.vue index 9db593cd9..ac12d597f 100644 --- a/src/modules/13_salary/components/04_salaryLists/TabMain.vue +++ b/src/modules/13_salary/components/04_salaryLists/TabMain.vue @@ -5,10 +5,10 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import genReportXLSX from "@/plugins/genreportxlsx"; +import { usePagination } from "@/composables/usePagination"; /** importType*/ import type { DataOption } from "@/modules/13_salary/interface/index/Main"; -import type { DataFilter } from "@/modules/13_salary/interface/index/SalaryList"; import type { DataPeriodLatest, DataPeriod, @@ -27,6 +27,10 @@ import { useSalaryListSDataStore } from "@/modules/13_salary/store/SalaryListsSt const $q = useQuasar(); const store = useSalaryListSDataStore(); const { messageError, showLoader, hideLoader } = useCounterMixin(); +const { pagination, params, onRequest, checkAndUpdatePage } = usePagination( + "", + () => fetchDataPeriod(store.groupId, true) +); /** props*/ const props = defineProps({ @@ -44,6 +48,8 @@ const rows = ref([]); const modalDialogInfoCriteria = ref(false); // ตัวแปรสำหรับแสดง Dialog แสดงหลักเกณฑ์การพิจารณาเลื่อนขั้นเงินข้าราชการ const isRetire = ref(false); // ตัวแปรสำหรับแสดงเฉพาะผู้เกษียณอายุราชการ +const keyword = ref(""); + /** itemsTab กลุ่ม*/ const itemsTabGroup = ref([ { @@ -210,15 +216,6 @@ const itemsCard = ref([ }, ]); -/** ข้อมูลค้นหารายชื่อคนขึ้นเงินเดือน*/ -const formFilter = reactive({ - page: 1, - pageSize: 10, - keyword: "", - type: store.tabType, -}); -const maxPage = ref(1); // จำนวนหน้าสูงสุด - /** * ฟังก์ชันเรียกข้อมูลโควต้า * @param id กลุ่ม @@ -255,11 +252,11 @@ async function fetchDataQuota(id: string) { * ฟังก์ชันเรียกข้อมูลรายชื่อเลื่อนเงินเดือนข้าราชการฯ * @param id กลุ่ม */ -async function fetchDataPeriod(id: string) { +async function fetchDataPeriod(id: string, force: boolean = false) { + force && showLoader(); let formData = { - page: formFilter.page.toString(), - pageSize: formFilter.pageSize.toString(), - keyword: formFilter.keyword.trim(), + ...params.value, + keyword: keyword.value.trim(), type: store.tabType, isRetire: store.roundMainCode !== "OCT" @@ -268,17 +265,20 @@ async function fetchDataPeriod(id: string) { ? "1" : "0", }; - rows.value = []; - await http .put(config.API.salaryListPeriodORG(id), formData) .then((res) => { - rows.value = res.data.result.data; - total.value = res.data.result.total; - maxPage.value = Math.ceil(res.data.result.total / formFilter.pageSize); + const result = res.data.result; + pagination.value.rowsNumber = result.total; + rows.value = result.data; + total.value = result.total; }) .catch((err) => { messageError($q, err); + rows.value = []; + }) + .finally(() => { + force && hideLoader(); }); } @@ -287,9 +287,9 @@ async function changeTabGroup() { showLoader(); try { await Promise.all([ - (formFilter.page = 1), - (formFilter.pageSize = 10), - (formFilter.keyword = ""), + (pagination.value.page = 1), + (pagination.value.rowsPerPage = 10), + (keyword.value = ""), (store.tabType = "PENDING"), props.periodLatest && store.fetchPeriodLatest(props?.periodLatest, store.tabGroup), @@ -309,9 +309,9 @@ async function changeTabType() { if (!store.groupId) return; showLoader(); try { - formFilter.page = 1; - formFilter.pageSize = 10; - formFilter.keyword = ""; + pagination.value.page = 1; + pagination.value.rowsPerPage = 10; + keyword.value = ""; store.groupId && (await fetchDataPeriod(store.groupId)); } catch (error) { messageError($q, error); @@ -671,24 +671,26 @@ onMounted(async () => { diff --git a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue index 2827baa1c..2de930508 100644 --- a/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue +++ b/src/modules/13_salary/components/04_salaryLists/TableTypeOther.vue @@ -1,15 +1,14 @@