Refactoring code module 06_evaluate

This commit is contained in:
STW_TTTY\stwtt 2024-09-04 14:52:04 +07:00
parent 4253226ac3
commit d03e3b9e98
22 changed files with 192 additions and 400 deletions

View file

@ -1,20 +1,20 @@
<script setup lang="ts">
import { ref, reactive, watch, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import type { FormRef } from "@/modules/06_evaluate/interface/evalute";
import axios from "axios";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
import { useCounterMixin } from "@/stores/mixin";
const router = useRouter();
const route = useRoute();
import type {
FormRef,
FormCommand,
FormData,
} from "@/modules/06_evaluate/interface/evalute";
const evaluateId = ref<string>(route.params.id as string);
const profile = ref<any>();
const $q = useQuasar();
const mixin = useCounterMixin();
const {
@ -25,36 +25,31 @@ const {
date2Thai,
success,
} = mixin;
const router = useRouter();
const route = useRoute();
interface FormCommand {
commanderFullname: string;
commanderPosition: string;
commanderAboveFullname: string;
commanderAbovePosition: string;
author: string;
subject: string;
assignedPosition: string;
}
const evaluateId = ref<string>(route.params.id as string);
const profile = ref<any>();
/** form ผู้เซ็นเอกสาร*/
const formCommand = reactive<FormCommand>({
commanderFullname: "",
commanderPosition: "",
commanderAboveFullname: "",
commanderAbovePosition: "",
author: "",
subject: "",
commanderFullname: "", //
commanderPosition: "", //
commanderAboveFullname: "", // 1
commanderAbovePosition: "", // 1
author: "", //
subject: "", //
assignedPosition: "",
});
const formData = reactive<any>({
const formData = reactive<FormData>({
id: "",
subject: "",
author: "",
commanderFullname: "",
commanderPosition: "",
commanderAboveFullname: "",
commanderAbovePosition: "",
subject: "", //
author: "", //
commanderFullname: "", //
commanderPosition: "", //
commanderAboveFullname: "", // 1
commanderAbovePosition: "", // 1
});
const downloadFile1 = ref<string>("");
@ -65,12 +60,12 @@ const downloadFile5 = ref<string>("");
const downloadFile6 = ref<string>("");
/** ตัวแปร file*/
const fileEvaluation1 = ref<any>();
const fileEvaluation2 = ref<any>();
const fileEvaluation3 = ref<any>();
const fileEvaluation4 = ref<any>();
const fileEvaluation5 = ref<any>();
const fileEvaluation6 = ref<any>();
const fileEvaluation1 = ref<File | null>();
const fileEvaluation2 = ref<File | null>();
const fileEvaluation3 = ref<File | null>();
const fileEvaluation4 = ref<File | null>();
const fileEvaluation5 = ref<File | null>();
const fileEvaluation6 = ref<File | null>();
const fileEvaluation1Ref = ref<object | null>(null);
const fileEvaluation2Ref = ref<object | null>(null);
@ -98,60 +93,6 @@ const objectRef: FormRef = {
commanderAbovePosition: commanderAbovePositionRef,
};
const files = [
{
id: "file1",
fileName: "แบบพิจารณาคุณสมบัติบุคคล",
pathName: "1-แบบพิจารณาคุณสมบัติบุคคล",
tp: "EV1_005",
templateName: "template-1",
nameFile: "แบบพิจารณาคุณสมบัติบุคคล",
},
{
id: "file2",
fileName: "แบบแสดงรายละเอียดการเสนอผลงาน",
pathName: "2-แบบแสดงรายละเอียดการเสนอผลงาน",
tp: "EV1_006",
templateName: "template-2",
nameFile: "แบบแสดงรายละเอียดการเสนอผลงาน",
},
{
id: "file3",
fileName:
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก)",
pathName:
"3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก)",
tp: "EV1_007",
templateName: "template-3",
nameFile:
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก)",
},
{
id: "file4",
fileName: "แบบประเมินคุณลักษณะบุคคล",
pathName: "4-แบบประเมินคุณลักษณะบุคคล",
tp: "EV1_008",
templateName: "template-4",
nameFile: "แบบประเมินคุณลักษณะบุคคล",
},
{
id: "file5",
fileName: "แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
pathName: "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
tp: "EV1_009",
templateName: "template-5",
nameFile: "แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)",
},
{
id: "file6",
fileName: "ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
pathName: "6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
tp: "EV1_010",
templateName: "template-6",
nameFile: "ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)",
},
];
/**
* function ดาวนโหลดไฟล
* @param fileName อไฟล
@ -169,54 +110,24 @@ async function downloadFile(fileName: string) {
.then((res) => {
if (fileName === "1-แบบพิจารณาคุณสมบัติบุคคล") {
downloadFile1.value = res.data.downloadUrl;
// fileEvaluation1.value = res.data.upload;
} else if (fileName === "2-แบบแสดงรายละเอียดการเสนอผลงาน") {
downloadFile2.value = res.data.downloadUrl;
// fileEvaluation2.value = res.data.upload;
} else if (
fileName ===
"3-แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลเพื่อประกอบการคัดเลือกบุคคล (เอกสารแบบ ก)"
) {
downloadFile3.value = res.data.downloadUrl;
// fileEvaluation3.value = res.data.upload;
} else if (fileName === "4-แบบประเมินคุณลักษณะบุคคล") {
downloadFile4.value = res.data.downloadUrl;
// fileEvaluation4.value = res.data.upload;
} else if (
fileName === "5-แบบสรุปข้อมูลของผู้ขอรับการคัดเลือก (เอกสารหมายเลข 9)"
) {
downloadFile5.value = res.data.downloadUrl;
// fileEvaluation5.value = res.data.upload;
} else if (fileName === "6-ผลงานที่จะส่งประเมิน (เอกสารหมายเลข 11)") {
downloadFile6.value = res.data.downloadUrl;
// fileEvaluation6.value = res.data.upload;
}
})
.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,
performance: performanceRef.value,
performanceOwner: performanceOwnerRef.value,
downloadFile: [
downloadFile1.value,
downloadFile2.value,
downloadFile3.value,
downloadFile4.value,
downloadFile5.value,
downloadFile6.value,
],
statusUpload: false,
};
hideLoader();
});
}
@ -226,9 +137,7 @@ function onSubmit() {
showLoader();
http
.post(config.API.evaluationExpertise, formData)
.then((res) => {
// props.fetchActive?.();
})
.then((res) => {})
.catch((err) => {
messageError($q, err);
})