ประเมินบุคคล => fix bug upload file

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-08-14 12:24:15 +07:00
parent 537277c381
commit 4bbc7c0cf4
4 changed files with 50 additions and 41 deletions

View file

@ -37,8 +37,8 @@ function handleItemClick(itemNumber: number) {
* @param volume index item * @param volume index item
*/ */
function getFile(volume: number) { function getFile(volume: number) {
const fileText = numToThai(volume);
showLoader(); showLoader();
const fileText = numToThai(volume);
http http
.get(config.API.evaluationFilebyId("เล่ม 1", id.value, fileText)) .get(config.API.evaluationFilebyId("เล่ม 1", id.value, fileText))
.then((res) => { .then((res) => {
@ -46,10 +46,8 @@ function getFile(volume: number) {
const type = res.data.fileType; const type = res.data.fileType;
getPDF(link, type); getPDF(link, type);
}) })
.catch(() => { .catch((e) => {
// messageError($q, e); messageError($q, e);
})
.finally(() => {
hideLoader(); hideLoader();
}); });
} }
@ -76,7 +74,6 @@ function getPDF(url: string, type: string) {
const objectUrl = URL.createObjectURL(blob); const objectUrl = URL.createObjectURL(blob);
const pdfData = await usePDF(`${objectUrl}`); const pdfData = await usePDF(`${objectUrl}`);
showLoader();
setTimeout(() => { setTimeout(() => {
store.log = 1; store.log = 1;
store.pdfSrcStore = pdfData.pdf.value; store.pdfSrcStore = pdfData.pdf.value;
@ -84,8 +81,8 @@ function getPDF(url: string, type: string) {
hideLoader(); hideLoader();
}, 1500); }, 1500);
}) })
.catch(async (e) => { .catch(() => {
messageError($q, JSON.parse(await e.response.data.text())); hideLoader();
}) })
.finally(() => { .finally(() => {
store.log = 0; store.log = 0;

View file

@ -265,9 +265,10 @@ async function upLoadFile(file: any) {
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
hideLoader();
}) })
.finally(() => { .finally(() => {
hideLoader(); // hideLoader();
}); });
} }
} }
@ -282,12 +283,13 @@ function fileUpLoad(url: string) {
headers: { "Content-Type": fileEvaluationUpload.value?.type }, headers: { "Content-Type": fileEvaluationUpload.value?.type },
onUploadProgress: (e) => console.log(e), onUploadProgress: (e) => console.log(e),
}) })
.catch((e) => { .then(() => {
messageError($q, e);
})
.finally(() => {
checkDoc10(); checkDoc10();
success($q, "อัปโหลดไฟล์สำเร็จ"); success($q, "อัปโหลดไฟล์สำเร็จ");
})
.catch((e) => {
messageError($q, e);
hideLoader();
}); });
} }
@ -333,6 +335,7 @@ async function checkDoc10() {
) )
.then((res: any) => { .then((res: any) => {
download10Url.value = res.data.downloadUrl; download10Url.value = res.data.downloadUrl;
fetchProfile();
}) })
.catch(() => { .catch(() => {
// messageError($q, e); // messageError($q, e);
@ -340,12 +343,11 @@ async function checkDoc10() {
.finally(() => { .finally(() => {
hideLoader(); hideLoader();
}); });
fetchProfile();
} }
/** function เรียกข้แมูลคุณสมบัติ*/ /** function เรียกข้แมูลคุณสมบัติ*/
async function fetchProfile() { async function fetchProfile() {
showLoader(); // showLoader();
await http await http
.get(config.API.evaluateGetDetail(id.value)) .get(config.API.evaluateGetDetail(id.value))
.then((res) => { .then((res) => {
@ -356,7 +358,7 @@ async function fetchProfile() {
messageError($q, err); messageError($q, err);
}) })
.finally(() => { .finally(() => {
hideLoader(); // hideLoader();
}); });
} }
@ -430,14 +432,14 @@ onMounted(async () => {
</div> </div>
<!-- ประกาศผลการคดเลอกบคคล (เอกสารหมายเลข 10) --> <!-- ประกาศผลการคดเลอกบคคล (เอกสารหมายเลข 10) -->
<div class="col-12" > <div class="col-12">
<q-card bordered style="border: 1px solid #d6dee1"> <q-card bordered style="border: 1px solid #d6dee1">
<div <div
class="text-weight-medium row col-12 bg-grey-1 q-py-sm q-px-md items-center" class="text-weight-medium row col-12 bg-grey-1 q-py-sm q-px-md items-center"
> >
<div>ประกาศผลการคดเลอกบคคล (เอกสารหมายเลข 10)</div> <div>ประกาศผลการคดเลอกบคคล (เอกสารหมายเลข 10)</div>
<q-space /> <q-space />
<div v-if="store.currentStep == 4 "> <div v-if="store.currentStep == 4">
<q-btn <q-btn
icon="download" icon="download"
color="indigo" color="indigo"
@ -473,7 +475,12 @@ onMounted(async () => {
</div> </div>
<div class="col-12" v-if="store.currentStep == 4"><q-separator /></div> <div class="col-12" v-if="store.currentStep == 4"><q-separator /></div>
<div class="row"> <div class="row">
<div class="col-12 q-pa-sm" v-if="store.currentStep == 4 && checkPermission($route)?.attrIsUpdate"> <div
class="col-12 q-pa-sm"
v-if="
store.currentStep == 4 && checkPermission($route)?.attrIsUpdate
"
>
<q-file <q-file
ref="fileEvaluationUploadRef" ref="fileEvaluationUploadRef"
v-model="fileEvaluationUpload" v-model="fileEvaluationUpload"
@ -482,6 +489,7 @@ onMounted(async () => {
dense dense
hide-bottom-space hide-bottom-space
lazy-rules lazy-rules
label="อัปโหลดไฟล์"
accept=".pdf" accept=".pdf"
:rules=" :rules="
download10Url === '' ? [(val) => !!val || 'กรุณาเลือกไฟล์'] : [] download10Url === '' ? [(val) => !!val || 'กรุณาเลือกไฟล์'] : []
@ -508,7 +516,10 @@ onMounted(async () => {
</div> </div>
<!-- ดตอผขอประเม --> <!-- ดตอผขอประเม -->
<div class="col-12" v-if="store.currentStep == 4 && checkPermission($route)?.attrIsUpdate"> <div
class="col-12"
v-if="store.currentStep == 4 && checkPermission($route)?.attrIsUpdate"
>
<div class="q-mt-xs q-gutter-md" align="right"> <div class="q-mt-xs q-gutter-md" align="right">
<q-btn label="ติดต่อผู้ขอประเมิน" color="info" @click="openPopUp" /> <q-btn label="ติดต่อผู้ขอประเมิน" color="info" @click="openPopUp" />
<q-btn <q-btn

View file

@ -117,8 +117,6 @@ function upLoadFile(file: any) {
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
})
.finally(() => {
hideLoader(); hideLoader();
}); });
} }
@ -134,14 +132,15 @@ function fileUpLoad(url: string) {
headers: { "Content-Type": fileEvaluation5.value?.type }, headers: { "Content-Type": fileEvaluation5.value?.type },
onUploadProgress: (e) => console.log(e), onUploadProgress: (e) => console.log(e),
}) })
.then(() => { .then(async () => {
success($q, "อัปโหลดไฟล์สำเร็จ"); await checkDocResult();
await success($q, "อัปโหลดไฟล์สำเร็จ");
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
checkDocResult(); hideLoader();
}); });
} }
@ -197,7 +196,7 @@ async function getDate() {
const download10Url = ref<string>(""); const download10Url = ref<string>("");
/** function เช็คไฟล์อัปโหลด*/ /** function เช็คไฟล์อัปโหลด*/
async function checkDocResult() { async function checkDocResult() {
showLoader(); // showLoader();
await http await http
.get( .get(
config.API.evaluationPatchData( config.API.evaluationPatchData(
@ -213,7 +212,7 @@ async function checkDocResult() {
// messageError($q, e); // messageError($q, e);
}) })
.finally(() => { .finally(() => {
hideLoader(); // hideLoader();
}); });
} }

View file

@ -113,20 +113,18 @@ function upLoadFile(name: string, file: any) {
}, },
}, },
}) })
.then((res) => { .then(async (res) => {
const foundKey: any = Object.keys(res.data).find( const foundKey: any = Object.keys(res.data).find(
(key) => (key) =>
res.data[key]?.fileName !== undefined && res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== "" res.data[key]?.fileName !== ""
); );
const link = res.data[foundKey]?.uploadUrl; const link = res.data[foundKey]?.uploadUrl;
fileUpLoad(link, file); await fileUpLoad(link, file);
await downloadFileList(name);
}) })
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
})
.finally(() => {
downloadFileList(name);
hideLoader(); hideLoader();
}); });
} }
@ -143,11 +141,14 @@ function fileUpLoad(url: string, file: any) {
headers: { "Content-Type": file?.type }, headers: { "Content-Type": file?.type },
onUploadProgress: (e) => console.log(e), onUploadProgress: (e) => console.log(e),
}) })
.then(() => {
success($q, "อัปโหลดไฟล์สำเร็จ");
})
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
success($q, "อัปโหลดไฟล์สำเร็จ"); hideLoader();
}); });
} }
@ -191,6 +192,7 @@ async function confirmApprove() {
dialogConfirm( dialogConfirm(
$q, $q,
() => { () => {
showLoader();
const data = { const data = {
metadata: { metadata: {
additionalProp1: nameOfWork.value, additionalProp1: nameOfWork.value,
@ -198,7 +200,6 @@ async function confirmApprove() {
additionalProp3: position.value, additionalProp3: position.value,
}, },
}; };
showLoader();
http http
.patch( .patch(
config.API.evaluationPatchData( config.API.evaluationPatchData(
@ -208,13 +209,14 @@ async function confirmApprove() {
), ),
data data
) )
.then(() => {}) .then(() => {
nextStep();
modalConfirm.value = false;
})
.catch((e) => { .catch((e) => {
messageError($q, e); messageError($q, e);
}) })
.finally(() => { .finally(() => {
nextStep();
modalConfirm.value = false;
hideLoader(); hideLoader();
}); });
}, },
@ -294,7 +296,7 @@ const downloadFile6 = ref<string>("");
* @param fileName อไฟล * @param fileName อไฟล
*/ */
async function downloadFileList(fileName: string) { async function downloadFileList(fileName: string) {
showLoader(); // showLoader();
await http await http
.get(config.API.evaluationFilebyId("เล่ม 2", id.value, fileName)) .get(config.API.evaluationFilebyId("เล่ม 2", id.value, fileName))
.then((res) => { .then((res) => {
@ -314,10 +316,10 @@ async function downloadFileList(fileName: string) {
} else if (fileName === "แบบสรุปผลการประเมิน (เอกสารแบบ ง)") { } else if (fileName === "แบบสรุปผลการประเมิน (เอกสารแบบ ง)") {
downloadFile6.value = res.data.downloadUrl; downloadFile6.value = res.data.downloadUrl;
} }
})
.finally(() => {
hideLoader();
}); });
// .finally(() => {
// hideLoader();
// });
} }
const author = ref<string>(""); const author = ref<string>("");