diff --git a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue index a611f252a..5176dcf92 100644 --- a/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue +++ b/src/modules/13_salary/components/02_salaryEmployee/TabCriteria.vue @@ -1,6 +1,7 @@ diff --git a/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue b/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue index d6ef43154..a3b10b375 100644 --- a/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue +++ b/src/modules/13_salary/components/02_salaryEmployee/TabStructure.vue @@ -5,6 +5,7 @@ import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; +import { updateCurrentPage } from "@/utils/function"; /** importType*/ import type { QTableProps } from "quasar"; @@ -179,6 +180,11 @@ function onClickDelete(id: string) { http .delete(config.API.salaryEmployeeChartByid(id)) .then(async () => { + formFilter.page = await updateCurrentPage( + formFilter.page, + maxPage.value, + rows.value.length + ); await fetchListChart(); await success($q, "ลบข้อมูลสำเร็จ"); }) @@ -282,7 +288,7 @@ onMounted(() => { :rows="rows" :columns="columns" row-key="name" - :rows-per-page-options="[10, 20, 50, 100]" + :rows-per-page-options="[1, 10, 20, 50, 100]" :visible-columns="visibleColumns" @update:pagination="updatePageSize" > diff --git a/src/modules/13_salary/views/01_salaryMain.vue b/src/modules/13_salary/views/01_salaryMain.vue index 114a110ad..9a03034d5 100644 --- a/src/modules/13_salary/views/01_salaryMain.vue +++ b/src/modules/13_salary/views/01_salaryMain.vue @@ -4,25 +4,22 @@ import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; import config from "@/app.config"; -/** - * importType - */ +/** importType */ import type { QTableProps } from "quasar"; import type { NewPagination } from "@/modules/13_salary/interface/index/Main"; import type { Salary } from "@/modules/13_salary/interface/response/Main"; import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main"; -/** - * importComponents - */ +/** importComponents */ import DialogFormMain from "@/modules/13_salary/components/01_Salary/DialogFormMain.vue"; // ผังบัญชีเงินเดือน import DialogFormUpload from "@/modules/13_salary/components/01_Salary/DialogUpload.vue"; // อัปโหลดเอกสารอ้างอิง -/** use*/ +/** use composables */ const $q = useQuasar(); const router = useRouter(); const { @@ -34,7 +31,7 @@ const { success, } = useCounterMixin(); -/** modalDialog*/ +/** modalDialog */ const modalDialogFormMain = ref(false); //popup เพิ่ม,แก้ไข ผังบัญชีเงินเดือน const modalUpload = ref(false); //popup อัปโหลดเอกสารอ้างอิง const rowId = ref(""); // id รายการผังบัญชีเงินเดือน @@ -86,7 +83,7 @@ const visibleColumns = ref([ "isActive", ]); -/** queryString*/ +/** queryString */ const formQuery = reactive({ page: 1, //*หน้า pageSize: 10, //*จำนวนแถวต่อหน้า @@ -98,9 +95,7 @@ const isActive = ref(false); //สถานะการใช้งา const typeAction = ref(""); //ประเภทการกระทำ const dataSalary = ref(); //ข้อมูลรายการผังบัญชีเงินเดือนที่ต้องการแก้ไข -/** - * fetch ข้อมูลรายการผังบัญชีเงินเดือน - */ +/** ฟังก์ชันดึงข้อมูลรายการผังบัญชีเงินเดือน */ async function fetchListSalaly() { showLoader(); const page = formQuery.page.toString(); @@ -126,8 +121,8 @@ async function fetchListSalaly() { } /** - * function openDialog เพิ่ม,แก้ไข ผังบัญชีเงินเดือน - * @param type ประเภท แก่ไข,เพิ่ม + * ฟังก์ชัน openDialog เพิ่ม,แก้ไข ผังบัญชีเงินเดือน + * @param type ประเภท แก้ไข,เพิ่ม * @param data ข้อมูลผังบัญชีเงินเดือน */ function onClickSalary(type: string, data: Salary | null) { @@ -139,7 +134,7 @@ function onClickSalary(type: string, data: Salary | null) { } /** - * function redirect to page อัตราเงินเดือน + * ฟังก์ชัน redirect to page อัตราเงินเดือน * @param id บัญชีเงินเดือน */ function onClickSalaryRate(id: string) { @@ -147,7 +142,7 @@ function onClickSalaryRate(id: string) { } /** - * function คัดลอกข้อมูลรายการผังบัญชีเงินเดือน + * ฟังก์ชันคัดลอกข้อมูลรายการผังบัญชีเงินเดือน * @param id บัญชีเงินเดือน */ function onClickCoppy(id: string) { @@ -167,21 +162,21 @@ function onClickCoppy(id: string) { } /** - * function ลบข้อมูลรายการผังบัญชีเงินเดือน + * ฟังก์ชันลบข้อมูลรายการผังบัญชีเงินเดือน * @param id บัญชีเงินเดือน */ function onClickDelete(id: string) { dialogRemove($q, async () => { showLoader(); - formQuery.page = - formQuery.page !== 1 && - formQuery.page === maxPage.value && - rows.value.length === 1 - ? formQuery.page - 1 - : formQuery.page; await http .delete(config.API.salaryChartByid(id)) .then(async () => { + formQuery.page = await updateCurrentPage( + formQuery.page, + maxPage.value, + rows.value.length + ); + await fetchListSalaly(); success($q, "ลบข้อมูลสำเร็จ"); }) @@ -195,7 +190,7 @@ function onClickDelete(id: string) { } /** - * function openDialog อัปโหลดเอกสารอ้างอิง + * ฟังก์ชัน openDialog อัปโหลดเอกสารอ้างอิง * @param type * @param id ผังบัญชีเงินเดือน * @param active สถานะการใช้งาน @@ -208,7 +203,7 @@ function onClickUpload(type: string, id: string, active: boolean) { } /** - * function updatePagination + * ฟังก์ชัน updatePagination * @param newPagination ข้อมูล Pagination ใหม่ */ function updatePagination(newPagination: NewPagination) { @@ -216,16 +211,12 @@ function updatePagination(newPagination: NewPagination) { formQuery.pageSize = newPagination.rowsPerPage; } -/** - * function ค้นหาข้อมูลตาม keyword - */ +/** ฟังก์ชัน ค้นหาข้อมูลตาม keyword */ function filterFn(page: number) { page !== 1 ? (formQuery.page = 1) : fetchListSalaly(); } -/** - * callbackFunction ทำงานเมื่อมีการ เปลี่ยนแถว - */ +/** callbackFunction ทำงานเมื่อมีการ เปลี่ยนแถว */ watch( () => formQuery.pageSize, () => { diff --git a/src/modules/13_salary/views/03_salaryRound.vue b/src/modules/13_salary/views/03_salaryRound.vue index 71516124c..12672c075 100644 --- a/src/modules/13_salary/views/03_salaryRound.vue +++ b/src/modules/13_salary/views/03_salaryRound.vue @@ -3,6 +3,7 @@ import { ref, watch, onMounted } from "vue"; import { useQuasar } from "quasar"; import { checkPermission } from "@/utils/permissions"; +import { updateCurrentPage } from "@/utils/function"; import { useCounterMixin } from "@/stores/mixin"; import { useSalaryDataStore } from "@/modules/13_salary/store/SalaryStore"; import config from "@/app.config"; @@ -42,7 +43,6 @@ const yearData = ref(0); //ปีงบประมาณ /** Table*/ const year = ref(0); //ปีงบประมาณ const filterKeyword = ref(""); //คำค้นหา -const currentPage = ref(1); //หน้า const maxPage = ref(1); //จำนวนหน้า const totalList = ref(0); //จำนวนรายการ const page = ref(1); //หน้า @@ -117,23 +117,19 @@ const pagination = ref({ rowsPerPage: rowsPerPage.value, }); -/** - * function เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน - */ +/**ฟังก์ชัน เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน */ function clickAdd() { dialog.value = true; editCheck.value = false; } -/** - * fetch รายการรอบการขึ้นเงินเดือน - */ +/** ฟังก์ชันดึงข้อมูลรายการรอบการขึ้นเงินเดือน */ async function getData() { showLoader(); await http .get( config.API.salaryPeriod() + - `?page=${page.value}&pageSise=${rowsPerPage.value}&keyword=${filterKeyword.value}&year=${year.value}` + `?page=${page.value}&pageSize=${rowsPerPage.value}&keyword=${filterKeyword.value}&year=${year.value}` ) .then(async (res) => { const data = await res.data.result; @@ -149,31 +145,34 @@ async function getData() { }); } -/** - * function เลือกปีงบประมาณ - */ +/** ฟังก์ชันเลือกปีงบประมาณ */ function updateYear() { page.value = 1; getData(); } -/** - * set ปี ทั้งหมด - */ + +/** ฟังก์ชันกำหนด ปี ทั้งหมด */ function yearAll() { year.value = 0; getData(); } /** - * function ลบรายการรอบการขึ้นเงินเดือน + * ฟังก์ชันลบรายการรอบการขึ้นเงินเดือน * @param id รอบการขึ้นเงินเดือน */ function deleteData(id: string) { - dialogRemove($q, () => { + dialogRemove($q, async () => { showLoader(); - http + await http .delete(config.API.salaryPeriod() + `/${id}`) .then(async () => { + page.value = await updateCurrentPage( + page.value, + maxPage.value, + dataStore.rows.length + ); + await getData(); await success($q, "ลบข้อมูลสำเร็จ"); }) @@ -187,9 +186,9 @@ function deleteData(id: string) { } /** - * function เปิด Dialog ข้อมูลรอบการขึ้นเงินเดือน + * ฟังก์ชันเปิด Dialog ข้อมูลรอบการขึ้นเงินเดือน * @param data ข้อมูลรอบการขึ้นเงินเดือน - * @param status สะถานะการแก่้ไข + * @param status สถานะการแก้ไข */ function editPopup(data: RowList, status: string) { if (status == "read") { @@ -205,7 +204,7 @@ function editPopup(data: RowList, status: string) { } /** - * function ปิดรอการขึ้นเงินเดือน + * ฟังก์ชันปิดรอการขึ้นเงินเดือน * @param id รอบการขึ้นเงินเดือน */ function dialogClose(id: string) { @@ -232,7 +231,7 @@ function dialogClose(id: string) { } /** - * function อัปเดท แถวต่อหน้า + * ฟังก์ชันอัปเดท แถวต่อหน้า * @param newPagination */ function updatePageSize(newPagination: NewPagination) { @@ -240,9 +239,7 @@ function updatePageSize(newPagination: NewPagination) { rowsPerPage.value = newPagination.rowsPerPage; } -/** - * callbackFunction ทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน - */ +/** ฟังก์ชันทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน */ watch( () => rowsPerPage.value, () => { @@ -250,12 +247,12 @@ watch( } ); -/** Hooklifecycle*/ +/** Hooklifecycle */ onMounted(async () => { year.value = new Date().getFullYear(); - getData(); dataStore.visibleColumns = visibleColumns.value; dataStore.columns = columns.value; + getData(); }); @@ -358,7 +355,7 @@ onMounted(async () => {