diff --git a/src/modules/05_leave/components/DialogDetail.vue b/src/modules/05_leave/components/DialogDetail.vue index 7874515..3333374 100644 --- a/src/modules/05_leave/components/DialogDetail.vue +++ b/src/modules/05_leave/components/DialogDetail.vue @@ -6,7 +6,7 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useLeaveStore } from "@/modules/05_leave/store"; -import genReport from "@/plugins/genreport"; +import { useDataStore } from "@/stores/data"; /** import type*/ import type { @@ -16,6 +16,8 @@ import type { FromCancelDetail, } from "@/modules/05_leave/interface/response/leave"; +import DialogHeader from "@/components/DialogHeader.vue"; +import Workflow from "@/components/Workflow/Main.vue"; import FormLeave from "@/modules/05_leave/components/formDetail/01_SickForm.vue"; import FormChildbirth from "@/modules/05_leave/components/formDetail/04_HelpWifeBirthForm.vue"; import FormHoliday from "@/modules/05_leave/components/formDetail/05_VacationForm.vue"; @@ -31,6 +33,7 @@ import FormCancel from "@/modules/05_leave/components/formDetail/formCancel.vue" const $q = useQuasar(); const dataStore = useLeaveStore(); +const mainStore = useDataStore(); const { convertStatud } = dataStore; const mixin = useCounterMixin(); const { @@ -408,28 +411,6 @@ async function onSubmit() { }); } -/** - * ฟังก์ชันดาวน์โหลดไฟล์ - * @param id รหัสการลา - * @param fileName ชื่อไฟล์ - * @param type ประเภทไฟล์ - */ -async function onClickDownloadFile(id: string, fileName: string, type: string) { - showLoader(); - await http - .get(config.API.leaveReport(id)) - .then(async (res) => { - const data = res.data.result; - await genReport(data, fileName, type); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); -} - /**** ตรวจสอบว่ามีการส่งข้อมูลเข้ามาแล้วเปิด modal */ watch( () => props.modal, @@ -453,62 +434,10 @@ watch( v-if="props.leaveStatus != 'DELETE'" style="width: 900px; max-width: 80vw" > - - - {{ ` ${titleMain} ${titleName}` }} - - ดาวน์โหลดไฟล์ - - - - - - - ไฟล์ .DOCX - - - - - - ไฟล์ .pdf - - - - - - - + @@ -651,62 +580,10 @@ watch( - - - {{ ` ${titleMainCancle} ${titleName}` }} - - ดาวน์โหลดไฟล์ - - - - - - - ไฟล์ .DOCX - - - - - - ไฟล์ .pdf - - - - - - - + diff --git a/src/modules/05_leave/interface/index/main.ts b/src/modules/05_leave/interface/index/main.ts index a63d65d..9551977 100644 --- a/src/modules/05_leave/interface/index/main.ts +++ b/src/modules/05_leave/interface/index/main.ts @@ -43,7 +43,6 @@ interface LeaveItem { all: number; use: number; remain: number; - leaveCountApproveCount: number; } interface MainList { diff --git a/src/modules/05_leave/views/Main.vue b/src/modules/05_leave/views/Main.vue index fcaca35..4e36478 100644 --- a/src/modules/05_leave/views/Main.vue +++ b/src/modules/05_leave/views/Main.vue @@ -141,14 +141,12 @@ async function fetchStatsTable() { value: el.leaveLimit > 0 ? Math.round( - (Number(el.leaveCountApprove) / Number(el.leaveLimit)) * - 100, + (Number(el.leaveCountApprove) / Number(el.leaveLimit)) * 100 ) : 0, all: Number(el.leaveLimit), use: el.leaveCountApprove, remain: Number(el.leaveLimit) - Number(el.leaveCountApprove), - leaveCountApproveCount: el.leaveCountApproveCount, })); }); stat.forEach((item) => itemPie.value.push(...item)); @@ -256,7 +254,7 @@ onMounted(async () => {
- {{ item.text }} + ลาพักผ่อน
@@ -264,19 +262,17 @@ onMounted(async () => {
ได้รับ - {{ item.all }} วัน + {{ item.all }}
ใช้ไป - {{ item.use }} วัน + {{ item.use }}
คงเหลือ - {{ item.remain }} วัน + {{ item.remain }}
@@ -298,11 +294,11 @@ onMounted(async () => { flat class="shadow-0 col-12 fit row items-center q-px-lg" > -
{{ item.text }}
+
ลาป่วย
ใช้ไป - {{ item.use }} วัน - ({{ item.leaveCountApproveCount }} ครั้ง) + {{ item.use }} +
@@ -321,11 +317,11 @@ onMounted(async () => { flat class="shadow-0 col-12 fit row items-center q-px-lg" > -
{{ item.text }}
+
ลากิจส่วนตัว
ใช้ไป - {{ item.use }} วัน - ({{ item.leaveCountApproveCount }} ครั้ง) + {{ item.use }} +
diff --git a/src/modules/08_KPI/views/form.vue b/src/modules/08_KPI/views/form.vue index 2d8e58b..39b06d4 100644 --- a/src/modules/08_KPI/views/form.vue +++ b/src/modules/08_KPI/views/form.vue @@ -9,7 +9,6 @@ import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; import { useKpiDataStore } from "@/modules/08_KPI/store"; -import avatar from "@/assets/avatar_user.jpg"; import type { FormProfile } from "@/modules/08_KPI/interface/request/index"; import type { @@ -108,13 +107,11 @@ async function getAvatar(id: string) { .then(async (res) => { const data = await res.data.result; if (data.avatarName) { - fetchProfile(id, data.avatarName); + await fetchProfile(id, data.avatarName); } }) .catch((e) => { messageError($q, e); - imgProfile.value = avatar; - store.dataEvaluation.avartar = avatar; }) .finally(() => { isLoadAvatar.value = false; @@ -122,16 +119,12 @@ async function getAvatar(id: string) { } /** ดึงข้อมูล เพื่อเก็บรูปโปรไฟล์ */ -function fetchProfile(id: string, avatarName: string) { - http +async function fetchProfile(id: string, avatarName: string) { + await http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) - .then((res) => { + .then(async (res) => { store.dataEvaluation.avartar = res.data.downloadUrl; imgProfile.value = res.data.downloadUrl; - }) - .catch(() => { - imgProfile.value = avatar; - store.dataEvaluation.avartar = avatar; }); } @@ -215,7 +208,7 @@ async function getOrgOp() { name: `${i.prefix}${i.firstName} ${i.lastName}`, })) .find( - (i: EvaOptionType) => i.id == store.dataEvaluation.commanderHighId, + (i: EvaOptionType) => i.id == store.dataEvaluation.commanderHighId ); isLoadCommander.value = false; }) @@ -232,21 +225,21 @@ function filterOption(val: string, update: Function, refData: string) { case "evaluatorIdOp": update(() => { evaluatorIdOp.value = evaluatorIdMainOp.value.filter( - (v: DataOptions) => v.name.indexOf(val) > -1, + (v: DataOptions) => v.name.indexOf(val) > -1 ); }); break; case "commanderIdOp": update(() => { commanderIdOp.value = commanderIdMainOp.value.filter( - (v: DataOptions) => v.name.indexOf(val) > -1, + (v: DataOptions) => v.name.indexOf(val) > -1 ); }); break; case "commanderHighOp": update(() => { commanderHighOp.value = commanderHighMainOp.value.filter( - (v: DataOptions) => v.name.indexOf(val) > -1, + (v: DataOptions) => v.name.indexOf(val) > -1 ); }); break; @@ -285,7 +278,7 @@ function sendToEvaluatore() { } }, "ยืนยันการส่งข้อตกลงให้ผู้ประเมินอนุมัติ", - "ต้องการยืนยันส่งข้อตกลงนี้ให้ผู้ประเมินอนุมัติใช่หรือไม่?", + "ต้องการยืนยันส่งข้อตกลงนี้ให้ผู้ประเมินอนุมัติใช่หรือไม่?" ); } @@ -315,7 +308,7 @@ function sendToEvaluateEvaluatore() { } }, "ยืนยันการส่งให้ผู้ประเมินรายงานผลสำเร็จของงาน", - "ต้องการยืนยันส่งให้ผู้ประเมินรายงานผลสำเร็จของงานใช่หรือไม่?", + "ต้องการยืนยันส่งให้ผู้ประเมินรายงานผลสำเร็จของงานใช่หรือไม่?" ); } @@ -345,7 +338,7 @@ function requireEdit() { } }, "ยืนยันการขอแก้ไขข้อตกลง", - "ต้องการยืนยันการขอแก้ไขข้อตกลงนี้ใช่หรือไม่?", + "ต้องการยืนยันการขอแก้ไขข้อตกลงนี้ใช่หรือไม่?" ); } @@ -418,7 +411,7 @@ async function goToSummary() { store.excusiveIndicator2ScoreVal + store.competencyScoreVal ).toFixed(2), - }, + } ) .then((res) => {}); @@ -434,7 +427,7 @@ async function goToSummary() { }); }, "ยืนยันการส่งไปสรุปผลการประเมิน", - "ต้องการยืนยันส่งไปสรุปผลการประเมินใช่หรือไม่?", + "ต้องการยืนยันส่งไปสรุปผลการประเมินใช่หรือไม่?" ); } @@ -524,7 +517,7 @@ async function downloadReport() { store.dataEvaluation.prefix + store.dataEvaluation.firstName + " " + - store.dataEvaluation.lastName, + store.dataEvaluation.lastName ); }) .catch((e) => { @@ -563,7 +556,7 @@ async function clickUpload(file: any) { const foundKey: string | undefined = Object.keys(res.data).find( (key) => res.data[key]?.fileName !== undefined && - res.data[key]?.fileName !== "", + res.data[key]?.fileName !== "" ); foundKey && uploadFileDoc(res.data[foundKey]?.uploadUrl, fileUpload.value); @@ -573,7 +566,7 @@ async function clickUpload(file: any) { }); }, "ยืนยันการอัปโหลดไฟล์", - "ต้องการยืนยันการอัปโหลดไฟล์นี้หรือไม่ ?", + "ต้องการยืนยันการอัปโหลดไฟล์นี้หรือไม่ ?" ); } @@ -630,7 +623,7 @@ function deleteFile(fileName: string) { showLoader(); http .delete( - config.API.file("แบบกำหนดข้อตกลง", "KPI", id.value) + `/${fileName}`, + config.API.file("แบบกำหนดข้อตกลง", "KPI", id.value) + `/${fileName}` ) .catch((e) => { messageError($q, e); diff --git a/src/modules/10_registry/05_Other/02_File.vue b/src/modules/10_registry/05_Other/02_File.vue index bb9f287..1be029f 100644 --- a/src/modules/10_registry/05_Other/02_File.vue +++ b/src/modules/10_registry/05_Other/02_File.vue @@ -6,7 +6,6 @@ import { ref, onMounted, watch } from "vue"; import http from "@/plugins/http"; import config from "@/app.config"; import { useRegistryInFormationStore } from "@/modules/10_registry/store/registry"; -import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile"; import type { FileFormType } from "@/modules/10_registry/interface/index/Main"; @@ -58,10 +57,18 @@ async function downloadFile(fileName: string) { ) .then(async (res) => { const downloadUrl = res.data.downloadUrl; - await downloadBlobFile({ - downloadUrl: downloadUrl, - fileName: fileName, - }); + const response = await fetch(downloadUrl); + const blob = await response.blob(); + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = fileName; + document.body.appendChild(link); + link.click(); + setTimeout(() => { + document.body.removeChild(link); + URL.revokeObjectURL(url); + }, 100); }) .catch((e) => { messageError($q, e); diff --git a/src/modules/10_registry/05_Other/03_FileOther.vue b/src/modules/10_registry/05_Other/03_FileOther.vue index 585e68c..05e740b 100644 --- a/src/modules/10_registry/05_Other/03_FileOther.vue +++ b/src/modules/10_registry/05_Other/03_FileOther.vue @@ -6,7 +6,6 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import { useRegistryInFormationStore } from "@/modules/10_registry/store/registry"; -import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile"; import type { FileFormType } from "@/modules/10_registry/interface/index/Main"; @@ -58,10 +57,18 @@ async function downloadFile(fileName: string) { ) .then(async (res) => { const downloadUrl = res.data.downloadUrl; - await downloadBlobFile({ - downloadUrl: downloadUrl, - fileName: fileName, - }); + const response = await fetch(downloadUrl); + const blob = await response.blob(); + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + link.href = url; + link.download = fileName; + document.body.appendChild(link); + link.click(); + setTimeout(() => { + document.body.removeChild(link); + URL.revokeObjectURL(url); + }, 100); }) .catch((e) => { messageError($q, e); diff --git a/src/modules/10_registry/utils/downloadFile.ts b/src/modules/10_registry/utils/downloadFile.ts index 99c06c5..341b7f9 100644 --- a/src/modules/10_registry/utils/downloadFile.ts +++ b/src/modules/10_registry/utils/downloadFile.ts @@ -49,8 +49,7 @@ export async function downloadBlobFile({ const url = URL.createObjectURL(blobForDownload); const link = document.createElement("a"); link.href = url; - const downloadFileName = fileName.includes(".") ? fileName : `${fileName}.${extension}`; - link.download = downloadFileName; + link.download = `${fileName}.${extension}`; document.body.appendChild(link); link.click(); setTimeout(() => { diff --git a/src/modules/11_probation/views/mainDetail.vue b/src/modules/11_probation/views/mainDetail.vue index a4584c0..cd6b60c 100644 --- a/src/modules/11_probation/views/mainDetail.vue +++ b/src/modules/11_probation/views/mainDetail.vue @@ -151,7 +151,6 @@ async function getAvatar(id: string) { }) .catch((e) => { messageError($q, e); - profileImg.value = avatar; }); } @@ -169,15 +168,14 @@ function getList(id: string) { }); } -function getImg(id: string, pathName: string) { - http +async function getImg(id: string, pathName: string) { + await http .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) .then((res) => { profileImg.value = res.data.downloadUrl; }) .catch((e) => { - profileImg.value = avatar; - // messageError($q, e); + messageError($q, e); hideLoader(); }); } @@ -190,7 +188,7 @@ function onSearch() { rows.value = onSearchDataTable( filter.value, rowsData.value, - columns.value ? columns.value : [], + columns.value ? columns.value : [] ); } diff --git a/src/plugins/genreport.ts b/src/plugins/genreport.ts index 500dca4..520ec00 100644 --- a/src/plugins/genreport.ts +++ b/src/plugins/genreport.ts @@ -19,7 +19,7 @@ async function genReport(data: any, fileName: string, type: string = "docx") { }, responseType: "arraybuffer", }) - .then(async (res) => { + .then((res) => { const responseData = res.data; if (responseData) { const mimeType = @@ -32,11 +32,13 @@ async function genReport(data: any, fileName: string, type: string = "docx") { const baseName = fileName.trim(); const extension = type === "docx" ? "docx" : "pdf"; + const link = document.createElement("a"); link.href = url; link.download = `${baseName}.${extension}`; document.body.appendChild(link); link.click(); + setTimeout(() => { document.body.removeChild(link); URL.revokeObjectURL(url); diff --git a/src/views/MainLayout.vue b/src/views/MainLayout.vue index 331dbe8..165bf6e 100644 --- a/src/views/MainLayout.vue +++ b/src/views/MainLayout.vue @@ -74,7 +74,7 @@ async function checkUser() { await dataStore.getProFileType(); kpiDataStore.dataProfile = data; // Set dataProfile in kpiDataStore if (data.avatarName) { - getImg(data.profileId, data.avatarName); + await getImg(data.profileId, data.avatarName); } else { dataStore.profileImg = avatar; } @@ -106,9 +106,6 @@ function getImg(id: string, pathName: string) { .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, pathName)) .then((res) => { dataStore.profileImg = res.data.downloadUrl; - }) - .catch(() => { - dataStore.profileImg = avatar; }); }