fixing response blob

This commit is contained in:
Warunee Tamkoo 2024-06-14 11:06:31 +07:00
parent a27091a81a
commit 74f1540203
25 changed files with 138 additions and 119 deletions

View file

@ -158,8 +158,8 @@ const clickAccount1 = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -185,8 +185,8 @@ const clickAccount2 = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -211,8 +211,8 @@ const clickAccount3 = async () => {
// start download
a.click();
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -502,8 +502,8 @@ const downloadFile = async () => {
const data = res.data;
downloadFilePDF(data, `Candidate__${dateToISO(new Date())}.xlsx`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -520,8 +520,8 @@ const downloadFileDetail = async () => {
const data = res.data;
downloadFilePDF(data, `Candidate_Detail_${dateToISO(new Date())}.xlsx`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -638,8 +638,8 @@ const downloadFileDashboard = async () => {
`Candidate_Dashboard_${dateToISO(new Date())}.xlsx`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -84,8 +84,8 @@ const fileDownload = async (no: number, type: string, fileName: string) => {
.then(async (res) => {
downloadFile(res, `${fileName}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -950,8 +950,8 @@ async function clickdownloadFile(type: string) {
`แบบมอบหมายงานการทดลองปฏิบัติหน้าที่ราชการ-${fullname.value}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -160,8 +160,8 @@ async function clickdownloadFile(type: string) {
.then((res) => {
downloadFile(res, `แบบรายงานการประเมินฯ_${fullname.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -37,13 +37,15 @@ const dataRole = ref<string>("mentor");
/** get
* @param id person id
*/
async function fecthAssign(id: string){
async function fecthAssign(id: string) {
showLoader();
await http
.get(config.API.formevaluate(id))
.then(async (res: any) => {
await fecthdataAssign(res.data.data);
fullname.value = res.data.data.experimentee ? res.data.data.experimentee.name : "";
fullname.value = res.data.data.experimentee
? res.data.data.experimentee.name
: "";
dataArrayNumber.value = 1;
})
.catch((e: any) => {
@ -52,19 +54,19 @@ async function fecthAssign(id: string){
.finally(() => {
hideLoader();
});
};
}
/**
* เปลยน tab
* @param tabVal type
*/
function changeTab(tabVal: string){
function changeTab(tabVal: string) {
tab.value = tabVal;
dataArrayNumber.value = Number(tabVal.charAt(4));
};
}
/** convert file */
function downloadFile(response: any, filename: string){
function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
@ -72,10 +74,10 @@ function downloadFile(response: any, filename: string){
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
}
/** download file */
async function FileDownload(type: string){
async function FileDownload(type: string) {
let numTab = probationStore.evaluate.find(
(e: any) => e.no === dataArrayNumber.value
);
@ -92,8 +94,8 @@ async function FileDownload(type: string){
`แบบบันทึกผล(ผู้ดูเเล)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -111,21 +113,21 @@ async function FileDownload(type: string){
`แบบบันทึกผล(ผู้บังคับบัญชา)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
}
};
}
/** ไปหน้า page add */
function addData(){
function addData() {
router.push(
`/probation/detail/addresult/${personalId.value}/${assignId.value}`
);
};
}
onMounted(async () => {
await fecthAssign(assignId.value);

View file

@ -40,9 +40,9 @@ onMounted(async () => {
/**
* get data
* @param id person id
* @param id person id
*/
async function fecthAssign(id: string){
async function fecthAssign(id: string) {
showLoader();
await http
.get(config.API.formevaluateCommander(id))
@ -59,19 +59,19 @@ async function fecthAssign(id: string){
.finally(() => {
hideLoader();
});
};
}
/**
* เปลยน tab
* @param tabVal type
* @param tabVal type
*/
function changeTab(tabVal: string){
function changeTab(tabVal: string) {
tab.value = tabVal;
dataArrayNumber.value = Number(tabVal.charAt(4));
};
}
/** เปลี่ยน type file */
function downloadFile(response: any, filename: string){
function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
@ -79,13 +79,13 @@ function downloadFile(response: any, filename: string){
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
}
/**
* download file
* @param type type
*/
async function FileDownload(type: string){
async function FileDownload(type: string) {
let numTab = probationStore.evaluate.find(
(e: any) => e.no === dataArrayNumber.value
);
@ -102,8 +102,8 @@ async function FileDownload(type: string){
`แบบบันทึกผล(ผู้บังคับบัญชา)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -121,21 +121,21 @@ async function FileDownload(type: string){
`แบบบันทึกผล(ผู้บังคับบัญชา)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
}
};
}
/** เปลี่ยนหน้า เพิ่ม */
function addData(){
function addData() {
router.push(
`/probation/detail/addevaluacommander/${personalId.value}/${assignId.value}`
);
};
}
</script>
<template>

View file

@ -37,12 +37,12 @@ const evaluate = ref<any>([]);
/**
* เปลยน tab
* @param tabVal type
* @param tabVal type
*/
function changeTab(tabVal: string){
function changeTab(tabVal: string) {
tab.value = tabVal;
dataArrayNumber.value = Number(tabVal.charAt(4));
};
}
onMounted(() => {
fecthAssign(assignId.value);
@ -50,9 +50,9 @@ onMounted(() => {
/**
* get data
* @param id person id
* @param id person id
*/
async function fecthAssign(id: string){
async function fecthAssign(id: string) {
showLoader();
await http
.get(config.API.createformCommader(id))
@ -60,7 +60,9 @@ onMounted(() => {
await fecthdataAssign(res.data.data);
evaluate.value = probationStore.evaluate;
tabs.value = evaluate.value;
fullname.value = res.data.data.experimentee ? res.data.data.experimentee.name : "";
fullname.value = res.data.data.experimentee
? res.data.data.experimentee.name
: "";
dataArrayNumber.value = 1;
})
.catch((e: any) => {
@ -69,10 +71,10 @@ onMounted(() => {
.finally(() => {
hideLoader();
});
};
}
/** เปลี่ยน type file */
function downloadFile(response: any, filename: string){
function downloadFile(response: any, filename: string) {
const link = document.createElement("a");
var fileName = filename;
link.href = window.URL.createObjectURL(new Blob([response.data]));
@ -80,13 +82,13 @@ function downloadFile(response: any, filename: string){
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
};
}
/**
* download file
* @param type type
*/
async function FileDownload(type: string){
async function FileDownload(type: string) {
let numTab = evaluate.value.find((e: any) => e.no === dataArrayNumber.value);
showLoader();
await http
@ -99,20 +101,20 @@ function downloadFile(response: any, filename: string){
`แบบประเมินผล(ผู้บังคับบัญชา)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
};
}
/** เปลี่ยนหน้า เพิ่ม */
function addData(){
function addData() {
router.push(
`/probation/detail/addevalua/${personalId.value}/${assignId.value}`
);
};
}
</script>
<template>

View file

@ -47,7 +47,9 @@ const fecthAssign = async (id: string) => {
.then(async (res: any) => {
await fecthdataAssign(res.data.data);
evaluate.value = probationStore.evaluate;
fullname.value = res.data.data.experimentee ? res.data.data.experimentee.name : "";
fullname.value = res.data.data.experimentee
? res.data.data.experimentee.name
: "";
tabs.value = evaluate.value;
dataArrayNumber.value = 1;
})
@ -81,8 +83,8 @@ const FileDownload = async (type: string) => {
`แบบประเมินผล(คณะกรรมการ)_${fullname.value}_ครั้งที่${numTab.no}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -357,8 +357,8 @@ const downloadAttachment = async (type: string, id: string) => {
.then(async (res) => {
downloadFile(res, `${"รายชื่อผู้เกษียณอายุราชการ"}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -90,8 +90,8 @@ const fileDownload = async (type: string) => {
`รายละเอียดบันทึกเวียนแจ้งการถึงแก่กรรม-${fullName}.${type}`
);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -403,8 +403,8 @@ const fileDownload = async (type: string, fileName: string) => {
.then(async (res) => {
downloadFile(res, `${fileName}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -54,8 +54,8 @@ async function downloadDocument(type: string) {
);
}
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -126,8 +126,8 @@ const downloadReport = async (
showDocument(url);
}
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -128,8 +128,8 @@ const downloadReport = async (
showDocument(url);
}
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -186,7 +186,7 @@ const filterSelector = (val: any, update: Function, name: any) => {
@filter="(inputValue:any,doneFn:Function) =>
filterSelector(inputValue, doneFn,'selectList') "
>
<template v-slot:no-option>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม

View file

@ -139,8 +139,8 @@ async function genReportXLSX(data: any) {
const blob = new Blob([res.data]);
downloadReport(blob, "xlsx");
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
}

View file

@ -118,8 +118,8 @@ async function genReport(data: any) {
hideLoader();
}, 1500);
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -144,8 +144,8 @@ async function genReportXLSX(data: any) {
const blob = new Blob([res.data]);
downloadReport(blob, "xlsx");
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -129,8 +129,8 @@ const downloadCover = async (type: string) => {
.then(async (res) => {
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -161,8 +161,8 @@ const downloadAttachment = async (type: string) => {
.then(async (res) => {
downloadFile(res, `เอกสารแนบท้าย ${orderName.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -207,14 +207,16 @@ const fetchReportCover = async (type: string, orderId: string) => {
viewPDF(orderCoverPdf.value);
}
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {});
}
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
!genReportStatus.value
? messageError($q, JSON.parse(await e.response.data.text()))
: messageError($q, e);
});
};
//
@ -228,8 +230,8 @@ const fetchReportAttachment = async (type: string, orderId: string) => {
const objectUrl = URL.createObjectURL(blob);
orderAttachmentPdf.value = objectUrl;
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
};

View file

@ -84,8 +84,8 @@ function getPDF(url: string, type: string) {
hideLoader();
}, 1500);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
store.log = 0;
@ -138,7 +138,9 @@ onMounted(async () => {
active-class="text-primary"
@click="handleItemClick(2)"
>
<q-item-section class="q-py-sm">แบบแสดงรายละเอยดการเสนอผลงาน</q-item-section>
<q-item-section class="q-py-sm"
>แบบแสดงรายละเอยดการเสนอผลงาน</q-item-section
>
</q-item>
<q-item
clickable
@ -147,7 +149,8 @@ onMounted(async () => {
active-class="text-primary"
@click="handleItemClick(3)"
>
<q-item-section class="q-py-sm">แบบตรวจสอบความถกตองครบถวนของขอมลเพอประกอบการคดเลอกบคคล
<q-item-section class="q-py-sm"
>แบบตรวจสอบความถกตองครบถวนของขอมลเพอประกอบการคดเลอกบคคล
(เอกสารแบบ )</q-item-section
>
</q-item>
@ -158,7 +161,9 @@ onMounted(async () => {
active-class="text-primary"
@click="handleItemClick(4)"
>
<q-item-section class="q-py-sm"> แบบประเมนคณลกษณะบคคล </q-item-section>
<q-item-section class="q-py-sm">
แบบประเมนคณลกษณะบคคล
</q-item-section>
</q-item>
<q-item
clickable
@ -178,7 +183,9 @@ onMounted(async () => {
active-class="text-primary"
@click="handleItemClick(6)"
>
<q-item-section class="q-py-sm"> ผลงานทจะสงประเม (เอกสารหมายเลข 11) </q-item-section>
<q-item-section class="q-py-sm">
ผลงานทจะสงประเม (เอกสารหมายเลข 11)
</q-item-section>
</q-item>
</q-list>
</template>

View file

@ -159,7 +159,9 @@ async function getPDF(url: string, type: string, fileName: string) {
a.download = fileName;
a.click();
})
.catch((e) => {})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {});
}

View file

@ -86,8 +86,8 @@ function getPDF(url: string, type: string) {
hideLoader();
}, 1500);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
store.log = 0;

View file

@ -145,8 +145,8 @@ const downloadCover = async (type: string) => {
.then(async (res) => {
downloadFile(res, `คำสั่ง ${orderName.value}.${type}`);
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
@ -206,14 +206,16 @@ const fetchReportCover = async (type: string, orderId: string) => {
viewPDF(orderCoverPdf.value);
}
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {});
}
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
!genReportStatus.value
? messageError($q, JSON.parse(await e.response.data.text()))
: messageError($q, e);
});
};
//
@ -227,8 +229,8 @@ const fetchReportAttachment = async (type: string, orderId: string) => {
const objectUrl = URL.createObjectURL(blob);
orderAttachmentPdf.value = objectUrl;
})
.catch((e) => {
messageError($q, e);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
};

View file

@ -212,8 +212,8 @@ function downloadFile(url: string, type: string, fileName: string) {
a.download = fileName;
a.click();
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -174,8 +174,8 @@ async function downloadFile(url: string, type: string, fileName: string) {
a.download = fileName;
a.click();
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();

View file

@ -51,8 +51,8 @@ async function genReportXLSX(
URL.revokeObjectURL(url);
}
})
.catch((err) => {
messageError($q, err);
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();