From f876abf6510af3b3af75e28939608fe925755739 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Wed, 25 Sep 2024 15:14:10 +0700 Subject: [PATCH 1/2] =?UTF-8?q?update=20=3D>=20API=20=E0=B8=AD=E0=B8=AD?= =?UTF-8?q?=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../18_command/components/Step/0_Main.vue | 4 +- .../components/Step/View0_Digital.vue | 298 +++++++++++++----- .../18_command/components/Step/View0_Live.vue | 232 ++++++++------ src/modules/18_command/store/DetailStore.ts | 2 +- 4 files changed, 352 insertions(+), 184 deletions(-) diff --git a/src/modules/18_command/components/Step/0_Main.vue b/src/modules/18_command/components/Step/0_Main.vue index d5fa07909..f45c19ae3 100644 --- a/src/modules/18_command/components/Step/0_Main.vue +++ b/src/modules/18_command/components/Step/0_Main.vue @@ -1,5 +1,5 @@ diff --git a/src/modules/18_command/components/Step/View0_Digital.vue b/src/modules/18_command/components/Step/View0_Digital.vue index e99b61200..8e973cc32 100644 --- a/src/modules/18_command/components/Step/View0_Digital.vue +++ b/src/modules/18_command/components/Step/View0_Digital.vue @@ -1,6 +1,7 @@ diff --git a/src/modules/07_insignia/components/4_Allocate/OrgList.vue b/src/modules/07_insignia/components/4_Allocate/OrgAllocatePageList.vue similarity index 87% rename from src/modules/07_insignia/components/4_Allocate/OrgList.vue rename to src/modules/07_insignia/components/4_Allocate/OrgAllocatePageList.vue index 7db9c94c9..8406bd8fd 100644 --- a/src/modules/07_insignia/components/4_Allocate/OrgList.vue +++ b/src/modules/07_insignia/components/4_Allocate/OrgAllocatePageList.vue @@ -1,14 +1,19 @@ - diff --git a/src/modules/07_insignia/components/report/Report_02.vue b/src/modules/07_insignia/components/report/ReportDetail.vue similarity index 83% rename from src/modules/07_insignia/components/report/Report_02.vue rename to src/modules/07_insignia/components/report/ReportDetail.vue index 959cb616d..64a6f997c 100644 --- a/src/modules/07_insignia/components/report/Report_02.vue +++ b/src/modules/07_insignia/components/report/ReportDetail.vue @@ -5,6 +5,9 @@ import { useCounterMixin } from "@/stores/mixin"; import { useRoute } from "vue-router"; import { useQuasar } from "quasar"; +import type { OptionData } from "@/modules/07_insignia/interface/index/Main"; +import type { ResponsePeriod } from "@/modules/07_insignia/interface/response/Main"; + import { useInsigniaDataStore } from "@/modules/07_insignia/store"; import http from "@/plugins/http"; @@ -31,37 +34,45 @@ interface OptionReport { title: string; } -onMounted(async () => { - await fecthlistRound(); - let report = optionReport.find((e: OptionReport) => e.id == typeReport); - report && (titleReport.value = report.title); -}); - const splitterModel = ref(14); const selectList = ref(); -const optionsList = ref([{ id: 0, name: "เลือกกรอบการยื่นขอ" }]); -const filterOtion = ref([]); +const optionsList = ref([{ id: 0, name: "เลือกกรอบการยื่นขอ" }]); +const filterOtion = ref([]); -const nextPage = () => { +/** + * ฟังก์ชันไปหน้าถัดไป + */ +function nextPage() { if (page.value < numOfPages.value) { page.value++; } -}; -const backPage = () => { +} + +/** + * ฟังก์ชันย้อนกลับ + */ +function backPage() { if (page.value !== 1) { page.value--; } -}; +} -const backHistory = () => { +/** + * ฟังก์ชัน Redirect ไปหน้า รายงานเครื่องราชอิสริยาภรณ์ + */ +function backHistory() { window.history.back(); -}; +} -const fecthlistRound = async () => { +/** + * ฟังก์ชันคึงข้อมูลรอบการเสนอขอ + */ +async function fecthlistRound() { + showLoader(); await http .get(config.API.listRoundInsignia()) .then((res: any) => { - optionsList.value = res.data.result.map((e: any) => ({ + optionsList.value = res.data.result.map((e: ResponsePeriod) => ({ id: e.period_id, year: e.period_year, name: e.period_name, @@ -70,14 +81,24 @@ const fecthlistRound = async () => { }) .catch((err) => { messageError($q, err); + }) + .finally(() => { + hideLoader(); }); -}; +} -const updateSelect = () => { +/** + * ฟังก์ชันเลือกรอบการเสนอขอ + */ +function updateSelect() { conditionDocument("show"); -}; +} -const conditionDocument = (type: string) => { +/** + * ฟังก์ชันโหลไฟล์รายงาน + * @param type นามสกุลไฟล์ที่ต้องการ + */ +function conditionDocument(type: string) { myForm.value?.validate().then(async (success: boolean) => { if (success) { if (type == "show") { @@ -87,18 +108,26 @@ const conditionDocument = (type: string) => { } } }); -}; +} -const showDocument = (url: any) => { +/** + * ฟังก์แสดงรายงาน + * @param url + */ +function showDocument(url: any) { const pdfData = usePDF(url); - setTimeout(() => { pdfSrc.value = pdfData.pdf.value; numOfPages.value = pdfData.pages.value; }, 1000); -}; +} -const downloadFile = (response: any, filename: string) => { +/** + * ฟังก์ชันโหลดไฟล์ + * @param response ช้อมูลที่ต้องการ + * @param filename ชื่อไฟล์ + */ +function downloadFile(response: any, filename: string) { const link = document.createElement("a"); var fileName = filename; link.href = window.URL.createObjectURL(new Blob([response.data])); @@ -106,12 +135,14 @@ const downloadFile = (response: any, filename: string) => { document.body.appendChild(link); link.click(); document.body.removeChild(link); -}; +} -const downloadReport = async ( - type: string = "pdf", - download: boolean = true -) => { +/** + * ฟังก์ชันโหลดไฟล์ + * @param type ประเภทไฟล์ + * @param download + */ +async function downloadReport(type: string = "pdf", download: boolean = true) { showLoader(); await http .get(config.API.reportInsignia(typeReport, type, selectList.value.id), { @@ -134,17 +165,30 @@ const downloadReport = async ( .finally(() => { hideLoader(); }); -}; -const filterSelector = (val: any, update: Function, name: any) => { +} + +/** + * function ค้นหาข้อมูลใน option + * @param val คำค้นหา + * @param update function + * @param name ชื่อ Selec + */ +function filterSelector(val: string, update: Function, name: string) { update(() => { const needle = val.toLowerCase(); if (name === "selectList") { filterOtion.value = optionsList.value.filter( - (v: any) => v.name.toLowerCase().indexOf(needle) > -1 + (v: OptionData) => v.name.toLowerCase().indexOf(needle) > -1 ); } }); -}; +} + +onMounted(async () => { + await fecthlistRound(); + let report = optionReport.find((e: OptionReport) => e.id == typeReport); + report && (titleReport.value = report.title); +});