report insignia

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-01-17 17:12:11 +07:00
parent 2dcb25d9db
commit eedab43e4a
4 changed files with 87 additions and 24 deletions

View file

@ -105,4 +105,6 @@ export default {
// สกจ. ตีกลับให้หัวหน้าเขต // สกจ. ตีกลับให้หัวหน้าเขต
rejectRequest: (id: string, ocId: string) => rejectRequest: (id: string, ocId: string) =>
`${insignia}/request/head/reject/${id}/${ocId}`, `${insignia}/request/head/reject/${id}/${ocId}`,
reportInsigniaNew: `${insignia}/report`,
}; };

View file

@ -82,6 +82,7 @@ const formData = reactive<FormDataAgency>({
responsibility: "", responsibility: "",
isOfficer: false, isOfficer: false,
isDeputy: false, isDeputy: false,
orgMisId: "",
}); });
/** /**
@ -120,6 +121,8 @@ function onSubmit() {
["org" + type + "Fax"]: formData.orgFax, ["org" + type + "Fax"]: formData.orgFax,
["org" + type + "Rank"]: formData.orgLevel, ["org" + type + "Rank"]: formData.orgLevel,
["org" + type + "RankSub"]: formData.orgLevelSub, ["org" + type + "RankSub"]: formData.orgLevelSub,
misId: formData.orgMisId,
[nameId]: rootId, [nameId]: rootId,
responsibility: responsibility:
formData.responsibility != null ? formData.responsibility : "", formData.responsibility != null ? formData.responsibility : "",
@ -205,6 +208,7 @@ function closeClear() {
formData.orgLevel = ""; formData.orgLevel = "";
formData.responsibility = ""; formData.responsibility = "";
formData.isOfficer = false; formData.isOfficer = false;
formData.orgMisId = "";
props.close?.(); props.close?.();
} }
@ -402,6 +406,7 @@ watch(
formData.responsibility = props.dataNode.responsibility; formData.responsibility = props.dataNode.responsibility;
formData.isOfficer = props.dataNode.isOfficer ?? false; formData.isOfficer = props.dataNode.isOfficer ?? false;
formData.isDeputy = props.dataNode.isDeputy ?? false; formData.isDeputy = props.dataNode.isDeputy ?? false;
formData.orgMisId = props.dataNode.isDeputy;
orgLevelOption.value = orgLevelOption.value =
props.dataNode.orgTreeRank === "DEPARTMENT" props.dataNode.orgTreeRank === "DEPARTMENT"
? orgLevelOptionMain.value ? orgLevelOptionMain.value
@ -596,6 +601,18 @@ watch(
:class="classInput(false)" :class="classInput(false)"
/> />
</div> </div>
<div class="col-4">
<q-input
v-model="formData.orgMisId"
ref="orgMisIdRef"
dense
outlined
for="#misId"
label="MisId"
hide-bottom-space
:class="classInput(false)"
/>
</div>
<div class="col-12"> <div class="col-12">
<q-input <q-input
v-model="formData.responsibility" v-model="formData.responsibility"

View file

@ -37,6 +37,7 @@ interface FormDataAgency {
responsibility: string; responsibility: string;
isOfficer?: boolean; isOfficer?: boolean;
isDeputy?: boolean; isDeputy?: boolean;
orgMisId: string;
} }
interface FormDataPosition { interface FormDataPosition {

View file

@ -2,6 +2,7 @@
import { ref, onMounted } from "vue"; import { ref, onMounted } from "vue";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { VuePDF, usePDF } from "@tato30/vue-pdf"; import { VuePDF, usePDF } from "@tato30/vue-pdf";
import axios from "axios";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import { checkPermission } from "@/utils/permissions"; import { checkPermission } from "@/utils/permissions";
@ -9,6 +10,8 @@ import { useCounterMixin } from "@/stores/mixin";
import { useStructureTree } from "@/stores/structureTree"; import { useStructureTree } from "@/stores/structureTree";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import genReport from "@/plugins/genreport";
import genReportXLSX from "@/plugins/genreportxlsx";
import type { DataStructureTree } from "@/interface/main"; import type { DataStructureTree } from "@/interface/main";
import type { OptionData } from "@/modules/07_insignia/interface/index/Main"; import type { OptionData } from "@/modules/07_insignia/interface/index/Main";
@ -29,11 +32,14 @@ const employeeClassOption = ref<OptionData[]>([
const typeReport = ref<string>(""); const typeReport = ref<string>("");
const optionReport = ref<OptionData[]>([ const optionReport = ref<OptionData[]>([
{ {
id: "45", id: "report1",
name: "บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชอิสริยาภรณ์", name: "บัญชีรายชื่อข้าราชการผู้ขอพระราชทานเครื่องราชอิสริยาภรณ์",
}, },
{ id: "44", name: " บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี" }, {
{ id: "43", name: " บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ 5 ปี" }, id: "report2",
name: " บัญชีระดับผลการประเมินผลการปฏิบัติราชการในรอบ 5 ปี",
},
{ id: "report3", name: " บัญชีแสดงจำนวนชั้นตราเครื่องราชฯ 5 ปี" },
]); ]);
const roundId = ref<string>(""); const roundId = ref<string>("");
@ -54,21 +60,11 @@ const pdfSrc = ref<any>();
const isLoadPDF = ref<boolean>(false); const isLoadPDF = ref<boolean>(false);
// /**
// * Redirect
// * @param type
// */
// function nextPage(type: string) {
// router.push(`/insignia/report/${type}`);
// }
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);
} }
/** /** ฟังก์ชันคึงข้อมูลรอบการเสนอขอ*/
* งกนคงขอมลรอบการเสนอขอ
*/
async function fecthlistRound() { async function fecthlistRound() {
showLoader(); showLoader();
await http await http
@ -106,12 +102,19 @@ function filterSelector(val: string, update: Function, name: string) {
}); });
} }
/**
* function เลอกหนวยงาน
* @param id id หนวยงาน
* @param level ระดบหนวยงาน
*/
function onSelectedNode(id: string, level: number) { function onSelectedNode(id: string, level: number) {
nodeId.value = id; nodeId.value = id;
nodeLevel.value = level; nodeLevel.value = level;
onUpdateFilter(); onUpdateFilter();
} }
const detailReport = ref<any>();
/** /**
* งกนโหลดไฟล * งกนโหลดไฟล
* @param type ประเภทไฟล * @param type ประเภทไฟล
@ -123,16 +126,19 @@ async function onUpdateFilter() {
pdfSrc.value = undefined; pdfSrc.value = undefined;
await http await http
.get(config.API.reportInsignia(typeReport.value, "pdf", roundId.value), { .post(
responseType: "blob", config.API.reportInsigniaNew +
}) `/${typeReport.value}/${employeeClass.value}`,
{
roundId: roundId.value,
node: nodeLevel.value,
nodeId: nodeId.value,
}
)
.then(async (res) => { .then(async (res) => {
const url = URL.createObjectURL(new Blob([res.data])); const data = await res.data.result;
const pdfData = await usePDF(url); detailReport.value = data;
await setTimeout(() => { await fetchDocumentTemplate(data);
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1000);
}) })
.catch(async (e) => { .catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text())); messageError($q, JSON.parse(await e.response.data.text()));
@ -143,6 +149,34 @@ async function onUpdateFilter() {
} }
} }
/**
* function เรยกไฟล PDF
* @param data อมลบญชนลา
*/
async function fetchDocumentTemplate(data: any) {
await axios
.post(`${config.API.reportTemplate}/docx`, data, {
headers: {
accept: "application/pdf",
"content-Type": "application/json",
},
responseType: "blob",
})
.then(async (res) => {
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
const pdfData = usePDF(`${objectUrl}`);
setTimeout(() => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1500);
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
}
/** ไปหน้าต่อไปของรายงาน */ /** ไปหน้าต่อไปของรายงาน */
function nextPage() { function nextPage() {
if (page.value < numOfPages.value) { if (page.value < numOfPages.value) {
@ -157,7 +191,16 @@ function backPage() {
} }
} }
function downloadReport(type: string) {} function downloadReport(type: string) {
const fileName =
optionReport.value.find((e) => e.id === typeReport.value)?.name || "";
if (type === "xlsx") {
genReportXLSX(detailReport.value, fileName, type);
} else {
genReport(detailReport.value, fileName, type);
}
}
onMounted(async () => { onMounted(async () => {
await Promise.all([fetchDataTree(), fecthlistRound()]); await Promise.all([fetchDataTree(), fecthlistRound()]);