fix CurrentPage ==> อัตราเงินเดือน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-08 10:07:38 +07:00
parent 1faa8e798a
commit 014bcdf180

View file

@ -1,15 +1,15 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, reactive, watch } from "vue"; import { ref, onMounted, reactive, watch } from "vue";
import { checkPermission } from "@/utils/permissions";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import { checkPermission } from "@/utils/permissions";
import { updateCurrentPage } from "@/utils/function";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import genReportXLSX from "@/plugins/genreportxlsx"; import genReportXLSX from "@/plugins/genreportxlsx";
/** /** importType */
* importType
*/
import type { QTableProps } from "quasar"; import type { QTableProps } from "quasar";
import type { import type {
NewPagination, NewPagination,
@ -18,17 +18,13 @@ import type {
import type { SalaryRate } from "@/modules/13_salary/interface/response/Main"; import type { SalaryRate } from "@/modules/13_salary/interface/response/Main";
import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main"; import type { FormQuerySalary } from "@/modules/13_salary/interface/request/Main";
/** /** importComponents */
* importComponents
*/
import DialogFormRate from "@/modules/13_salary/components/01_Salary/DialogFormRate.vue"; import DialogFormRate from "@/modules/13_salary/components/01_Salary/DialogFormRate.vue";
/** /** importStore */
* importStore
*/
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
/** use*/ /** use composables */
const $q = useQuasar(); const $q = useQuasar();
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
@ -38,12 +34,12 @@ const { dialogRemove, success, messageError, showLoader, hideLoader } =
const isActive = ref<boolean>(false); const isActive = ref<boolean>(false);
const posType = ref<string>(""); const posType = ref<string>("");
const salaryId = ref<string>(route.params.id.toString()); const salaryId = ref<string>(route.params.id.toString()); // id
/** modalDialog*/ /** modalDialog */
const modalDialogFormRate = ref<boolean>(false); const modalDialogFormRate = ref<boolean>(false);
/** Table*/ /** Table */
const rows = ref<SalaryRate[]>([]); const rows = ref<SalaryRate[]>([]);
const columns = ref<QTableProps["columns"]>([ const columns = ref<QTableProps["columns"]>([
{ {
@ -102,7 +98,7 @@ const columns = ref<QTableProps["columns"]>([
}, },
]); ]);
/** List Mune*/ /** List Menu */
const itemMenu = ref<ItemsMenu[]>([ const itemMenu = ref<ItemsMenu[]>([
{ {
label: "แก้ไข", label: "แก้ไข",
@ -119,7 +115,7 @@ const itemMenu = ref<ItemsMenu[]>([
}, },
]); ]);
/** queryString*/ /** queryString */
const formQuery = reactive<FormQuerySalary>({ const formQuery = reactive<FormQuerySalary>({
page: 1, //* page: 1, //*
pageSize: 100, //* pageSize: 100, //*
@ -135,9 +131,7 @@ const pagination = ref({
const typeAction = ref<string>(""); // const typeAction = ref<string>(""); //
const dataSalaryRate = ref<SalaryRate>(); // const dataSalaryRate = ref<SalaryRate>(); //
/** /** ฟังก์ชันดึงข้อมูลรายการอัตราเงินเดือน*/
* fetch รายการอตราเงนเดอน
*/
async function fetchListSalaryRate() { async function fetchListSalaryRate() {
const page = formQuery.page.toString(); const page = formQuery.page.toString();
const pageSize = formQuery.pageSize.toString(); const pageSize = formQuery.pageSize.toString();
@ -159,8 +153,8 @@ async function fetchListSalaryRate() {
} }
/** /**
* function openDialog เพ,แกไข ตราเงนเดอน * งก openDialog เพ,แกไข ตราเงนเดอน
* @param type ประเภท แกไข,เพ * @param type ประเภท แกไข,เพ
* @param data อมลอตราเงนเดอน * @param data อมลอตราเงนเดอน
*/ */
function onClickSalaryRate(type: string, data: SalaryRate | null) { function onClickSalaryRate(type: string, data: SalaryRate | null) {
@ -178,15 +172,15 @@ function onClickSalaryRate(type: string, data: SalaryRate | null) {
function onClickDelete(id: string) { function onClickDelete(id: string) {
dialogRemove($q, async () => { dialogRemove($q, async () => {
showLoader(); showLoader();
formQuery.page =
formQuery.page !== 1 &&
formQuery.page === maxPage.value &&
rows.value.length === 1
? formQuery.page - 1
: formQuery.page;
await http await http
.delete(config.API.salaryRateListByid(id)) .delete(config.API.salaryRateListByid(id))
.then(async () => { .then(async () => {
formQuery.page = await updateCurrentPage(
formQuery.page,
maxPage.value,
rows.value.length
);
await fetchListSalaryRateNew(); await fetchListSalaryRateNew();
await success($q, "ลบข้อมูลสำเร็จ"); await success($q, "ลบข้อมูลสำเร็จ");
}) })
@ -199,9 +193,7 @@ function onClickDelete(id: string) {
}); });
} }
/** /** ฟังก์ชันดาวน์โหลดรายงานอัตราเงินเดือน */
* ดาวนโหลดไฟล
*/
function clickDownload() { function clickDownload() {
showLoader(); showLoader();
http http
@ -218,9 +210,7 @@ function clickDownload() {
}); });
} }
/** /** ฟังก์ชันดึงข้อมูลอัตราเงินเดือน */
* fetch อมลอตราเงนเดอน
*/
function fetchDataSalary() { function fetchDataSalary() {
http http
.get(config.API.salaryChartByid(salaryId.value)) .get(config.API.salaryChartByid(salaryId.value))
@ -235,7 +225,7 @@ function fetchDataSalary() {
} }
/** /**
* function updatePagination * งก updatePagination
* @param newPagination อม Pagination ใหม * @param newPagination อม Pagination ใหม
*/ */
function updatePagination(newPagination: NewPagination) { function updatePagination(newPagination: NewPagination) {
@ -243,6 +233,7 @@ function updatePagination(newPagination: NewPagination) {
formQuery.pageSize = newPagination.rowsPerPage; formQuery.pageSize = newPagination.rowsPerPage;
} }
/** ฟังก์ชันดึงข้อมูลรายการอัตราเงินเดือนใหม่ */
async function fetchListSalaryRateNew() { async function fetchListSalaryRateNew() {
try { try {
showLoader(); showLoader();
@ -254,9 +245,7 @@ async function fetchListSalaryRateNew() {
} }
} }
/** /** ฟังก์ชันติดตามการเปลี่ยนแปลงขนาดหน้า */
* ทำงานเมอมการ เปลยนหนาหร แถว
*/
watch( watch(
() => formQuery.pageSize, () => formQuery.pageSize,
async () => { async () => {
@ -264,6 +253,7 @@ watch(
} }
); );
/** Hook ที่ทำงานเมื่อ component ถูก mount */
onMounted(async () => { onMounted(async () => {
try { try {
showLoader(); showLoader();