fix bug ==> ดาวน์โหลดไฟล์ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา
This commit is contained in:
parent
da98c579fc
commit
1cad82f258
2 changed files with 24 additions and 56 deletions
|
|
@ -1245,17 +1245,15 @@ onMounted(async () => {
|
|||
</q-btn>
|
||||
</q-td>
|
||||
|
||||
<!-- <q-td auto-width>
|
||||
<q-td auto-width>
|
||||
<btnDownloadFile
|
||||
v-if="
|
||||
props.row.insigniaSend == 'เหรียญจักรพรรดิมาลา (ร.จ.พ.)' &&
|
||||
checkPermission($route)?.attrIsGet
|
||||
"
|
||||
:profileId="props.row.profileId"
|
||||
:round="DataStore.roundId"
|
||||
:optionRound="DataStore.optionRound"
|
||||
:rowId="props.row.id"
|
||||
/>
|
||||
</q-td> -->
|
||||
</q-td>
|
||||
|
||||
<q-td key="no" :props="props">
|
||||
{{ props.rowIndex + 1 }}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import { useCounterMixin } from "@/stores/mixin";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
import type { Optionround } from "@/modules/07_insignia/interface/index/Main";
|
||||
import genReport from "@/plugins/genreport";
|
||||
import genReportXLSX from "@/plugins/genreportxlsx";
|
||||
|
||||
/** use*/
|
||||
const $q = useQuasar();
|
||||
|
|
@ -15,68 +16,37 @@ const { messageError, showLoader, hideLoader } = mixin;
|
|||
|
||||
/** props*/
|
||||
const props = defineProps({
|
||||
profileId: {
|
||||
rowId: {
|
||||
type: String,
|
||||
},
|
||||
round: {
|
||||
type: String,
|
||||
},
|
||||
optionRound: {
|
||||
type: Object,
|
||||
},
|
||||
});
|
||||
|
||||
const titleReport = ref<string>(""); //ชื่อรายงาน
|
||||
|
||||
/**
|
||||
* function ดาวน์โหลดไฟล์
|
||||
* @param type ประเภท file
|
||||
*/
|
||||
async function downloadDocument(type: string) {
|
||||
let round = [];
|
||||
if (props.optionRound) {
|
||||
round = props.optionRound.find((e: Optionround) => e.id === props.round);
|
||||
}
|
||||
titleReport.value = round.name;
|
||||
const download: boolean = true;
|
||||
if (props.profileId) {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.reportInsignia("46", type, props.profileId), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (download) {
|
||||
downloadFile(
|
||||
res,
|
||||
`ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา.${type}`
|
||||
);
|
||||
}
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
showLoader();
|
||||
try {
|
||||
const res = await http.post(
|
||||
config.API.reportInsigniaNew + `/report8/${props.rowId}`
|
||||
);
|
||||
|
||||
/**
|
||||
* function โหลดเอกสาร
|
||||
* @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]));
|
||||
link.setAttribute("download", fileName);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
const reportTitle = "ประวัติสำหรับการเสนอขอพระราชทานเหรียญจักรพรรดิมาลา";
|
||||
|
||||
if (type === "xlsx") {
|
||||
await genReportXLSX(res.data.result, reportTitle, type);
|
||||
} else {
|
||||
await genReport(res.data.result, reportTitle, type);
|
||||
}
|
||||
} catch (error) {
|
||||
messageError($q, error);
|
||||
} finally {
|
||||
hideLoader();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<q-btn
|
||||
dense
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue