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 { useQuasar } from "quasar";
|
||||||
|
|
||||||
import { checkPermission } from "@/utils/permissions";
|
import { checkPermission } from "@/utils/permissions";
|
||||||
|
import { updateCurrentPage } from "@/utils/function";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useSalaryDataStore } from "@/modules/13_salary/store/SalaryStore";
|
import { useSalaryDataStore } from "@/modules/13_salary/store/SalaryStore";
|
||||||
import config from "@/app.config";
|
import config from "@/app.config";
|
||||||
|
|
@ -42,7 +43,6 @@ const yearData = ref<number | null>(0); //ปีงบประมาณ
|
||||||
/** Table*/
|
/** Table*/
|
||||||
const year = ref<number>(0); //ปีงบประมาณ
|
const year = ref<number>(0); //ปีงบประมาณ
|
||||||
const filterKeyword = ref<string>(""); //คำค้นหา
|
const filterKeyword = ref<string>(""); //คำค้นหา
|
||||||
const currentPage = ref<number>(1); //หน้า
|
|
||||||
const maxPage = ref<number>(1); //จำนวนหน้า
|
const maxPage = ref<number>(1); //จำนวนหน้า
|
||||||
const totalList = ref<number>(0); //จำนวนรายการ
|
const totalList = ref<number>(0); //จำนวนรายการ
|
||||||
const page = ref<number>(1); //หน้า
|
const page = ref<number>(1); //หน้า
|
||||||
|
|
@ -117,23 +117,19 @@ const pagination = ref({
|
||||||
rowsPerPage: rowsPerPage.value,
|
rowsPerPage: rowsPerPage.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**ฟังก์ชัน เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน */
|
||||||
* function เปิด Dialog เพิ่มรอบการขึ้นเงินเดือน
|
|
||||||
*/
|
|
||||||
function clickAdd() {
|
function clickAdd() {
|
||||||
dialog.value = true;
|
dialog.value = true;
|
||||||
editCheck.value = false;
|
editCheck.value = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** ฟังก์ชันดึงข้อมูลรายการรอบการขึ้นเงินเดือน */
|
||||||
* fetch รายการรอบการขึ้นเงินเดือน
|
|
||||||
*/
|
|
||||||
async function getData() {
|
async function getData() {
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(
|
.get(
|
||||||
config.API.salaryPeriod() +
|
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) => {
|
.then(async (res) => {
|
||||||
const data = await res.data.result;
|
const data = await res.data.result;
|
||||||
|
|
@ -149,31 +145,34 @@ async function getData() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** ฟังก์ชันเลือกปีงบประมาณ */
|
||||||
* function เลือกปีงบประมาณ
|
|
||||||
*/
|
|
||||||
function updateYear() {
|
function updateYear() {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* set ปี ทั้งหมด
|
/** ฟังก์ชันกำหนด ปี ทั้งหมด */
|
||||||
*/
|
|
||||||
function yearAll() {
|
function yearAll() {
|
||||||
year.value = 0;
|
year.value = 0;
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function ลบรายการรอบการขึ้นเงินเดือน
|
* ฟังก์ชันลบรายการรอบการขึ้นเงินเดือน
|
||||||
* @param id รอบการขึ้นเงินเดือน
|
* @param id รอบการขึ้นเงินเดือน
|
||||||
*/
|
*/
|
||||||
function deleteData(id: string) {
|
function deleteData(id: string) {
|
||||||
dialogRemove($q, () => {
|
dialogRemove($q, async () => {
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
await http
|
||||||
.delete(config.API.salaryPeriod() + `/${id}`)
|
.delete(config.API.salaryPeriod() + `/${id}`)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
|
page.value = await updateCurrentPage(
|
||||||
|
page.value,
|
||||||
|
maxPage.value,
|
||||||
|
dataStore.rows.length
|
||||||
|
);
|
||||||
|
|
||||||
await getData();
|
await getData();
|
||||||
await success($q, "ลบข้อมูลสำเร็จ");
|
await success($q, "ลบข้อมูลสำเร็จ");
|
||||||
})
|
})
|
||||||
|
|
@ -187,9 +186,9 @@ function deleteData(id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function เปิด Dialog ข้อมูลรอบการขึ้นเงินเดือน
|
* ฟังก์ชันเปิด Dialog ข้อมูลรอบการขึ้นเงินเดือน
|
||||||
* @param data ข้อมูลรอบการขึ้นเงินเดือน
|
* @param data ข้อมูลรอบการขึ้นเงินเดือน
|
||||||
* @param status สะถานะการแก่้ไข
|
* @param status สถานะการแก้ไข
|
||||||
*/
|
*/
|
||||||
function editPopup(data: RowList, status: string) {
|
function editPopup(data: RowList, status: string) {
|
||||||
if (status == "read") {
|
if (status == "read") {
|
||||||
|
|
@ -205,7 +204,7 @@ function editPopup(data: RowList, status: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function ปิดรอการขึ้นเงินเดือน
|
* ฟังก์ชันปิดรอการขึ้นเงินเดือน
|
||||||
* @param id รอบการขึ้นเงินเดือน
|
* @param id รอบการขึ้นเงินเดือน
|
||||||
*/
|
*/
|
||||||
function dialogClose(id: string) {
|
function dialogClose(id: string) {
|
||||||
|
|
@ -232,7 +231,7 @@ function dialogClose(id: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function อัปเดท แถวต่อหน้า
|
* ฟังก์ชันอัปเดท แถวต่อหน้า
|
||||||
* @param newPagination
|
* @param newPagination
|
||||||
*/
|
*/
|
||||||
function updatePageSize(newPagination: NewPagination) {
|
function updatePageSize(newPagination: NewPagination) {
|
||||||
|
|
@ -240,9 +239,7 @@ function updatePageSize(newPagination: NewPagination) {
|
||||||
rowsPerPage.value = newPagination.rowsPerPage;
|
rowsPerPage.value = newPagination.rowsPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** ฟังก์ชันทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน */
|
||||||
* callbackFunction ทำเมื่อมีการอัปเดท แถวต่อหน้า แล้ว fetch รายการรอบการขึ้นเงินเดือน
|
|
||||||
*/
|
|
||||||
watch(
|
watch(
|
||||||
() => rowsPerPage.value,
|
() => rowsPerPage.value,
|
||||||
() => {
|
() => {
|
||||||
|
|
@ -250,12 +247,12 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/** Hooklifecycle*/
|
/** Hooklifecycle */
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
year.value = new Date().getFullYear();
|
year.value = new Date().getFullYear();
|
||||||
getData();
|
|
||||||
dataStore.visibleColumns = visibleColumns.value;
|
dataStore.visibleColumns = visibleColumns.value;
|
||||||
dataStore.columns = columns.value;
|
dataStore.columns = columns.value;
|
||||||
|
getData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -358,7 +355,7 @@ onMounted(async () => {
|
||||||
<template v-slot:pagination="scope">
|
<template v-slot:pagination="scope">
|
||||||
ทั้งหมด {{ totalList?.toLocaleString() }} รายการ
|
ทั้งหมด {{ totalList?.toLocaleString() }} รายการ
|
||||||
<q-pagination
|
<q-pagination
|
||||||
v-model="currentPage"
|
v-model="page"
|
||||||
active-color="primary"
|
active-color="primary"
|
||||||
color="dark"
|
color="dark"
|
||||||
:max="Number(maxPage)"
|
:max="Number(maxPage)"
|
||||||
|
|
@ -481,7 +478,7 @@ onMounted(async () => {
|
||||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||||
<div v-if="col.name == 'no'">
|
<div v-if="col.name == 'no'">
|
||||||
{{
|
{{
|
||||||
(currentPage - 1) * Number(pagination.rowsPerPage) +
|
(page - 1) * Number(pagination.rowsPerPage) +
|
||||||
props.rowIndex +
|
props.rowIndex +
|
||||||
1
|
1
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue