fix CurrentPage ===> รอบการขึ้นเงินเดือน
This commit is contained in:
parent
014bcdf180
commit
c6abf8314d
1 changed files with 25 additions and 28 deletions
|
|
@ -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<number | null>(0); //ปีงบประมาณ
|
|||
/** Table*/
|
||||
const year = ref<number>(0); //ปีงบประมาณ
|
||||
const filterKeyword = ref<string>(""); //คำค้นหา
|
||||
const currentPage = ref<number>(1); //หน้า
|
||||
const maxPage = ref<number>(1); //จำนวนหน้า
|
||||
const totalList = ref<number>(0); //จำนวนรายการ
|
||||
const page = ref<number>(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();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -358,7 +355,7 @@ onMounted(async () => {
|
|||
<template v-slot:pagination="scope">
|
||||
ทั้งหมด {{ totalList?.toLocaleString() }} รายการ
|
||||
<q-pagination
|
||||
v-model="currentPage"
|
||||
v-model="page"
|
||||
active-color="primary"
|
||||
color="dark"
|
||||
:max="Number(maxPage)"
|
||||
|
|
@ -481,7 +478,7 @@ onMounted(async () => {
|
|||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'">
|
||||
{{
|
||||
(currentPage - 1) * Number(pagination.rowsPerPage) +
|
||||
(page - 1) * Number(pagination.rowsPerPage) +
|
||||
props.rowIndex +
|
||||
1
|
||||
}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue