Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m21s

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-04-30 15:05:05 +07:00
commit e67f064421
2 changed files with 59 additions and 17 deletions

View file

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { is, useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { ref, onMounted } from "vue"; import { ref, onMounted, watch } from "vue";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
@ -18,14 +18,15 @@ const fileList = ref<FileFormType[]>([]);
/** ฟังก์ชันดึงข้อมูลไฟล์ */ /** ฟังก์ชันดึงข้อมูลไฟล์ */
async function getData() { async function getData() {
if (!store.profileId) return;
isLoading.value = true; isLoading.value = true;
await http await http
.get( .get(
config.API.fileByFileUser( config.API.fileByFileUser(
"ระบบทะเบียนประวัติ", "ระบบทะเบียนประวัติ",
"เอกสารหลักฐาน", "เอกสารหลักฐาน",
store.profileId store.profileId,
) ),
) )
.then((res) => { .then((res) => {
const data = res.data; const data = res.data;
@ -51,12 +52,23 @@ async function downloadFile(fileName: string) {
"ระบบทะเบียนประวัติ", "ระบบทะเบียนประวัติ",
"เอกสารหลักฐาน", "เอกสารหลักฐาน",
store.profileId, store.profileId,
fileName fileName,
) ),
) )
.then((res) => { .then(async (res) => {
const data = res.data.downloadUrl; const downloadUrl = res.data.downloadUrl;
window.open(data, "_blank"); 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 = fileName;
document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
}, 100);
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -69,6 +81,15 @@ async function downloadFile(fileName: string) {
onMounted(() => { onMounted(() => {
getData(); getData();
}); });
watch(
() => store.profileId,
(newVal) => {
if (newVal) {
getData();
}
},
);
</script> </script>
<template> <template>

View file

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from "vue"; import { ref, onMounted, watch } from "vue";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
@ -18,14 +18,15 @@ const fileList = ref<FileFormType[]>([]);
/** ฟังก์ชันดึงข้อมูลไฟล์ */ /** ฟังก์ชันดึงข้อมูลไฟล์ */
async function getData() { async function getData() {
if (!store.citizenId) return;
isLoading.value = true; isLoading.value = true;
await http await http
.get( .get(
config.API.fileByFileUser( config.API.fileByFileUser(
"ระบบทะเบียนประวัติ", "ระบบทะเบียนประวัติ",
"เอกสารหลักฐานเพิ่มเติม", "เอกสารหลักฐานเพิ่มเติม",
store.citizenId store.citizenId,
) ),
) )
.then((res) => { .then((res) => {
const data = res.data; const data = res.data;
@ -51,12 +52,23 @@ async function downloadFile(fileName: string) {
"ระบบทะเบียนประวัติ", "ระบบทะเบียนประวัติ",
"เอกสารหลักฐานเพิ่มเติม", "เอกสารหลักฐานเพิ่มเติม",
store.citizenId, store.citizenId,
fileName fileName,
) ),
) )
.then((res) => { .then(async (res) => {
const data = res.data.downloadUrl; const downloadUrl = res.data.downloadUrl;
window.open(data, "_blank"); 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 = fileName;
document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
URL.revokeObjectURL(url);
}, 100);
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
@ -69,6 +81,15 @@ async function downloadFile(fileName: string) {
onMounted(() => { onMounted(() => {
getData(); getData();
}); });
watch(
() => store.citizenId,
(newVal) => {
if (newVal) {
getData();
}
},
);
</script> </script>
<template> <template>