This commit is contained in:
Warunee Tamkoo 2023-12-23 21:51:15 +07:00
parent 43e36b7b74
commit 6eed463eb5
6 changed files with 313 additions and 190 deletions

View file

@ -50,9 +50,19 @@ async function onClickDowloadFile(
{ positionLevel: profile.value == null ? "" : profile.value.positionLevel },
{ posNo: profile.value == null ? "" : profile.value.posNo },
{ oc: profile.value == null ? "" : profile.value.oc },
{ birthDate: profile.value == null ? "" : date2Thai(profile.value.birthDate) },
{
birthDate:
profile.value == null ? "" : date2Thai(profile.value.birthDate),
},
{ govAge: profile.value == null ? "" : profile.value.govAge },
{ positionLevelNew: profile.value == null ? "" : (profile.value.type == "EXPERT"? "ชำนาญการ":"ชำนาญการพิเศษ")}
{
positionLevelNew:
profile.value == null
? ""
: profile.value.type == "EXPERT"
? "ชำนาญการ"
: "ชำนาญการพิเศษ",
}
);
const body = {
@ -96,6 +106,7 @@ function upLoadFile(name: string, file: any) {
messageError($q, e);
})
.finally(() => {
downloadFileList(name);
hideLoader();
});
}
@ -120,67 +131,84 @@ function fileUpLoad(url: string, file: any) {
});
}
function downloadFile() {
// const fileEdit2 = ref<string>("");
// function downloadFile() {
// showLoader();
// http
// .get(
// config.API.evaluationFilebyId(
// " 2",
// id.value,
// "2- 2 ()"
// )
// )
// .then((res) => {
// fileEdit2.value = res.data.downloadUrl;
// const link = res.data.downloadUrl;
// const type = res.data.fileType;
// const fileName = res.data.fileName;
// getPDF(link, type, fileName);
// })
// .catch((e) => {})
// .finally(() => {
// hideLoader();
// });
// }
// function getPDF(url: string, type: string, fileName: string) {
// axios
// .get(url, {
// method: "GET",
// responseType: "blob",
// headers: {
// "Content-Type": "application/json",
// Accept: type, //
// },
// })
// .then(async (res) => {
// console.log(res);
// const a = document.createElement("a");
// a.href = window.URL.createObjectURL(res.data);
// a.download = fileName;
// // a.download = res.data.fileName + `.${mime.getExtension(res.data.fileType)}`
// a.click();
// })
// .catch((e) => {})
// .finally(() => {});
// }
function confirmApprove() {
const data = {
metadata: {
additionalProp1: nameOfWork.value,
additionalProp2: nameOfOwner.value,
additionalProp3: position.value,
},
};
showLoader();
http
.get(config.API.evaluationFilebyId("เล่ม 2", id.value, '2-เอกสารเล่ม 2 (ฉบับแก้ไข)'))
.patch(
config.API.evaluationPatchData(
"เล่ม 2",
id.value,
"2-เอกสารเล่ม 2 (ฉบับแก้ไข)"
),
data
)
.then((res) => {
const link = res.data.downloadUrl;
const type = res.data.fileType;
const fileName = res.data.fileName;
getPDF(link, type, fileName);
console.log(res);
})
.catch((e) => {
messageError($q, e);
})
.catch((e) => {})
.finally(() => {
nextStep();
modalConfirm.value = false;
hideLoader();
});
}
function getPDF(url: string, type: string, fileName: string) {
axios
.get(url, {
method: "GET",
responseType: "blob",
headers: {
"Content-Type": "application/json",
Accept: type, //
},
})
.then(async (res) => {
console.log(res);
const a = document.createElement("a");
a.href = window.URL.createObjectURL(res.data);
a.download = fileName;
// a.download = res.data.fileName + `.${mime.getExtension(res.data.fileType)}`
a.click();
})
.catch((e) => {})
.finally(() => {});
}
function confirmApprove(){
const data = {
metadata: {
additionalProp1: nameOfWork.value,
additionalProp2: nameOfOwner.value,
additionalProp3: position.value,
},
}
showLoader()
http
.patch(config.API.evaluationPatchData('เล่ม 2',id.value,'2-เอกสารเล่ม 2 (ฉบับแก้ไข)'),data)
.then((res)=>{
console.log(res)
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
nextStep();
modalConfirm.value = false
hideLoader()
})
}
function nextStep(){
function nextStep() {
showLoader();
http
.put(config.API.evaluationNextFinish(id.value))
@ -202,7 +230,7 @@ async function fetchProfile() {
.get(config.API.evaluateGetDetail(id.value))
.then((res) => {
const data = res.data.result;
profile.value =data
profile.value = data;
})
.catch((err) => {
messageError($q, err);
@ -212,9 +240,75 @@ async function fetchProfile() {
});
}
onMounted(()=>{
fetchProfile()
})
const downloadDocEditUrl = ref<string>("");
function checkDocEdit() {
showLoader();
http
.get(
config.API.evaluationPatchData(
"เล่ม 2",
id.value,
"2-เอกสารเล่ม 2 (ฉบับแก้ไข)"
)
)
.then((res: any) => {
downloadDocEditUrl.value = res.data.downloadUrl;
})
// .catch((e) => {
// messageError($q, e);
// })
.finally(() => {
hideLoader();
});
}
const downloadFile1 = ref<string>("");
const downloadFile2 = ref<string>("");
const downloadFile3 = ref<string>("");
const downloadFile4 = ref<string>("");
const downloadFile5 = ref<string>("");
const downloadFile6 = ref<string>("");
async function downloadFileList(fileName: string) {
showLoader();
await http
.get(config.API.evaluationFilebyId("เล่ม 2", id.value, fileName))
.then((res) => {
console.log(res.data);
if (
fileName ===
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลประกอบการประเมินผลงาน (เอกสารแบบ ค)"
) {
downloadFile1.value = res.data.downloadUrl;
} else if (fileName === "บัญชีแสดงการรับ-ส่งผลงาน (เอกสารหมายเลข 15)") {
downloadFile2.value = res.data.downloadUrl;
} else if (fileName === "แบบประเมินผลงาน (เอกสารหมายเลข 16)") {
downloadFile3.value = res.data.downloadUrl;
} else if (fileName === "แบบแสดงการประเมินผลงาน (เอกสารหมายเลข 17)") {
downloadFile4.value = res.data.downloadUrl;
} else if (fileName === "แบบรายงานผลการประเมินบุคคล (เอกสารหมายเลข 18)") {
downloadFile5.value = res.data.downloadUrl;
} else if (fileName === "แบบสรุปผลการประเมิน (เอกสารแบบ ง)") {
downloadFile6.value = res.data.downloadUrl;
}
})
.finally(() => {
hideLoader();
});
}
onMounted(() => {
fetchProfile();
downloadFileList(
"แบบตรวจสอบความถูกต้องครบถ้วนของข้อมูลประกอบการประเมินผลงาน (เอกสารแบบ ค)"
);
downloadFileList("บัญชีแสดงการรับ-ส่งผลงาน (เอกสารหมายเลข 15)");
downloadFileList("แบบประเมินผลงาน (เอกสารหมายเลข 16)");
downloadFileList("แบบแสดงการประเมินผลงาน (เอกสารหมายเลข 17)");
downloadFileList("แบบรายงานผลการประเมินบุคคล (เอกสารหมายเลข 18)");
downloadFileList("แบบสรุปผลการประเมิน (เอกสารแบบ ง)");
checkDocEdit();
});
</script>
<template>
@ -258,13 +352,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation81"
v-if="downloadFile1"
:href="downloadFile1"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation81)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -279,7 +374,6 @@ onMounted(()=>{
lazy-rules
label="อัปโหลดไฟล์"
accept=".pdf"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
@ -336,13 +430,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation82"
v-if="downloadFile2"
:href="downloadFile2"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation82)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -357,7 +452,6 @@ onMounted(()=>{
lazy-rules
label="อัปโหลดไฟล์"
accept=".pdf"
>
<template v-slot:prepend>
<q-icon name="attach_file" />
@ -414,13 +508,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation83"
v-if="downloadFile3"
:href="downloadFile3"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation83)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -491,13 +586,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation84"
v-if="downloadFile4"
:href="downloadFile4"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation84)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -568,13 +664,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation85"
v-if="downloadFile5"
:href="downloadFile5"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation85)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -645,13 +742,14 @@ onMounted(()=>{
</div>
<div class="col-xs-12 col-sm-6 row">
<q-btn
v-if="fileEvaluation86"
v-if="downloadFile6"
:href="downloadFile6"
target="_blank"
class="col-12"
outline
icon="visibility"
label="ดูไฟล์เอกสาร"
color="primary"
@click="onClickViewPDF(fileEvaluation86)"
>
<q-tooltip> ไฟลเอกสาร </q-tooltip></q-btn
>
@ -698,7 +796,7 @@ onMounted(()=>{
</div>
</q-card>
</div>
<div class="col-12">
<div v-if="downloadDocEditUrl != ''" class="col-12">
<q-card bordered style="border: 1px solid #d6dee1">
<div class="text-weight-medium bg-grey-1 q-py-sm q-px-md">
เอกสารเล 2 (ฉบบแกไข)
@ -709,11 +807,12 @@ onMounted(()=>{
<div class="row q-col-gutter-md col-12">
<div class="col-xs-12 col-sm-12 row">
<q-btn
:href="downloadDocEditUrl"
target="_blank"
class="col-12"
icon="download"
label="ดาวน์โหลด"
color="primary"
@click="downloadFile"
>
<q-tooltip> ดาวนโหลดตนแบบ </q-tooltip></q-btn
>