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