download file ทดลองงาน

This commit is contained in:
STW_TTTY\stwtt 2024-08-22 12:05:41 +07:00
parent c63539190d
commit c014962eed
8 changed files with 85 additions and 77 deletions

View file

@ -6,6 +6,8 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
const $q = useQuasar();
const isEdit = ref<boolean>(true);
const router = useRouter();
@ -917,21 +919,21 @@ function downloadFile(response: any, filename: string) {
async function clickdownloadFile(type: string) {
showLoader();
await http
.get(config.API.reportAssign(type, assignId.value), {
responseType: "blob",
})
.then((res) => {
downloadFile(
res,
`แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-${fullname.value}.${type}`
.get(config.API.reportAssign(type, assignId.value))
.then(async (res) => {
const data = res.data.result;
await genReport(
data,
`แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-${fullname.value}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
})
.finally(() => {});
}
/** เช็ค จำนวนเดือน เเละ วันที่เริ่ม ไม่เท่ากับ undefined*/
@ -1088,7 +1090,7 @@ onMounted(async () => {
<div v-else class="col-12 row q-gutter-md">
<div>แบบมอบหมายงานการทดลองปฏหนาทราชการ</div>
<q-btn
v-if="!isEdit && !checkRoutePermisson"
v-if="!isEdit"
size="12px"
flat
dense

View file

@ -29,7 +29,7 @@ const {
const route = useRoute();
const checkRoutePermisson = ref<boolean>(route.name == "probationFormDetail");
const assignId = ref<string>(route.params.form.toString());
const { assign } = probationStore;
const { fecthAssignoutput,assign } = probationStore;
const Autherise = ref<any>(null);
const dateAutherise = ref<any>(new Date());
const option = ref<any>([]);
@ -106,6 +106,7 @@ async function fecthAssign() {
await http
.get(config.API.evaluateCreate(assignId.value))
.then(async (res) => {
await fecthAssignoutput(res.data.data);
// if (props.action == "add") {
person.value = res.data.data.person;
// option.value.push(res.data.data.commander);

View file

@ -21,7 +21,7 @@ const router = useRouter();
const routeName = router.currentRoute.value.name;
const $q = useQuasar();
const probationStore = useProbationDataStore();
const { assign } = probationStore;
const { fecthAssignoutput, assign } = probationStore;
const mixin = useCounterMixin();
const {
date2Thai,
@ -218,6 +218,7 @@ async function fecthAssign() {
await http
.get(config.API.evaluateChairman(assignId.value))
.then(async (res: any) => {
await fecthAssignoutput(res.data.data);
assign.value = res.data.data.assign;
evaluate_no.value = res.data.data.evaluate_no;
start_date.value = res.data.data.start_date;

View file

@ -6,6 +6,8 @@ import { useRoute, useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
import genReport from "@/plugins/genreport";
const probationStore = useProbationDataStore();
const $q = useQuasar();
@ -156,21 +158,21 @@ function downloadFile(response: any, filename: string) {
async function clickdownloadFile(type: string) {
showLoader();
await http
.get(config.API.reportEvaluateResult(type, assignId.value), {
responseType: "blob",
})
.then((res) => {
downloadFile(
res,
`แบบรายงานการประเมินฯ_${probationStore.person.name}.${type}`
.get(config.API.reportEvaluateResult(type, assignId.value))
.then(async (res) => {
const data = res.data.result;
await genReport(
data,
`แบบรายงานการประเมินฯ_${person.value.name}.${type}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
})
.finally(() => {});
}
/** post/put data
@ -717,7 +719,10 @@ onMounted(() => {
</div>
</q-form>
<q-toolbar class="text-primary" v-if="action == 'add' && !checkRoutePermisson">
<q-toolbar
class="text-primary"
v-if="action == 'add' && !checkRoutePermisson"
>
<q-space />
<q-btn label="บันทึก" color="secondary" @click="savaForm" />
</q-toolbar>

View file

@ -6,6 +6,7 @@ import { useRoute, useRouter } from "vue-router";
import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
const Header = defineAsyncComponent(
() =>
@ -63,17 +64,6 @@ function changeTab(tabVal: string) {
dataArrayNumber.value = Number(tabVal.charAt(4));
}
/** convert file */
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);
}
/** download file */
async function FileDownload(type: string) {
let numTab = probationStore.evaluate.find(
@ -83,40 +73,40 @@ async function FileDownload(type: string) {
if (dataRole.value == "mentor") {
showLoader();
await http
.get(config.API.reportEvaluateRecord1(type, numTab.id), {
responseType: "blob",
})
.get(config.API.reportEvaluateRecord1(type, numTab.id))
.then(async (res) => {
downloadFile(
res,
`แบบบันทึกผล(ผู้ดูเเล)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
const data = res.data.result;
await genReport(
data,
`แบบบันทึกผล(ผู้ดูเเล)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
})
.finally(() => {});
} else {
//
showLoader();
await http
.get(config.API.reportEvaluateRecord1(type, numTab.id), {
responseType: "blob",
})
.get(config.API.reportEvaluateRecord1(type, numTab.id))
.then(async (res) => {
downloadFile(
res,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
const data = res.data.result;
await genReport(
data,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
})
.finally(() => {});
}
}
@ -167,7 +157,7 @@ onMounted(async () => {
<div class="q-gutter-md" v-else-if="probationStore.tabs.length == 0">
<div class="flex justify-center items-center q-my-md q-gutter-md">
<q-btn
v-if="!checkRoutePermisson"
v-if="!checkRoutePermisson"
outline
color="primary"
label="สร้างแบบบันทึกผล"

View file

@ -7,6 +7,8 @@ import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
const Header = defineAsyncComponent(
() =>
import(
@ -87,39 +89,42 @@ async function FileDownload(type: string) {
if (dataRole.value == "mentor") {
showLoader();
await http
.get(config.API.reportEvaluateRecord1(type, numTab.id), {
responseType: "blob",
})
.get(config.API.reportEvaluateRecord1(type, numTab.id))
.then(async (res) => {
downloadFile(
res,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
const data = res.data.result;
await genReport(
data,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
hideLoader();
})
.finally(() => {
hideLoader();
});
} else {
//
showLoader();
await http
.get(config.API.reportEvaluateRecord1(type, numTab.id), {
responseType: "blob",
})
.get(config.API.reportEvaluateRecord1(type, numTab.id))
.then(async (res) => {
downloadFile(
res,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
const data = res.data.result;
await genReport(
data,
`แบบบันทึกผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
hideLoader();
})
.finally(() => {
hideLoader();
});
}
}

View file

@ -7,6 +7,8 @@ import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useProbationDataStore } from "@/modules/05_placement/storeProbation";
import genReport from "@/plugins/genreport";
const Header = defineAsyncComponent(
() =>
import(
@ -86,20 +88,22 @@ async function FileDownload(type: string) {
let numTab = evaluate.value.find((e: any) => e.no === dataArrayNumber.value);
showLoader();
await http
.get(config.API.reportEvaluate(type, numTab.id), {
responseType: "blob",
})
.get(config.API.reportEvaluate(type, numTab.id))
.then(async (res) => {
downloadFile(
res,
`แบบประเมินผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}.${type}`
const data = res.data.result;
await genReport(
data,
`แบบประเมินผล(ผู้บังคับบัญชา)_${probationStore.person.name}_ครั้งที่${numTab.no}`,
type
);
hideLoader();
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
hideLoader();
})
.finally(() => {
hideLoader();
});
}
@ -146,7 +150,7 @@ onMounted(() => {
/>
</q-tab-panel>
</q-tab-panels>
<div v-else class="q-gutter-md">
<div class="flex justify-center items-center q-my-md q-gutter-md">
<q-btn