From 0676e8a644f7d4e76e369697eb2d0ca7ae6629ab Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Mon, 21 Oct 2024 16:04:02 +0700 Subject: [PATCH] no message --- .../components/DialogAddRequestEdit.vue | 12 +- .../10_registry/views/requestEditDetail.vue | 113 ++++++++++++++++++ 2 files changed, 124 insertions(+), 1 deletion(-) diff --git a/src/modules/10_registry/components/DialogAddRequestEdit.vue b/src/modules/10_registry/components/DialogAddRequestEdit.vue index 02b2cf4..349a580 100644 --- a/src/modules/10_registry/components/DialogAddRequestEdit.vue +++ b/src/modules/10_registry/components/DialogAddRequestEdit.vue @@ -171,6 +171,7 @@ function fetchProfile() { /** popup รายละเอียดของ ขอปรับปรุงข้อมูลจากกรมการปกครอง */ function onInfo(val: string) { + formData.document = null; if (val == "ขอปรับปรุงข้อมูลจากกรมการปกครอง") { modalInfo.value = true; } @@ -238,10 +239,19 @@ watch( diff --git a/src/modules/10_registry/views/requestEditDetail.vue b/src/modules/10_registry/views/requestEditDetail.vue index cd1a7db..42850d4 100644 --- a/src/modules/10_registry/views/requestEditDetail.vue +++ b/src/modules/10_registry/views/requestEditDetail.vue @@ -18,6 +18,7 @@ const router = useRouter(); const route = useRoute(); const { showLoader, hideLoader, messageError, date2Thai } = useCounterMixin(); +const urlImg = ref(""); const requestId = ref(route.params.id.toString()); const dataRequest = ref({ @@ -48,6 +49,9 @@ async function fetchData() { status: data.status, remark: data.remark, }; + if (dataRequest.value.topic == "ขอแก้ไขรูปภาพประจำตัว") { + onDownloadFile(requestId.value); + } }) .catch((err) => { messageError($q, err); @@ -57,6 +61,63 @@ async function fetchData() { }); } +/** + * function หาชื่อไฟล์ + * @param id รายการยื่นคำร้องขอแก้ไขข้อมูล + */ +function onDownloadFile(id: string) { + showLoader(); + http + .get( + config.API.file( + "ระบบทะเบียนประวัติ", + "เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล", + id + ) + ) + .then((res) => { + if (res.data.length !== 0) { + downloadUrl(id, res.data[0].fileName); + } else { + hideLoader(); + } + }) + .catch((e) => { + messageError($q, e); + hideLoader(); + }); +} + +/** + * function โหลดไฟล์ + * @param id รายการยื่นคำร้องขอแก้ไขข้อมูล + * @param fileName ชื่อไฟล์ + */ +function downloadUrl(id: string, fileName: string) { + http + .get( + config.API.fileByFile( + "ระบบทะเบียนประวัติ", + "เอกสารหลักฐานคำร้องขอแก้ไขข้อมูล", + id, + fileName + ) + ) + .then((res) => { + if (dataRequest.value.topic == "ขอแก้ไขรูปภาพประจำตัว") { + urlImg.value = res.data.downloadUrl; + } else { + window.open(res.data.downloadUrl, "_blank"); + } + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + onMounted(async () => { await fetchData(); }); @@ -157,6 +218,58 @@ onMounted(async () => { type="textarea" /> +
+ {{ + dataRequest.topic == "ขอแก้ไขรูปภาพประจำตัว" + ? "รูปภาพที่อัปโหลด" + : "เอกสารหลักฐาน" + }} +
+
+ + + หลักฐานอ้างอิง + +
+
+ +
+
+ + +
+