Compare commits

..

No commits in common. "e67f064421fe53754e518035251108be0a116a30" and "992a420bcd0f6154d07f274eb88b6f5b9b6db0db" have entirely different histories.

2 changed files with 17 additions and 59 deletions

View file

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

View file

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