fix บัญชีแสดงวันลา
This commit is contained in:
parent
7c1f4502ec
commit
02bfb6387c
1 changed files with 29 additions and 59 deletions
|
|
@ -24,14 +24,8 @@ import LoadView from "@/components/LoadView.vue";
|
|||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
const { fetchStructureTree } = useStructureTree();
|
||||
const {
|
||||
showLoader,
|
||||
hideLoader,
|
||||
date2Thai,
|
||||
dateToISO,
|
||||
messageError,
|
||||
monthYear2Thai,
|
||||
} = useCounterMixin();
|
||||
const { date2Thai, dateToISO, messageError, monthYear2Thai } =
|
||||
useCounterMixin();
|
||||
|
||||
const year = ref<number>(new Date().getFullYear());
|
||||
const dateStart = ref<Date>(new Date(year.value - 1, 9, 1));
|
||||
|
|
@ -77,17 +71,26 @@ const nodeLevel = ref<number>(0);
|
|||
const node = ref<DataStructureTree[]>([]);
|
||||
const expanded = ref<string[]>([]);
|
||||
|
||||
/** ฟังก์ชันเรียกข้อมูลโครงสร้างหน่วยงาน*/
|
||||
async function fetchDataTree() {
|
||||
node.value = await fetchStructureTree(route.meta.Key as string, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันเลือกหน่วยงานที่ต้องการดูข้อมูล
|
||||
* @param id id หน่วยงาน
|
||||
* @param level node ของหน่วงงานที่เลือก
|
||||
*/
|
||||
function onSelectedNode(id: string, level: number) {
|
||||
nodeId.value = id;
|
||||
nodeLevel.value = level;
|
||||
updateLeaveday();
|
||||
}
|
||||
|
||||
/** function อัปเดทบัญชีแสดงวันลา */
|
||||
/**
|
||||
* ฟังก์ชันอัปเดทบัญชีแสดงวันลา
|
||||
* และเรียกข้อมูลรายงาน
|
||||
*/
|
||||
async function updateLeaveday() {
|
||||
switch (yearType.value) {
|
||||
case "FULL":
|
||||
|
|
@ -125,23 +128,17 @@ async function updateLeaveday() {
|
|||
isLoadPDF.value = true;
|
||||
pdfSrc.value = undefined;
|
||||
|
||||
typeReport.value === "1"
|
||||
? fetchLeaveday(
|
||||
employeeClass.value,
|
||||
yearType.value,
|
||||
dateStart.value,
|
||||
dateEnd.value
|
||||
)
|
||||
: fetchLeaveday2(
|
||||
employeeClass.value,
|
||||
yearType.value,
|
||||
dateStart.value,
|
||||
dateEnd.value
|
||||
);
|
||||
//เรียกฟังก์ชัน fetchLeaveday
|
||||
fetchLeaveday(
|
||||
employeeClass.value,
|
||||
yearType.value,
|
||||
dateStart.value,
|
||||
dateEnd.value
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลบัญชีแสดงวันลา
|
||||
* ฟังก์ชันเรียกข้อมูลรายงาน
|
||||
* @param type สถานภาพ
|
||||
* @param year ปั
|
||||
* @param startDate วันเริ่มต้น
|
||||
|
|
@ -161,38 +158,13 @@ async function fetchLeaveday(
|
|||
node: nodeLevel.value,
|
||||
};
|
||||
|
||||
await http
|
||||
.post(config.API.leaveReportLeaveday(type), body)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
data && (await fetchDocumentTemplate(data));
|
||||
isReport.value = data ? true : false;
|
||||
detailReport.value = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
isLoadPDF.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
async function fetchLeaveday2(
|
||||
type: string,
|
||||
year: string,
|
||||
startDate: Date,
|
||||
endDate: Date
|
||||
) {
|
||||
const body = {
|
||||
type: year === "FULL" ? "FULL" : year === "MONTH" ? "MONTH" : "HAFT",
|
||||
startDate: dateToISO(startDate),
|
||||
endDate: dateToISO(endDate),
|
||||
nodeId: nodeId.value,
|
||||
node: nodeLevel.value,
|
||||
};
|
||||
const pathAPI =
|
||||
typeReport.value === "1"
|
||||
? config.API.leaveReportLeaveday(type)
|
||||
: config.API.leaveReportLeave2(type);
|
||||
|
||||
await http
|
||||
.post(config.API.leaveReportLeave2(type), body)
|
||||
.post(pathAPI, body)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
data && (await fetchDocumentTemplate(data));
|
||||
|
|
@ -233,12 +205,10 @@ async function fetchDocumentTemplate(data: any) {
|
|||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 2000);
|
||||
});
|
||||
.finally(() => {});
|
||||
}
|
||||
|
||||
//ตัวแปร PDF
|
||||
const numOfPages = ref<number>(0);
|
||||
const page = ref<number>(1);
|
||||
const pdfSrc = ref<any>();
|
||||
|
|
@ -366,7 +336,7 @@ onMounted(() => {
|
|||
<div class="row col-12 q-col-gutter-sm">
|
||||
<div class="col-md-3 col-xs-12">
|
||||
<q-select
|
||||
class="bg-white"
|
||||
class="bg-white select_ellipsis3"
|
||||
hide-bottom-space
|
||||
outlined
|
||||
dense
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue