Merge branch 'develop' into devTee
This commit is contained in:
commit
5b7bf77d5e
2 changed files with 46 additions and 19 deletions
|
|
@ -3,6 +3,7 @@ interface DataOption {
|
|||
name: string;
|
||||
type?: string;
|
||||
typeName?: string;
|
||||
keyId?: string;
|
||||
}
|
||||
|
||||
interface DataOptionShort {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import config from "@/app.config";
|
|||
import http from "@/plugins/http";
|
||||
|
||||
import type { DataStructureTree } from "@/interface/main";
|
||||
import type { DataOption } from "@/modules/21_report/interface/Main";
|
||||
import type { DataOption } from "@/modules/13_salary/interface/index/Main";
|
||||
|
||||
import LoadView from "@/components/LoadView.vue";
|
||||
|
||||
|
|
@ -46,17 +46,35 @@ const groupOptions = ref<DataOption[]>([
|
|||
{ id: "GROUP2", name: "กลุ่ม 2" },
|
||||
]);
|
||||
|
||||
const report = ref<string>("");
|
||||
const report = ref<DataOption | null>(null);
|
||||
const reportOption = computed(() => {
|
||||
const storeData = employeeClass.value === "officer" ? store : storeEmp;
|
||||
|
||||
if (round.value.shortCode === "APR") {
|
||||
return storeData.itemDownloadApr.filter((e) => e.type !== "pdf");
|
||||
} else if (round.value.shortCode === "OCT") {
|
||||
return storeData.itemDownloadOct.filter((e) => e.type !== "pdf");
|
||||
// ตรวจสอบว่า round.value มีค่าและมี shortCode
|
||||
if (!round.value?.shortCode) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
// เลือก data source ตาม shortCode
|
||||
let dataSource: DataOption[] = [];
|
||||
switch (round.value.shortCode) {
|
||||
case "APR":
|
||||
dataSource = storeData.itemDownloadApr || [];
|
||||
break;
|
||||
case "OCT":
|
||||
dataSource = storeData.itemDownloadOct || [];
|
||||
break;
|
||||
default:
|
||||
dataSource = [];
|
||||
}
|
||||
|
||||
// กรองข้อมูลที่ไม่ใช่ PDF Map keyId
|
||||
return dataSource
|
||||
.filter((e) => e.type !== "pdf")
|
||||
.map((e) => ({
|
||||
...e,
|
||||
keyId: `${e.id}${e?.typeName ? `-${e.typeName}` : ""}`,
|
||||
}));
|
||||
});
|
||||
|
||||
const numOfPages = ref<number>(0);
|
||||
|
|
@ -151,8 +169,8 @@ function onChangeYear() {
|
|||
}
|
||||
|
||||
function fetchReportPDF() {
|
||||
if (employeeClass.value && round.value && report.value && nodeId.value) {
|
||||
fetchDataReportUnified(report.value, employeeClass.value);
|
||||
if (employeeClass.value && round.value && report.value?.id && nodeId.value) {
|
||||
fetchDataReportUnified(report.value?.id, employeeClass.value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -221,12 +239,20 @@ async function fetchDataReportUnified(
|
|||
"gov-08",
|
||||
"gov-10",
|
||||
].includes(reportCode);
|
||||
const finalUrl = isGovernmentId ? `${url}/${group.value}` : url;
|
||||
|
||||
const finalUrl = isGovernmentId
|
||||
? `${url}/${group.value}${
|
||||
report.value?.id === "gov-04" ? `/${report.value?.typeName}` : ""
|
||||
}`
|
||||
: `${url}${
|
||||
report.value?.id === "emp2-04" || report.value?.id === "emp-04"
|
||||
? `/${report.value?.typeName}`
|
||||
: ""
|
||||
}`;
|
||||
|
||||
try {
|
||||
const res = await http.get(finalUrl);
|
||||
const dataList = res.data.result;
|
||||
// await genReportXLSX(dataList, data.name, type);
|
||||
await fetchDocumentTemplate(dataList);
|
||||
} catch (e) {
|
||||
messageError($q, e);
|
||||
|
|
@ -267,7 +293,9 @@ async function fetchDocumentTemplate(data: any) {
|
|||
}
|
||||
|
||||
function onDownloadFile(type: string) {
|
||||
const name = reportOption.value.find((e) => e.id === report.value)?.name;
|
||||
const name = reportOption.value.find(
|
||||
(e) => e.keyId === report.value?.keyId
|
||||
)?.name;
|
||||
genReportXLSX(detailReport.value, `${name}_${nodeName.value}`, type);
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +318,7 @@ function clearFilter() {
|
|||
year.value = new Date().getFullYear();
|
||||
round.value = "";
|
||||
group.value = "GROUP1";
|
||||
report.value = "";
|
||||
report.value = null;
|
||||
|
||||
detailReport.value = undefined;
|
||||
pdfSrc.value = undefined;
|
||||
|
|
@ -326,7 +354,7 @@ onMounted(() => {
|
|||
option-label="name"
|
||||
option-value="id"
|
||||
bg-color="white"
|
||||
@update:model-value="(report = ''), fetchReportPDF"
|
||||
@update:model-value="(report = null), fetchReportPDF"
|
||||
>
|
||||
</q-select>
|
||||
</div>
|
||||
|
|
@ -443,7 +471,7 @@ onMounted(() => {
|
|||
lazy-rules
|
||||
hide-bottom-space
|
||||
bg-color="white"
|
||||
@update:model-value="report = ''"
|
||||
@update:model-value="report = null"
|
||||
>
|
||||
</q-select>
|
||||
</div>
|
||||
|
|
@ -475,10 +503,8 @@ onMounted(() => {
|
|||
v-model="report"
|
||||
:options="reportOption"
|
||||
label="รายงาน"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
option-value="keyId"
|
||||
class="bg-white"
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -587,7 +613,7 @@ onMounted(() => {
|
|||
unelevated
|
||||
color="public"
|
||||
type="submit"
|
||||
:disable="nodeId == '' || round == '' || report == ''"
|
||||
:disable="nodeId == '' || round == '' || report == null"
|
||||
/>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue