หน้ารายการประเมิน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-01-03 17:03:25 +07:00
parent 0b4a87e293
commit 9f247273c1
12 changed files with 334 additions and 89 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, onMounted, reactive } from "vue";
import { ref, watch, onMounted, reactive } from "vue";
import { useRouter, useRoute } from "vue-router";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import { useQuasar } from "quasar";
@ -51,8 +51,8 @@ const fileEvaluation3Ref = ref<object | null>(null);
const fileEvaluation4Ref = ref<object | null>(null);
const fileEvaluation5Ref = ref<object | null>(null);
const fileEvaluation6Ref = ref<object | null>(null);
const performanceRef = ref<object | null>(null);
const performanceOwnerRef = ref<object | null>(null);
const performanceRef = ref<any>(null);
const performanceOwnerRef = ref<any>(null);
/**
* function updateFormref
@ -70,6 +70,14 @@ function updateInput(val: any) {
fileEvaluation4Ref: fileEvaluation4Ref.value,
fileEvaluation5Ref: fileEvaluation5Ref.value,
fileEvaluation6Ref: fileEvaluation6Ref.value,
downloadFile: [
downloadFile1.value,
downloadFile2.value,
downloadFile3.value,
downloadFile4.value,
downloadFile5.value,
downloadFile6.value,
],
};
emit("update:form", val, ref); //
}
@ -212,29 +220,43 @@ async function fetchPathUpload(
type: string,
file: any
) {
const body = {
fileList: { fileName: type, metadata: {} },
};
performanceRef.value.validate();
performanceOwnerRef.value.validate();
if (id && file) {
showLoader();
await http
.post(config.API.loadPathDocument(volume, id), body)
.then((res) => {
const foundKey: string | undefined = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
foundKey && uploadfile(res.data[foundKey]?.uploadUrl, file);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
downloadFile(type);
hideLoader();
});
if (
performanceRef.value.hasError === false &&
performanceOwnerRef.value.hasError === false
) {
const body = {
fileList: {
fileName: type,
metadata: {
subject: performance.value,
author: performanceOwner.value,
},
},
};
if (id && file) {
showLoader();
await http
.post(config.API.loadPathDocument(volume, id), body)
.then((res) => {
const foundKey: string | undefined = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
foundKey && uploadfile(res.data[foundKey]?.uploadUrl, file);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
downloadFile(type);
hideLoader();
});
}
}
}
@ -311,6 +333,7 @@ const downloadFile3 = ref<string>("");
const downloadFile4 = ref<string>("");
const downloadFile5 = ref<string>("");
const downloadFile6 = ref<string>("");
const emptyValues = ref<any>();
/**
* function ดาวนโหลดไฟล
* @param fileName อไฟล
@ -346,29 +369,53 @@ async function downloadFile(fileName: string) {
}
})
.finally(() => {
const ref = {
commanderFullnameRef: commanderFullnameRef.value,
commanderPositionRef: commanderPositionRef.value,
commanderAboveFullnameRef: commanderAboveFullnameRef.value,
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
fileEvaluation2Ref: fileEvaluation2Ref.value,
fileEvaluation3Ref: fileEvaluation3Ref.value,
fileEvaluation4Ref: fileEvaluation4Ref.value,
fileEvaluation5Ref: fileEvaluation5Ref.value,
fileEvaluation6Ref: fileEvaluation6Ref.value,
downloadFile: [
downloadFile1.value,
downloadFile2.value,
downloadFile3.value,
downloadFile4.value,
downloadFile5.value,
downloadFile6.value,
],
};
emptyValues.value = ref.downloadFile.filter((e: any) => e === "");
// if (emptyValues.value.length < 6) {
// console.log("There are empty values in the array.");
// }
emit("update:form", formCommand, ref);
hideLoader();
});
}
const statusUpload = ref<boolean>(false);
function onClickCheckUploadStatus() {
statusUpload.value = true;
}
/**lifecycle Hooks*/
onMounted(async () => {
const ref = {
commanderFullnameRef: commanderFullnameRef.value,
commanderPositionRef: commanderPositionRef.value,
commanderAboveFullnameRef: commanderAboveFullnameRef.value,
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
fileEvaluation2Ref: fileEvaluation2Ref.value,
fileEvaluation3Ref: fileEvaluation3Ref.value,
fileEvaluation4Ref: fileEvaluation4Ref.value,
fileEvaluation5Ref: fileEvaluation5Ref.value,
fileEvaluation6Ref: fileEvaluation6Ref.value,
};
if (keycloak.tokenParsed != null) {
performanceOwner.value = keycloak.tokenParsed.name;
}
if (store.currentStep > 2) {
fetcheSigner(evaluateId.value);
}
fetchCheckSpec(evaluateId.value);
emit("update:form", formCommand, ref);
downloadFile("1-แบบพิจารณาคุณสมบัติบุคคล");
downloadFile("2-แบบแสดงรายละเอียดการเสนอผลงาน");
downloadFile(
@ -378,6 +425,33 @@ onMounted(async () => {
downloadFile("5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)");
downloadFile("6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)");
});
watch(
() => store.checkFileupload,
() => {
const fileEvaluationValues = [
fileEvaluation1,
fileEvaluation2,
fileEvaluation3,
fileEvaluation4,
fileEvaluation5,
fileEvaluation6,
];
const downloadFileValues = [
downloadFile1,
downloadFile2,
downloadFile3,
downloadFile4,
downloadFile5,
downloadFile6,
];
for (let i = 0; i < downloadFileValues.length; i++) {
if (downloadFileValues[i].value === "") {
fileEvaluationValues[i].value = null;
}
}
}
);
</script>
<template>
@ -394,9 +468,12 @@ onMounted(async () => {
<!-- <div class="text-weight-medium q-py-sm">
งคบบญชาชนต
</div> -->
<div class="row col-12 q-col-gutter-md q-pa-sm">
<q-input
:readonly="store.currentStep != 2"
:readonly="
store.currentStep != 2 || emptyValues?.length < 6
"
ref="performanceRef"
dense
class="col-xs-12 col-sm-6"
@ -408,7 +485,9 @@ onMounted(async () => {
lazy-rules
/>
<q-input
:readonly="store.currentStep != 2"
:readonly="
store.currentStep != 2 || emptyValues?.length < 6
"
ref="performanceOwnerRef"
class="col-xs-12 col-sm-6"
dense
@ -422,6 +501,14 @@ onMounted(async () => {
</div>
</div>
</div>
<!-- <div align="right">
<q-btn
unelevated
label="อัปโหลไฟล์"
color="public"
@click="onClickCheckUploadStatus"
/>
</div> -->
</div>
</div>
</q-card>

View file

@ -61,10 +61,13 @@ async function downloadFile(url: string) {
},
})
.then((res) => {
console.log(url);
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
console.log(objectUrl);
emit("update:file", objectUrl);
emit("update:file", objectUrl, url);
})
.catch((err) => {
messageError($q, err);

View file

@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, reactive, onMounted } from "vue";
import { ref, reactive, watch, onMounted } from "vue";
import keycloak from "@/plugins/keycloak";
import { useRoute } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
@ -28,6 +29,11 @@ const pdfSrc = ref<any>();
const performance = ref<string>("");
const performanceOwner = ref<string>("");
const position = ref<string>("");
const performanceRef = ref<object | null>(null);
const performanceOwnerRef = ref<object | null>(null);
const positionRef = ref<object | null>(null);
const formCommand = reactive<FormCommand>({
commanderFullname: "",
@ -55,6 +61,7 @@ const updateInput = (value: any) => {
commanderAboveFullnameRef: commanderAboveFullnameRef.value,
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
downloadFile: [downloadUrl.value],
};
emit("update:form", value, ref);
};
@ -66,14 +73,14 @@ async function fetchPathUpload(
file: any
) {
const body = {
fileList: { fileName: type, metadata: {} },
// "1-",
// "2-",
// "3- ( .)",
// "4-",
// "5- ( 9)",
// "6- ( 11)",
fileList: {
fileName: type,
metadata: {
subject: performance.value,
author: performanceOwner.value,
position: position.value
},
},
};
if (id && file) {
showLoader();
@ -105,6 +112,7 @@ async function uploadfile(uploadUrl: string, file: any) {
},
})
.then(() => {
checkDoc();
success($q, "อัปโหลไฟล์สำเร็จ");
})
.catch((err) => {
@ -152,18 +160,15 @@ async function fetchCheckDate() {
}
onMounted(async () => {
const ref = {
commanderFullnameRef: commanderFullnameRef.value,
commanderPositionRef: commanderPositionRef.value,
commanderAboveFullnameRef: commanderAboveFullnameRef.value,
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
};
if (keycloak.tokenParsed != null) {
performanceOwner.value = keycloak.tokenParsed.name;
}
checkDoc();
if (store.currentStep > 2) {
fetcheSigner(evaluateId.value);
}
await fetchCheckDate();
emit("update:form", formCommand, ref);
// props.evaluateId && (await fetchPathUpload(" 2", props.evaluateId));
});
@ -172,7 +177,7 @@ function checkDoc() {
showLoader();
http
.get(
config.API.loadFileDocument("เล่ม 2", store.evaluateId, "1-เอกสารเล่ม 2")
config.API.loadFileDocument("เล่ม 2", evaluateId.value, "1-เอกสารเล่ม 2")
)
.then((res: any) => {
downloadUrl.value = res.data.downloadUrl;
@ -182,12 +187,29 @@ function checkDoc() {
// })
.finally(() => {
hideLoader();
const ref = {
commanderFullnameRef: commanderFullnameRef.value,
commanderPositionRef: commanderPositionRef.value,
commanderAboveFullnameRef: commanderAboveFullnameRef.value,
commanderAbovePositionRef: commanderAbovePositionRef.value,
fileEvaluation1Ref: fileEvaluation1Ref.value,
downloadFile: [downloadUrl.value],
};
emit("update:form", formCommand, ref);
});
}
onMounted(() => {
checkDoc();
});
watch(
() => store.checkFileupload,
() => {
downloadUrl.value === ""
? (fileEvaluation1.value = "")
: fileEvaluation1.value;
}
);
// onMounted(() => {});
</script>
<template>
@ -214,7 +236,7 @@ onMounted(() => {
</div> -->
<div class="row col-12 q-col-gutter-md q-pa-sm">
<q-input
:readonly="store.currentStep != 2"
:readonly="store.currentStep != 6"
ref="performanceRef"
dense
class="col-xs-12 col-sm-6"
@ -226,7 +248,7 @@ onMounted(() => {
lazy-rules
/>
<q-input
:readonly="store.currentStep != 2"
:readonly="store.currentStep != 6"
ref="performanceOwnerRef"
class="col-xs-12 col-sm-6"
dense
@ -237,6 +259,20 @@ onMounted(() => {
:rules="[(val) => !!val || `${'กรุณากรอกเจ้าของผลงาน'}`]"
lazy-rules
/>
<q-input
:readonly="store.currentStep != 6"
ref="positionRef"
class="col-xs-12 col-sm-6"
dense
outlined
v-model="position"
@update:model-value="updateInput(formCommand)"
label="ตำแหน่งที่ได้รับ"
:rules="[
(val) => !!val || `${'กรุณากรอกตำแหน่งที่ได้รับ'}`,
]"
lazy-rules
/>
</div>
</div>
</div>

View file

@ -59,7 +59,7 @@ async function downloadFile(url: string) {
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
emit("update:file", objectUrl);
emit("update:file", objectUrl, url);
})
.catch((err) => {
messageError($q, err);