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/plugins/genreport.ts b/src/plugins/genreport.ts index 500dca4..19e2856 100644 --- a/src/plugins/genreport.ts +++ b/src/plugins/genreport.ts @@ -2,6 +2,7 @@ import axios from "axios"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; +import { downloadBlobFile } from "@/modules/10_registry/utils/downloadFile"; const mixin = useCounterMixin(); const { showLoader, hideLoader } = mixin; @@ -31,16 +32,11 @@ async function genReport(data: any, fileName: string, type: string = "docx") { const url = URL.createObjectURL(blob); 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); - }, 100); + // const extension = type === "docx" ? "docx" : "pdf"; + await downloadBlobFile({ + downloadUrl: url, + fileName: baseName, + }); } }) .catch((err) => {