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