fix CurrentPage ===> ผังบัญชีค่าจ้างลูกจ้างประจำ(หลักเกณฑ์)

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-07-08 09:52:27 +07:00
parent fb7b4060c9
commit 1513eecd15

View file

@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { checkPermission } from "@/utils/permissions";
import { updateCurrentPage } from "@/utils/function";
import http from "@/plugins/http";
import config from "@/app.config";
import { useQuasar } from "quasar";
@ -150,11 +151,14 @@ const posTypeOpMain = ref<DataOption[]>([]); //ข้อมูลกลุ่ม
const posTypeOp = ref<DataOption[]>([]); //
const posType = ref<string | null>(""); //
/**
* งขอมลกลมงาน
*/
function getPosType() {
http
const pagination = ref({
page: formFilter.page,
rowsPerPage: formFilter.pageSize,
});
/** ดึงข้อมูลกลุ่มงาน*/
async function getPosType() {
await http
.get(config.API.salaryEmployeePosType())
.then((res) => {
const data = res.data.result;
@ -164,12 +168,12 @@ function getPosType() {
name: "ทั้งหมด",
},
];
const test = data.map((item: PosType) => ({
const datatypes = data.map((item: PosType) => ({
id: item.id,
name: item.posTypeName,
}));
option.push(...test);
option.push(...datatypes);
posTypeOp.value = option;
posTypeOpMain.value = option;
})
@ -178,15 +182,14 @@ function getPosType() {
});
}
/**
* งขอมลรายการหลกเกณฑ
*/
function getData() {
showLoader();
http
/** ดึงข้อมูลรายการหลักเกณฑ์ */
async function getData() {
await http
.get(
config.API.salaryFormula() +
`/?page=${formFilter.page}&pageSize=${formFilter.pageSize}&keyword=${formFilter.keyword.trim()}&posTypeId=${posType.value}`
`/?page=${formFilter.page}&pageSize=${
formFilter.pageSize
}&keyword=${formFilter.keyword.trim()}&posTypeId=${posType.value}`
)
.then((res) => {
const data = res.data.result.data;
@ -207,9 +210,6 @@ function getData() {
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
@ -228,14 +228,19 @@ function editPopup(params: ListData, type: string) {
* function fetch อมลรายการตามหน
* @param val หน
*/
function updatePage(val: number) {
formFilter.page = val;
getData();
async function updatePage(val: number) {
try {
showLoader();
formFilter.page = val;
await getData();
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
/**
* function ปเดทแถวตอหน
*/
/** function อัปเดทแถวต่อหน้า*/
function updatePageSize(newPagination: NewPagination) {
formFilter.page = 1;
formFilter.pageSize = newPagination.rowsPerPage;
@ -246,11 +251,16 @@ function updatePageSize(newPagination: NewPagination) {
* @param id หลกเกณฑ
*/
function onClickDelete(id: string) {
dialogRemove($q, () => {
dialogRemove($q, async () => {
showLoader();
http
await http
.delete(config.API.salaryFormula() + `/${id}`)
.then(async () => {
formFilter.page = await updateCurrentPage(
formFilter.page,
maxPage.value,
rows.value.length
);
await getData();
await success($q, "ลบข้อมูลสำเร็จ");
})
@ -276,31 +286,37 @@ function filterSelector(val: string, update: Function) {
});
}
/**
* callbackFuntioon ทำงานเมอมการอปเดทแถว
*/
watch(
() => formFilter.pageSize,
() => {
getData();
}
);
/**
* functionn fetch อมลรายการหนาแรก
*/
/** function fetch ข้อมูลรายการหน้าแรก */
function filterFn() {
formFilter.page = 1;
getData();
}
const pagination = ref({
page: formFilter.page,
rowsPerPage: formFilter.pageSize,
});
/** callbackFunction ทำงานเมื่อมี่การอัปเดทแถว*/
watch(
() => formFilter.pageSize,
async () => {
try {
showLoader();
await getData();
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
}
);
/** Hook */
onMounted(async () => {
await Promise.all([getData(), getPosType()]);
try {
showLoader();
await Promise.all([getData(), getPosType()]);
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
});
</script>