From 8968086017b8fcc48cea6e756fc964750d75c879 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 5 Jan 2024 10:08:00 +0700 Subject: [PATCH] =?UTF-8?q?upload=20file=20=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A1=E0=B8=B7=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Detail/step/step4.vue | 77 +++++++++++------ .../components/Detail/step/step5.vue | 83 ++++++++++++------- .../components/Detail/step/step8.vue | 80 ++++++++++++------ .../components/Detail/viewstep/viewStep1.vue | 16 ++-- 4 files changed, 165 insertions(+), 91 deletions(-) diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue index 5ca7768df..ba8ad3746 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step4.vue @@ -220,32 +220,36 @@ function getStep() { }); } -function upLoadFile() { - showLoader(); - http - .post(config.API.evaluationFileListbyId("เล่ม 1", id.value), { - fileList: { - fileName: "10-ประกาศผลการคัดเลือกบุคคล (เอกสารหมายเลข 10)", - metadata: { - tag: "value", +function upLoadFile(file: any) { + if (file) { + showLoader(); + http + .post(config.API.evaluationFileListbyId("เล่ม 1", id.value), { + fileList: { + fileName: "10-ประกาศผลการคัดเลือกบุคคล (เอกสารหมายเลข 10)", + metadata: { + tag: "value", + subject: subject.value, + author: author.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); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - 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); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + } } function fileUpLoad(url: string) { @@ -328,8 +332,29 @@ async function fetchProfile() { }); } +const author = ref(""); +const subject = ref(""); + +function fetchDataSigner() { + showLoader(); + http + .get(config.API.evaluationSigner(id.value, 1)) + .then((res) => { + const data = res.data.result; + author.value = data.author; + subject.value = data.subject; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + onMounted(() => { checkDoc10(); + fetchDataSigner(); }); @@ -443,7 +468,7 @@ onMounted(() => { dense color="primary" icon="mdi-upload " - @click="upLoadFile" + @click="upLoadFile(fileEvaluationUpload)" >อัปโหลดไฟล์ diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step5.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step5.vue index a41fd8159..97e4ae3dc 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step5.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step5.vue @@ -107,32 +107,36 @@ function save() { } } -function upLoadFile() { - showLoader(); - http - .post(config.API.evaluationFileListbyId("เล่ม 1", id.value), { - fileList: { - fileName: "บันทึกแจ้งผลการประกาศคัดเลือก", - metadata: { - tag: "value", +function upLoadFile(file: any) { + if (file) { + showLoader(); + http + .post(config.API.evaluationFileListbyId("เล่ม 1", id.value), { + fileList: { + fileName: "บันทึกแจ้งผลการประกาศคัดเลือก", + metadata: { + tag: "value", + author: author.value, + subject: subject.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); - }) - .catch((e) => { - messageError($q, e); - }) - .finally(() => { - 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); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + } } function fileUpLoad(url: string) { @@ -275,9 +279,30 @@ function checkDocResult() { }); } -onMounted(() => { - getDate(); - checkDocResult(); +const author = ref(""); +const subject = ref(""); + +function fetchDataSigner() { + showLoader(); + http + .get(config.API.evaluationSigner(id.value, 1)) + .then((res) => { + const data = res.data.result; + author.value = data.author; + subject.value = data.subject; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + +onMounted(async () => { + await getDate(); + await checkDocResult(); + await fetchDataSigner(); }); @@ -392,7 +417,7 @@ onMounted(() => { dense color="primary" icon="mdi-upload" - @click="upLoadFile" + @click="upLoadFile(fileEvaluation5)" >อัปโหลดไฟล์ diff --git a/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue b/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue index f3c83cac9..3ac82d7c8 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/step/step8.vue @@ -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(""); +const subject = ref(""); +const assignedPosition = ref(""); + +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( "แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลประกอบการประเมินผลงาน (เอกสารแบบ ค)" ); diff --git a/src/modules/12_evaluatePersonal/components/Detail/viewstep/viewStep1.vue b/src/modules/12_evaluatePersonal/components/Detail/viewstep/viewStep1.vue index 8ab0b9c7b..3dfbb93c3 100644 --- a/src/modules/12_evaluatePersonal/components/Detail/viewstep/viewStep1.vue +++ b/src/modules/12_evaluatePersonal/components/Detail/viewstep/viewStep1.vue @@ -62,12 +62,10 @@ onMounted(() => { formDetail.birthDate = props.data.birthDate && date2Thai(props.data.birthDate); formDetail.govAge = props.data.govAge; - formDetail.educations = props.data.education; + formDetail.educations = props.data.educations; - console.log(props.data.certificate); - - formDetail.certificates = props.data.certificate - ? props.data.certificate.map((e: CertificatesForm) => ({ + formDetail.certificates = props.data.certificates + ? props.data.certificates.map((e: CertificatesForm) => ({ certificateNo: e.certificateNo, certificateType: e.certificateType, expireDate: date2Thai(e.expireDate), @@ -76,8 +74,6 @@ onMounted(() => { })) : []; - console.log(formDetail.certificates); - formDetail.salaries = props.data.salaries ? props.data.salaries.map((e: any) => ({ amount: e.amount, @@ -105,8 +101,8 @@ onMounted(() => { })) : []; - formDetail.trainings = props.data.training - ? props.data.training.map((e: any) => ({ + formDetail.trainings = props.data.trainings + ? props.data.trainings.map((e: any) => ({ dateOrder: date2Thai(e.dateOrder), department: e.department, duration: e.duration, @@ -119,7 +115,7 @@ onMounted(() => { yearly: e.yearly, })) : []; - formDetail.assessments = props.data.assessment; + formDetail.assessments = props.data.assessments; } });