fix bug pagintion ==> ระบบเปลี่ยนแปลงรอบการปฏิบัติงานของผู้ใช้งาน
This commit is contained in:
parent
0c91be9173
commit
b28f759ac7
3 changed files with 43 additions and 29 deletions
|
|
@ -68,8 +68,8 @@ const pageSize = ref<number>(10);
|
||||||
const initialPagination = ref<any>({
|
const initialPagination = ref<any>({
|
||||||
sortBy: null,
|
sortBy: null,
|
||||||
descending: false,
|
descending: false,
|
||||||
page: 1,
|
page: dataStore.page,
|
||||||
rowsPerPage: pageSize, // set ตาม page หลักส่งมา
|
rowsPerPage: dataStore.pageSize, // set ตาม page หลักส่งมา
|
||||||
});
|
});
|
||||||
|
|
||||||
// Pagination - page & change page & get new data
|
// Pagination - page & change page & get new data
|
||||||
|
|
@ -77,7 +77,7 @@ const currentPage = ref<number>(1);
|
||||||
const roundOp = ref<any>([]);
|
const roundOp = ref<any>([]);
|
||||||
async function updatePagination(newPagination: any) {
|
async function updatePagination(newPagination: any) {
|
||||||
initialPagination.value = newPagination;
|
initialPagination.value = newPagination;
|
||||||
currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
// currentPage.value = 1; // set current page เป็น 1 เสมอเมื่อเปลี่ยน per row
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Function validateForm */
|
/** Function validateForm */
|
||||||
|
|
@ -103,7 +103,7 @@ function onSubmit() {
|
||||||
$q,
|
$q,
|
||||||
() => {
|
() => {
|
||||||
changeRound();
|
changeRound();
|
||||||
props.closeDialog?.();
|
// props.closeDialog?.();
|
||||||
},
|
},
|
||||||
"ยืนยันการบันทึกข้อมูล",
|
"ยืนยันการบันทึกข้อมูล",
|
||||||
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
"ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?"
|
||||||
|
|
@ -112,6 +112,7 @@ function onSubmit() {
|
||||||
|
|
||||||
/** Function เปลี่ยนรอบเวลา*/
|
/** Function เปลี่ยนรอบเวลา*/
|
||||||
async function changeRound() {
|
async function changeRound() {
|
||||||
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.post(config.API.leaveRound(), {
|
.post(config.API.leaveRound(), {
|
||||||
profileId: props.personId,
|
profileId: props.personId,
|
||||||
|
|
@ -121,12 +122,13 @@ async function changeRound() {
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา");
|
success($q, "บันทึกข้อมูลเปลี่ยนรอบเวลา");
|
||||||
|
props.closeDialog?.();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
props.closeDialog?.();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +137,7 @@ async function changeRound() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
async function fetchDataOption() {
|
async function fetchDataOption() {
|
||||||
showLoader();
|
props.editCheck !== "history" && showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.leaveRound())
|
.get(config.API.leaveRound())
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
@ -156,7 +158,7 @@ async function fetchDataOption() {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
hideLoader();
|
props.editCheck !== "history" && hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -168,8 +170,9 @@ function close() {
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => currentPage.value, () => initialPagination.value.rowsPerPage],
|
() => initialPagination.value.rowsPerPage,
|
||||||
() => {
|
() => {
|
||||||
|
currentPage.value = 1;
|
||||||
emit(
|
emit(
|
||||||
"update:change-page",
|
"update:change-page",
|
||||||
currentPage.value,
|
currentPage.value,
|
||||||
|
|
@ -179,6 +182,15 @@ watch(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function nextPage() {
|
||||||
|
emit(
|
||||||
|
"update:change-page",
|
||||||
|
currentPage.value,
|
||||||
|
initialPagination.value.rowsPerPage,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.modal,
|
() => props.modal,
|
||||||
async () => {
|
async () => {
|
||||||
|
|
@ -188,6 +200,7 @@ watch(
|
||||||
formData.effectiveDate = null;
|
formData.effectiveDate = null;
|
||||||
}
|
}
|
||||||
if (props.modal === true) {
|
if (props.modal === true) {
|
||||||
|
currentPage.value = 1;
|
||||||
await fetchDataOption();
|
await fetchDataOption();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -355,7 +368,7 @@ watch(
|
||||||
dense
|
dense
|
||||||
class="custom-header-table"
|
class="custom-header-table"
|
||||||
:visible-columns="dataStore.visibleColumnsHistory"
|
:visible-columns="dataStore.visibleColumnsHistory"
|
||||||
:rows-per-page-options="[5, 10, 25, 50, 100]"
|
:rows-per-page-options="[1, 10, 25, 50, 100]"
|
||||||
:pagination="initialPagination"
|
:pagination="initialPagination"
|
||||||
@update:pagination="updatePagination"
|
@update:pagination="updatePagination"
|
||||||
>
|
>
|
||||||
|
|
@ -370,6 +383,7 @@ watch(
|
||||||
boundary-links
|
boundary-links
|
||||||
direction-links
|
direction-links
|
||||||
:max="Number(dataStore.maxPage)"
|
:max="Number(dataStore.maxPage)"
|
||||||
|
@update:model-value="nextPage"
|
||||||
></q-pagination>
|
></q-pagination>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:header="props">
|
<template v-slot:header="props">
|
||||||
|
|
|
||||||
|
|
@ -122,17 +122,16 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
const maxPageMain = ref<number>(0);
|
const maxPageMain = ref<number>(0);
|
||||||
const totalListMain = ref<number>(0);
|
const totalListMain = ref<number>(0);
|
||||||
|
|
||||||
function fetchDataForCardId(dataDetail: any) {
|
async function fetchDataForCardId(dataDetail: any) {
|
||||||
if (dataDetail) {
|
if (dataDetail) {
|
||||||
rows.value = [];
|
|
||||||
showLoader();
|
showLoader();
|
||||||
http
|
await http
|
||||||
.post(config.API.leaveSearch(), {
|
.post(config.API.leaveSearch(), {
|
||||||
citizenId: dataDetail.cardId || "", //เลขประจำตัวประชาชน
|
citizenId: dataDetail.cardId || "", //เลขประจำตัวประชาชน
|
||||||
firstname: dataDetail.firstName || "", //ชื่อจริง
|
firstname: dataDetail.firstName || "", //ชื่อจริง
|
||||||
lastname: dataDetail.lastName || "", //นามสกุล
|
lastname: dataDetail.lastName || "", //นามสกุล
|
||||||
page: dataDetail.page || 1, //*หน้า
|
page: dataDetail.page, //หน้า
|
||||||
pageSize: dataDetail.pageSize || 10, //*จำนวนแถวต่อหน้า
|
pageSize: dataDetail.pageSize || 10, //จำนวนแถวต่อหน้า
|
||||||
keyword: dataDetail.keyword || "", //keyword ค้นหา
|
keyword: dataDetail.keyword || "", //keyword ค้นหา
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
|
@ -160,7 +159,7 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
messageError($q, e);
|
messageError($q, e);
|
||||||
})
|
})
|
||||||
.finally(async () => {
|
.finally(() => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -179,13 +178,13 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
* @param pageSizeVal pagesize
|
* @param pageSizeVal pagesize
|
||||||
*/
|
*/
|
||||||
async function changePage(pageVal: number, pageSizeVal: number) {
|
async function changePage(pageVal: number, pageSizeVal: number) {
|
||||||
page.value = await pageVal;
|
page.value = pageVal;
|
||||||
pageSize.value = await pageSizeVal;
|
pageSize.value = pageSizeVal;
|
||||||
fetchDatainHistory();
|
fetchDatainHistory();
|
||||||
}
|
}
|
||||||
/**ฟังก์ชั่นดึงดาต้าประวัติ */
|
/**ฟังก์ชั่นดึงดาต้าประวัติ */
|
||||||
async function fetchDatainHistory() {
|
async function fetchDatainHistory() {
|
||||||
console.log(profileId.value);
|
rowsHistory.value = [];
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(
|
.get(
|
||||||
|
|
@ -194,7 +193,6 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const dataHistory = res.data.result.data;
|
const dataHistory = res.data.result.data;
|
||||||
rowsHistory.value = [];
|
|
||||||
dataHistory.map((e: DataInterface) => {
|
dataHistory.map((e: DataInterface) => {
|
||||||
rowsHistory.value.push({
|
rowsHistory.value.push({
|
||||||
round: e.round,
|
round: e.round,
|
||||||
|
|
@ -206,9 +204,7 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
});
|
});
|
||||||
total.value = res.data.result.total;
|
total.value = res.data.result.total;
|
||||||
maxPage.value = Math.ceil(total.value / pageSize.value);
|
maxPage.value = Math.ceil(total.value / pageSize.value);
|
||||||
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
|
|
||||||
});
|
});
|
||||||
console.log(rowsHistory.value);
|
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -232,6 +228,8 @@ export const useChangeRoundDataStore = defineStore(
|
||||||
changePage,
|
changePage,
|
||||||
total,
|
total,
|
||||||
maxPage,
|
maxPage,
|
||||||
|
page,
|
||||||
|
pageSize,
|
||||||
|
|
||||||
totalListMain,
|
totalListMain,
|
||||||
maxPageMain,
|
maxPageMain,
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,15 @@ const formData = reactive<DataPost>({
|
||||||
* @param check action edit,history
|
* @param check action edit,history
|
||||||
* @param detail รายละเอียดข้อมูลรอบการปฏิบัติของผู้ใช้งาน
|
* @param detail รายละเอียดข้อมูลรอบการปฏิบัติของผู้ใช้งาน
|
||||||
*/
|
*/
|
||||||
function Openmodal(check: string, detail: any) {
|
async function Openmodal(check: string, detail: any) {
|
||||||
DataRow.value = detail;
|
DataRow.value = detail;
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
dataStore.setProfileId(DataRow.value.profileId);
|
dataStore.setProfileId(DataRow.value.profileId);
|
||||||
editCheck.value = check;
|
editCheck.value = check;
|
||||||
if (check === "history") {
|
if (check === "history") {
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
dataStore.fetchDatainHistory();
|
dataStore.changePage(1, dataStore.pageSize);
|
||||||
|
// dataStore.fetchDatainHistory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -71,15 +72,15 @@ async function fetchDataCalendarWork(id: string) {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
modalFix.value = true;
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const detailByid = ref();
|
const detailByid = ref();
|
||||||
async function OpenmodalFix(detail: any) {
|
async function OpenmodalFix(detail: any) {
|
||||||
await fetchDataCalendarWork(detail.profileId);
|
|
||||||
detailByid.value = detail;
|
detailByid.value = detail;
|
||||||
|
modalFix.value = true;
|
||||||
|
await fetchDataCalendarWork(detail.profileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Function closePopup */
|
/** Function closePopup */
|
||||||
|
|
@ -95,7 +96,8 @@ function save() {
|
||||||
.put(config.API.leaveWorkByid(detailByid.value.profileId), {
|
.put(config.API.leaveWorkByid(detailByid.value.profileId), {
|
||||||
work: dateWork.value,
|
work: dateWork.value,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
// await searchData();
|
||||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
closeDialog();
|
closeDialog();
|
||||||
})
|
})
|
||||||
|
|
@ -113,14 +115,13 @@ function save() {
|
||||||
* @param newPagination ข้อมูล Pagination ใหม่
|
* @param newPagination ข้อมูล Pagination ใหม่
|
||||||
*/
|
*/
|
||||||
function updatePagination(newPagination: any) {
|
function updatePagination(newPagination: any) {
|
||||||
formData.page = 1;
|
|
||||||
formData.pageSize = newPagination.rowsPerPage;
|
formData.pageSize = newPagination.rowsPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Function ค้นหาข้อมูล */
|
/** Function ค้นหาข้อมูล */
|
||||||
function searchData() {
|
async function searchData() {
|
||||||
if (formData.cardId || formData.firstName || formData.lastName) {
|
if (formData.cardId || formData.firstName || formData.lastName) {
|
||||||
dataStore.fetchDataForCardId(formData);
|
await dataStore.fetchDataForCardId(formData);
|
||||||
} else {
|
} else {
|
||||||
dialogMessageNotify($q, "กรุณากรอกข้อมูลอย่างน้อย 1 ช่อง");
|
dialogMessageNotify($q, "กรุณากรอกข้อมูลอย่างน้อย 1 ช่อง");
|
||||||
}
|
}
|
||||||
|
|
@ -129,6 +130,7 @@ function searchData() {
|
||||||
watch(
|
watch(
|
||||||
() => formData.pageSize,
|
() => formData.pageSize,
|
||||||
() => {
|
() => {
|
||||||
|
formData.page = 1;
|
||||||
searchData();
|
searchData();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue