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 () => {