upload file ประเมืน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-05 10:08:00 +07:00
parent 8bef90ab4b
commit 8968086017
4 changed files with 165 additions and 91 deletions

View file

@ -105,32 +105,37 @@ function openConfirmEvalution() {
}
function upLoadFile(name: string, file: any) {
showLoader();
http
.post(config.API.evaluationFileListbyId("เล่ม 2", id.value), {
fileList: {
fileName: name,
metadata: {
tag: "value",
if (file) {
showLoader();
http
.post(config.API.evaluationFileListbyId("เล่ม 2", id.value), {
fileList: {
fileName: name,
metadata: {
tag: "value",
author: author.value,
subject: subject.value,
assignedPosition: assignedPosition.value,
},
},
},
})
.then((res) => {
const foundKey: any = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
const link = res.data[foundKey]?.uploadUrl;
fileUpLoad(link, file);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
downloadFileList(name);
hideLoader();
});
})
.then((res) => {
const foundKey: any = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
const link = res.data[foundKey]?.uploadUrl;
fileUpLoad(link, file);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
downloadFileList(name);
hideLoader();
});
}
}
function fileUpLoad(url: string, file: any) {
@ -337,7 +342,6 @@ async function downloadFileList(fileName: string) {
await http
.get(config.API.evaluationFilebyId("เล่ม 2", id.value, fileName))
.then((res) => {
console.log(res.data);
if (
fileName ===
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลประกอบการประเมินผลงาน (เอกสารแบบ ค)"
@ -360,8 +364,32 @@ async function downloadFileList(fileName: string) {
});
}
const author = ref<string>("");
const subject = ref<string>("");
const assignedPosition = ref<string>("");
async function fetchDataSigner() {
showLoader();
await http
.get(config.API.evaluationSigner(id.value, 2))
.then((res) => {
const data = res.data.result;
author.value = data.authorDoc2;
subject.value = data.subjectDoc2;
assignedPosition.value = data.assignedPosition;
console.log(assignedPosition.value, data);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
onMounted(() => {
fetchProfile();
fetchDataSigner();
downloadFileList(
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลประกอบการประเมินผลงาน (เอกสารแบบ ค)"
);