fix CurrentPage ===> ผังบัญชีค่าจ้างลูกจ้างประจำ(หลักเกณฑ์)
This commit is contained in:
parent
fb7b4060c9
commit
1513eecd15
1 changed files with 59 additions and 43 deletions
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue