From 14195e972f6f198426ada41e5f2fe37423694396 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 30 Apr 2026 15:17:49 +0700 Subject: [PATCH] refactor(file): replace window.open with blob download pattern in ChangeName Co-authored-by: Copilot --- .../01_Information/02_ChangeName.vue | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/modules/10_registry/01_Information/02_ChangeName.vue b/src/modules/10_registry/01_Information/02_ChangeName.vue index 0a7a972..5a140b4 100644 --- a/src/modules/10_registry/01_Information/02_ChangeName.vue +++ b/src/modules/10_registry/01_Information/02_ChangeName.vue @@ -114,7 +114,7 @@ function onSearch() { rows.value = onSearchDataTable( filter.value, rowsData.value, - columns.value ? columns.value : [] + columns.value ? columns.value : [], ); } @@ -132,12 +132,27 @@ async function onDownloadFile(id: string, profileId: string) { "ประวัติการเปลี่ยนชื่อ-นามสกุล", profileId, id, - "เอกสารหลักฐาน" - ) + "เอกสารหลักฐาน", + ), ) .then(async (res) => { - const data = res.data.downloadUrl; - window.open(data, "_blank"); + // const data = res.data.downloadUrl; + // window.open(data, "_blank"); + console.log(res.data); + + const downloadUrl = res.data.downloadUrl; + const response = await fetch(downloadUrl); + const blob = await response.blob(); + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = `ประวัติการเปลี่ยนชื่อ-นามสกุล_`; + document.body.appendChild(link); + link.click(); + setTimeout(() => { + document.body.removeChild(link); + URL.revokeObjectURL(url); + }, 100); }) .catch((err) => { messageError($q, err);