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