ปรับแก้ไข เปลี่ยนแปลงรอบ

This commit is contained in:
AnandaTon 2023-11-28 14:03:31 +07:00
parent 9100062af6
commit ea614b07c2
3 changed files with 106 additions and 39 deletions

View file

@ -150,7 +150,7 @@ export const useChangeRoundDataStore = defineStore(
roundStart: e.startTimeMorning,
roundEnd: e.leaveTimeAfterNoon,
currentRound: `${e.startTimeMorning}-${e.leaveTimeAfterNoon}`,
effectiveDate: date2Thai(e.effectiveDate),
effectiveDate: date2Thai(e.effectiveDate) ?? "-",
}));
console.log(profileId.value);
console.log(apiData.length);
@ -171,7 +171,9 @@ export const useChangeRoundDataStore = defineStore(
const rowsHistory = ref<historyShow[]>([]);
// paging
const page = ref<number>(1);
const total = ref<number>(0);
const pageSize = ref<number>(10);
const maxPage = ref<number>(0);
const filter = ref<string>(""); //search data table
/**
* api
@ -183,19 +185,19 @@ export const useChangeRoundDataStore = defineStore(
pageSize.value = await pageSizeVal;
fetchDatainHistory();
}
/**ฟังก์ชั่นดึงดาต้าประวัติ */
async function fetchDatainHistory() {
console.log(profileId.value);
showLoader();
await http
.post(
config.API.leaveRoundById(profileId.value),
{
page: page.value,
pageSize: pageSize.value,
keyword: filter.value,
}
// `?page=${page.value}&pageSize=${pageSize.value}&keyword=${filter.value}`
.get(
config.API.leaveRoundById(profileId.value) +
// {
// page: page.value,
// pageSize: pageSize.value,
// keyword: filter.value,
// }
`?page=${page.value}&pageSize=${pageSize.value}&keyword=${filter.value}`
)
.then((res) => {
const dataHistory = res.data.result.data;
@ -209,7 +211,9 @@ export const useChangeRoundDataStore = defineStore(
effectiveDate: date2Thai(e.effectiveDate),
reson: e.remark ?? "-",
});
console.log(rowsHistory.value);
total.value = res.data.result.total;
maxPage.value = Math.ceil(total.value / pageSize.value);
maxPage.value = maxPage.value < 1 ? 1 : maxPage.value;
});
})
.catch((err) => {
@ -232,6 +236,8 @@ export const useChangeRoundDataStore = defineStore(
checkCilck,
setProfileId,
changePage,
total,
maxPage,
};
}
);