Merge branch 'develop' into devTee

This commit is contained in:
setthawutttty 2025-02-17 10:16:43 +07:00
commit 54682072d6
2 changed files with 127 additions and 16 deletions

View file

@ -110,6 +110,30 @@ async function fecthlistRound() {
});
}
const roundId2 = ref<string>("");
const roundOtionMain2 = ref<any[]>([]);
const roundOtion2 = ref<any[]>([]);
/** ฟังก์ชันคึงข้อมูลรอบการเสนอขอ note*/
async function fecthlistRound2() {
showLoader();
await http
.get(config.API.noteround(), { params: { path: "RECORD" } })
.then((res: any) => {
roundOtionMain2.value = res.data.result.map((e: any) => ({
id: e.id,
year: e.year,
name: e.name,
}));
roundOtion2.value = roundOtionMain2.value;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* function นหาขอมลใน option
* @param val คำคนหา
@ -163,7 +187,13 @@ async function onUpdateFilter() {
name: "รายงานแสดงรายชื่อลูกจ้างประจำที่ได้รับ/ไม่ได้รับ การจ่ายใบกำกับฯ เครื่องราชอิสริยาภรณที่ได้รับพระราชทาน (ลูกจ้าง)",
};
}
if (typeReport.value && roundId.value && nodeId.value) {
if (
(typeReport.value.val === "report1" ||
typeReport.value.val === "report2" ||
typeReport.value.val === "report3") &&
(roundId.value || roundId2.value) &&
nodeId.value
) {
isLoadPDF.value = true;
pdfSrc.value = undefined;
@ -180,13 +210,34 @@ async function onUpdateFilter() {
.then(async (res) => {
const data = await res.data.result;
detailReport.value = data;
const type =
typeReport.value.val === "report4" ||
typeReport.value.val === "report5" ||
typeReport.value.val === "report6"
? "xlsx"
: "docx";
await fetchDocumentTemplate(data, type);
await fetchDocumentTemplate(data, "docx");
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
isLoadPDF.value = false;
});
} else if (roundId2.value && nodeId.value) {
isLoadPDF.value = true;
pdfSrc.value = undefined;
await http
.post(
config.API.reportInsigniaNew +
`/${typeReport.value.val}/${employeeClass.value}`,
{
roundId: roundId2.value,
node: nodeLevel.value,
nodeId: nodeId.value,
}
)
.then(async (res) => {
const data = await res.data.result;
detailReport.value = data;
await fetchDocumentTemplate(data, "xlsx");
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
@ -239,19 +290,21 @@ function backPage() {
}
}
function downloadReport(type: string) {
function downloadReport(type: string, download: "docx" | "" | "xlsx" = "") {
const fileName =
optionReport.value.find((e) => e.id === typeReport.value.id)?.name || "";
if (type === "xlsx") {
if (type === "xlsx" && download === "") {
genReportXLSX(detailReport.value, fileName, type);
} else if (type === "pdf" && download === "xlsx") {
genReportXLSX(detailReport.value, fileName, "pdf");
} else {
genReport(detailReport.value, fileName, type);
}
}
onMounted(async () => {
await Promise.all([fetchDataTree(), fecthlistRound()]);
await Promise.all([fetchDataTree(), fecthlistRound(), fecthlistRound2()]);
});
</script>
@ -284,20 +337,42 @@ onMounted(async () => {
flat
round
:loading="isLoadPDF"
:disable="!nodeId || !employeeClass || !roundId"
:disable="!nodeId || !employeeClass || (!roundId && !roundId2)"
color="primary"
icon="download"
v-if="checkPermission($route)?.attrIsGet"
>
<q-menu>
<q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="downloadReport('pdf')">
<q-item
clickable
v-close-popup
@click="
downloadReport(
'pdf',
typeReport.val != 'report1' ||
typeReport.val != 'report2' ||
typeReport.val != 'report3'
? 'xlsx'
: 'docx'
)
"
>
<q-item-section avatar
><q-icon color="red" name="mdi-file-pdf"
/></q-item-section>
<q-item-section>ไฟล .pdf</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadReport('docx')">
<q-item
v-if="
typeReport.val == 'report1' ||
typeReport.val == 'report2' ||
typeReport.val == 'report3'
"
clickable
v-close-popup
@click="downloadReport('docx')"
>
<q-item-section avatar
><q-icon color="blue" name="mdi-file-word"
/></q-item-section>
@ -342,6 +417,12 @@ onMounted(async () => {
<div class="col-md-4 col-xs-12">
<q-select
v-if="
typeReport &&
(typeReport.val == 'report1' ||
typeReport.val == 'report2' ||
typeReport.val == 'report3')
"
class="bg-white"
use-input
fill-input
@ -368,6 +449,35 @@ onMounted(async () => {
</q-item>
</template>
</q-select>
<q-select
v-else
class="bg-white"
use-input
fill-input
hide-selected
dense
lazy-rules
outlined
v-model="roundId2"
:options="roundOtion2"
label="เลือกรอบ"
option-value="id"
option-label="name"
emit-value
map-options
@update:model-value="onUpdateFilter"
@filter="(inputValue:string,doneFn:Function) =>
filterSelector(inputValue, doneFn,'round') "
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
</div>
</q-card>

View file

@ -152,10 +152,11 @@ function fetchReportPDF() {
async function fetchDataReportUnified(
reportCode: string,
employeeClass: string,
employeeClass: string
) {
isLoadFilePdf.value = true;
pdfSrc.value = undefined
pdfSrc.value = undefined;
page.value = 1;
const isHalfYearReport = (id: string) =>
["go1", "go2", "go2-01", "emp-08", "emp2-08"].includes(id);