แก้ download file
This commit is contained in:
parent
f725b5fe21
commit
adab68a63f
1 changed files with 19 additions and 19 deletions
|
|
@ -6,6 +6,9 @@ import { useQuasar } from "quasar";
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router";
|
||||||
import { useCounterMixin } from "@/stores/mixin";
|
import { useCounterMixin } from "@/stores/mixin";
|
||||||
import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
|
import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
|
||||||
|
|
||||||
|
import genReport from "@/plugins/genreport";
|
||||||
|
|
||||||
const probationStore = useProbationDataStore();
|
const probationStore = useProbationDataStore();
|
||||||
const { fecthdataAssign } = probationStore;
|
const { fecthdataAssign } = probationStore;
|
||||||
|
|
||||||
|
|
@ -59,35 +62,26 @@ const fecthAssign = async (id: string) => {
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const 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 FileDownload = async (type: string) => {
|
const FileDownload = async (type: string) => {
|
||||||
let numTab = evaluate.value.find((e: any) => e.no === dataArrayNumber.value);
|
let numTab = evaluate.value.find((e: any) => e.no === dataArrayNumber.value);
|
||||||
showLoader();
|
showLoader();
|
||||||
await http
|
await http
|
||||||
.get(config.API.reportEvaluateChairman(type, numTab.id), {
|
.get(config.API.reportEvaluateChairman(type, numTab.id))
|
||||||
responseType: "blob",
|
|
||||||
})
|
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
downloadFile(
|
const data = res.data.result;
|
||||||
res,
|
await genReport(
|
||||||
`แบบประเมินผล(คณะกรรมการ)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
|
data,
|
||||||
|
`แบบประเมินผล(คณะกรรมการ)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
|
||||||
|
type
|
||||||
);
|
);
|
||||||
|
hideLoader();
|
||||||
})
|
})
|
||||||
.catch(async (e) => {
|
.catch(async (e) => {
|
||||||
messageError($q, JSON.parse(await e.response.data.text()));
|
messageError($q, JSON.parse(await e.response.data.text()));
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
hideLoader();
|
hideLoader();
|
||||||
});
|
})
|
||||||
|
.finally(() => {});
|
||||||
};
|
};
|
||||||
const addData = () => {
|
const addData = () => {
|
||||||
router.push(
|
router.push(
|
||||||
|
|
@ -134,7 +128,13 @@ const changeTab = (tabVal: string) => {
|
||||||
|
|
||||||
<div class="q-gutter-md" v-if="tabs.length === 0">
|
<div class="q-gutter-md" v-if="tabs.length === 0">
|
||||||
<div class="flex justify-center items-center q-my-md q-gutter-md">
|
<div class="flex justify-center items-center q-my-md q-gutter-md">
|
||||||
<q-btn v-if="!checkRoutePermisson" outline color="primary" label="สร้างแบบประเมิน" @click="addData" />
|
<q-btn
|
||||||
|
v-if="!checkRoutePermisson"
|
||||||
|
outline
|
||||||
|
color="primary"
|
||||||
|
label="สร้างแบบประเมิน"
|
||||||
|
@click="addData"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue