Compare commits

...

6 commits
v1.0.18 ... dev

Author SHA1 Message Date
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
89801e787f Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m18s
2026-05-29 13:55:22 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
a0f0443a55 refactor: downloadBlobFile with direct blob download logic 2026-05-29 13:55:05 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
d022ae189c Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m17s
2026-05-29 11:36:06 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
650de029f3 feat(leave): DownloadFile form leave 2026-05-29 11:35:50 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
423b9f5fe3 Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m31s
2026-05-29 10:55:56 +07:00
DESKTOP-1R2VSQH\Lenovo ThinkPad E490
54c7855b61 feat(leave): display leaveCountApproveCount 2026-05-29 10:55:41 +07:00
4 changed files with 161 additions and 29 deletions

View file

@ -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 { useDataStore } from "@/stores/data";
import genReport from "@/plugins/genreport";
/** import type*/
import type {
@ -16,8 +16,6 @@ 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";
@ -33,7 +31,6 @@ 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 {
@ -411,6 +408,28 @@ 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,
@ -434,10 +453,62 @@ watch(
v-if="props.leaveStatus != 'DELETE'"
style="width: 900px; max-width: 80vw"
>
<DialogHeader
:tittle="`${titleMain} ${titleName}`"
:close="props.onClickClose"
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">
{{ ` ${titleMain} ${titleName}` }}
<q-btn class="q-mr-sm" icon="mdi-download" round color="primary" flat>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip>
<q-menu>
<q-list style="min-width: 100px">
<q-item
clickable
v-close-popup
@click="
onClickDownloadFile(
formData.id,
formData.leaveSubTypeName
? formData.leaveSubTypeName
: formData.leaveTypeName,
'docx',
)
"
>
<q-item-section avatar>
<q-icon color="blue" name="mdi-file-word" />
</q-item-section>
<q-item-section>ไฟล .DOCX</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="
onClickDownloadFile(
formData.id,
formData.leaveSubTypeName
? formData.leaveSubTypeName
: formData.leaveTypeName,
'pdf',
)
"
>
<q-item-section avatar>
<q-icon color="red" name="mdi-file-pdf" />
</q-item-section>
<q-item-section>ไฟล .pdf</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="props.onClickClose?.()"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
<q-separator />
<q-card-section v-if="isLoading">
@ -580,10 +651,62 @@ watch(
</q-card>
<q-card v-if="props.leaveStatus === 'DELETE'" style="min-width: 40vw">
<DialogHeader
:tittle="`${titleMainCancle} ${titleName}`"
:close="props.onClickClose"
<q-toolbar>
<q-toolbar-title class="text-subtitle2 text-bold">
{{ ` ${titleMainCancle} ${titleName}` }}
<q-btn class="q-mr-sm" icon="mdi-download" round color="primary" flat>
<q-tooltip>ดาวนโหลดไฟล</q-tooltip>
<q-menu>
<q-list style="min-width: 100px">
<q-item
clickable
v-close-popup
@click="
onClickDownloadFile(
formData.id,
formData.leaveSubTypeName
? formData.leaveSubTypeName
: formData.leaveTypeName,
'docx',
)
"
>
<q-item-section avatar>
<q-icon color="blue" name="mdi-file-word" />
</q-item-section>
<q-item-section>ไฟล .DOCX</q-item-section>
</q-item>
<q-item
clickable
v-close-popup
@click="
onClickDownloadFile(
formData.id,
formData.leaveSubTypeName
? formData.leaveSubTypeName
: formData.leaveTypeName,
'pdf',
)
"
>
<q-item-section avatar>
<q-icon color="red" name="mdi-file-pdf" />
</q-item-section>
<q-item-section>ไฟล .pdf</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</q-toolbar-title>
<q-btn
icon="close"
unelevated
round
dense
@click="props.onClickClose?.()"
style="color: #ff8080; background-color: #ffdede"
/>
</q-toolbar>
<q-separator />
<q-card-section v-if="isLoading">

View file

@ -43,6 +43,7 @@ interface LeaveItem {
all: number;
use: number;
remain: number;
leaveCountApproveCount: number;
}
interface MainList {

View file

@ -141,12 +141,14 @@ 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));
@ -254,7 +256,7 @@ onMounted(async () => {
</q-knob>
</div>
<div class="col-12 text-center text-weight-medium">
ลาพกผอน
{{ item.text }}
</div>
</div>
<div class="row gt-xs"><q-separator vertical /></div>
@ -262,17 +264,19 @@ onMounted(async () => {
<div class="col-12 row text-dark text-body2 items-center">
<div class="col-12 row q-pa-xs q-px-md row">
<span class="text-grey-7 col-6">ได</span>
<span class="text-weight-bold">{{ item.all }}</span>
<span class="text-weight-bold">{{ item.all }} </span>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row q-pa-xs q-px-md">
<span class="text-grey-7 col-6">ใชไป</span>
<span class="text-weight-bold">{{ item.use }}</span>
<span class="text-weight-bold">{{ item.use }} </span>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 row q-pa-xs q-px-md">
<span class="text-grey-7 col-6">คงเหล</span>
<span class="text-weight-bold">{{ item.remain }}</span>
<span class="text-weight-bold"
>{{ item.remain }} </span
>
</div>
</div>
</div>
@ -294,11 +298,11 @@ onMounted(async () => {
flat
class="shadow-0 col-12 fit row items-center q-px-lg"
>
<div class="text-subtitle2 col-4">ลาปวย</div>
<div class="text-subtitle2 col-4">{{ item.text }}</div>
<div class="text-subtitle2 col-8">
<span class="text-grey-7 q-pr-md">ใชไป</span>
<span class="text-weight-bold">{{ item.use }}</span>
<!-- <span class="text-grey-7 q-pl-md">ลา</span> -->
<span class="text-weight-bold">{{ item.use }} </span>
({{ item.leaveCountApproveCount }} คร)
</div>
</q-card>
</div>
@ -317,11 +321,11 @@ onMounted(async () => {
flat
class="shadow-0 col-12 fit row items-center q-px-lg"
>
<div class="text-subtitle2 col-4">ลากจสวนต</div>
<div class="text-subtitle2 col-4">{{ item.text }}</div>
<div class="text-subtitle2 col-8">
<span class="text-grey-7 q-pr-md">ใชไป</span>
<span class="text-weight-bold">{{ item.use }}</span>
<!-- <span class="text-grey-7 q-pl-md">ลา</span> -->
<span class="text-weight-bold">{{ item.use }} </span>
({{ item.leaveCountApproveCount }} คร)
</div>
</q-card>
</div>

View file

@ -2,7 +2,6 @@ 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;
@ -32,11 +31,16 @@ 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";
await downloadBlobFile({
downloadUrl: url,
fileName: baseName,
});
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);
}
})
.catch((err) => {