Merge branch 'develop' of https://github.com/Frappet/bma-ehr-frontend into develop

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-10-07 11:53:59 +07:00
commit 82051daa2b
4 changed files with 63 additions and 1097 deletions

View file

@ -1,297 +0,0 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import axios from "axios";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
/** importType*/
import type {
DataOption,
DataDateMonthObject,
} from "@/modules/09_leave/interface/index/Main";
/** importComponents*/
import Header from "@/components/DialogHeader.vue";
/** use*/
const mixin = useCounterMixin();
const $q = useQuasar();
const { date2Thai, monthYear2Thai, dateToISO, messageError } = mixin;
// const apiGenReport =
// "https://report-server.frappet.synology.me/api/v1/report-template/xlsx";
const props = defineProps({
modal: {
type: Boolean,
requier: true,
default: false,
},
close: {
type: Function,
requier: true,
},
});
const loadingBtn = ref<boolean>(true);
const filterType = ref<string>("DAY");
const filterTypeMain = ref<DataOption[]>([
{ id: "DAY", name: "รายวัน" },
{ id: "MONTH", name: "รายเดือน" },
]);
const filterTypeOption = ref<DataOption[]>(filterTypeMain.value);
const date = ref<Date>(new Date());
const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: new Date().getFullYear(),
});
const detailReport = ref<any>();
/** function อัปเดทรายงานสถิติการลา*/
async function updateFilterType() {
filterType.value === "DAY"
? updateDte()
: filterType.value === "MONTH"
? updateMonth()
: false;
}
/** function อัปเดทวัน*/
async function updateDte() {
const body = {
startDate: dateToISO(date.value),
endDate: dateToISO(date.value),
type: filterType.value,
};
fetchReportTimeRecords(body);
}
/** function อัปเดทเดือน*/
async function updateMonth() {
const mount = dateMonth.value.month + 1;
//
const firstDay = new Date(dateMonth.value.year, mount - 1, 1);
//
const lastDay = new Date(dateMonth.value.year, mount, 0);
const body = {
startDate: dateToISO(firstDay),
endDate: dateToISO(lastDay),
type: filterType.value,
};
fetchReportTimeRecords(body);
}
/**
* function เรยกขอมลรายงานสถการลา
* @param body นเรมตนและสนส
*/
async function fetchReportTimeRecords(body: any) {
loadingBtn.value = true;
await http
.post(config.API.leaveReportTimeRecords(), body)
.then((res) => {
const data = res.data.result;
detailReport.value = data;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
setTimeout(() => {
loadingBtn.value = false;
}, 500);
});
}
/**
* function filterOption
* @param val คำคนหา
* @param update functoin
*/
function filterFnOptions(val: any, update: Function) {
update(() => {
filterTypeOption.value = filterTypeMain.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
/**
* function เรยกไฟล XLSX
* @param data อมลรายงานสถการลา
*/
async function genReportXLSX(data: any) {
await axios
.post(`${config.API.reportTemplate}/xlsx`, data, {
headers: {
accept:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"content-Type": "application/json",
},
responseType: "blob",
})
.then(async (res) => {
const blob = new Blob([res.data]);
await downloadReport(blob, "xlsx");
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
}
/**
*
* @param data อมลรายงานสถการลา
* @param type นามสกลไฟล
*/
async function downloadReport(data: any, type: string) {
const link = document.createElement("a");
var fileName = "รายงานสรุปบันทึกการลงเวลาปฏิบัติงาน";
link.href = window.URL.createObjectURL(new Blob([data]));
link.setAttribute("download", `${fileName}.${type}`);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function monthYearThai(val: DataDateMonthObject) {
if (val == null) return "";
else return monthYear2Thai(val.month, val.year);
}
watch(
() => props.modal,
() => {
filterType.value = "DAY";
date.value = new Date();
props.modal && updateFilterType();
}
);
</script>
<template>
<q-dialog v-model="props.modal" persistent>
<q-card style="width: 700px; max-width: 100vw">
<Header :close="props.close" :tittle="'รายงานสถิติการลงเวลา'" />
<q-separator />
<q-card-section class="q-pt-none" style="padding: 0px">
<div class="q-pa-sm q-gutter-y-sm">
<q-toolbar class="q-pa-sm bg-grey-2" style="border-radius: 5px">
<div class="q-pr-xs col-4">
<q-select
class="bg-white"
outlined
dense
v-model="filterType"
:options="filterTypeOption"
emit-value
map-options
option-label="name"
option-value="id"
@update:model-value="updateFilterType"
@filter="(inputValue: any,
doneFn: Function) => filterFnOptions(inputValue, doneFn,)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div class="q-pr-xs col-4" v-if="filterType === 'DAY'">
<datepicker
menu-class-name="modalfix"
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
@update:model-value="updateDte"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="bg-white"
outlined
dense
borderless
:model-value="date ? date2Thai(date) : null"
:label="`${'วันที่'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="q-pr-xs col-4" v-if="filterType === 'MONTH'">
<datepicker
v-model="dateMonth"
:locale="'th'"
autoApply
month-picker
:enableTimePicker="false"
@update:model-value="updateMonth"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="bg-white"
outlined
dense
borderless
:label="`${'เดือน'}`"
:model-value="monthYearThai(dateMonth)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
></q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="q-pr-xs col-4">
<q-btn
:loading="loadingBtn"
:disable="loadingBtn"
color="primary"
icon="download"
label="ดาวน์โหลดรายงาน"
@click="genReportXLSX(detailReport)"
style="width: 100%"
>
<q-tooltip>ดาวนโหลดรายงาน</q-tooltip>
</q-btn>
</div>
</q-toolbar>
</div>
</q-card-section>
</q-card>
</q-dialog>
</template>
<style scoped></style>

View file

@ -1,676 +0,0 @@
<script setup lang="ts">
import { ref, onMounted } from "vue";
import { useQuasar } from "quasar";
import { VuePDF, usePDF } from "@tato30/vue-pdf";
import axios from "axios";
import { useRoute } from "vue-router";
import { useStructureTree } from "@/stores/structureTree";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
import http from "@/plugins/http";
import config from "@/app.config";
import genReportXLSX from "@/plugins/genreportxlsx";
import genReportDocx from "@/plugins/genreport";
import type { DataStructureTree } from "@/interface/main";
import type {
DataOption,
DataDateMonthObject,
} from "@/modules/09_leave/interface/index/Main";
import LoadView from "@/components/LoadView.vue";
const $q = useQuasar();
const route = useRoute();
const {
date2Thai,
monthYear2Thai,
dateToISO,
messageError,
showLoader,
hideLoader,
} = useCounterMixin();
const { fetchStructureTree } = useStructureTree();
/** filter*/
const typeReport = ref<string>("");
const optionReport = ref<DataOption[]>([
{ id: "1", name: "รายงานการเข้างาน" },
{ id: "2", name: "รายงานการเข้างานสาย" },
]);
const employeeClass = ref<string>("officer");
const employeeClassOption = ref<DataOption[]>([
{ id: "officer", name: "ข้าราชการ กทม. สามัญ" },
{ id: "employee", name: "ลูกจ้างประจำ กทม." },
]);
const filterType = ref<string>("DAY");
const filterTypeMain = ref<DataOption[]>([
{ id: "DAY", name: "รายวัน" },
{ id: "WEEKLY", name: "รายสัปดาห์" },
{ id: "MONTH", name: "รายเดือน" },
]);
const filterTypeOption = ref<DataOption[]>(filterTypeMain.value);
const date = ref<Date>(new Date());
const dateWeek = ref<Date[]>(getCurrentWeek());
const dateMonth = ref<DataDateMonthObject>({
month: new Date().getMonth(),
year: new Date().getFullYear(),
});
const isLoadPDF = ref<boolean>(false);
/** tree*/
const filterTree = ref<string>("");
const nodeId = ref<string>("");
const nodeLevel = ref<number>(0);
const node = ref<DataStructureTree[]>([]);
const expanded = ref<string[]>([]);
/** report*/
const numOfPages = ref<number>(0);
const page = ref<number>(1);
const pdfSrc = ref<any>();
const detailReport = ref<any>();
const isReport = ref<boolean>(false);
/** กลับหน้าก่อนหน้าของรายงาน */
function backPage() {
if (page.value !== 1) {
page.value--;
}
}
/** ไปหน้าต่อไปของรายงาน */
function nextPage() {
if (page.value < numOfPages.value) {
page.value++;
}
}
async function fetchDataTree() {
node.value = await fetchStructureTree(route.meta.Key as string, true);
}
function onSelectedNode(id: string, level: number) {
nodeId.value = id;
nodeLevel.value = level;
updateFilterType(filterType.value);
}
/** function อัปเดทรายงานสถิติการลา*/
async function updateFilterType(type: string) {
if (!nodeId.value || !typeReport.value) {
return false;
}
let body = {};
isReport.value = false;
isLoadPDF.value = true;
pdfSrc.value = undefined;
page.value = 1;
switch (type) {
case "DAY":
body = {
startDate: dateToISO(date.value),
endDate: dateToISO(date.value),
type: filterType.value,
nodeId: nodeId.value,
node: nodeLevel.value,
};
break;
case "WEEKLY":
const startOfWeek = new Date(dateWeek.value[0]); // index 0
const endOfWeek = new Date(dateWeek.value[1]);
body = {
startDate: dateToISO(startOfWeek),
endDate: dateToISO(endOfWeek),
type: filterType.value,
nodeId: nodeId.value,
node: nodeLevel.value,
};
break;
case "MONTH":
const mount = dateMonth.value.month + 1;
//
const firstDay = new Date(dateMonth.value.year, mount - 1, 1);
//
const lastDay = new Date(dateMonth.value.year, mount, 0);
body = {
startDate: dateToISO(firstDay),
endDate: dateToISO(lastDay),
type: filterType.value,
nodeId: nodeId.value,
node: nodeLevel.value,
};
break;
default:
break;
}
typeReport.value === "1"
? fetchReportTimeRecords(body)
: fetchReportTimeLate(body);
}
/**
* function เรยกขอมลรายงานการเขางาน
* @param body นเรมตนและสนส
*/
async function fetchReportTimeRecords(body: any) {
await http
.post(config.API.leaveReportTimeRecords(employeeClass.value), body)
.then(async (res) => {
const data = res.data.result;
detailReport.value = data;
isReport.value = data ? true : false;
await fetchDocumentTemplate(data);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
isLoadPDF.value = false;
});
}
/**
* function เรยกขอมลรายงานการเขางานสาย
* @param body นเรมตนและสนส
*/
async function fetchReportTimeLate(body: any) {
await http
.post(config.API.leaveReportTimeLate(employeeClass.value), body)
.then(async (res) => {
const data = res.data.result;
detailReport.value = data;
isReport.value = data ? true : false;
await fetchDocumentTemplate(data);
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
isLoadPDF.value = false;
});
}
/**
* function เรยกไฟล XLSX
* @param data อมลรายงานสถการลา
*/
async function fetchDocumentTemplate(data: any) {
await axios
.post(`${config.API.reportTemplate}/xlsx?`, data, {
headers: {
accept: "application/pdf",
"content-Type": "application/json",
},
responseType: "blob",
})
.then(async (res) => {
const blob = new Blob([res.data]);
const objectUrl = URL.createObjectURL(blob);
const pdfData = await usePDF(`${objectUrl}`);
// PDF
setTimeout(async () => {
pdfSrc.value = pdfData.pdf.value;
numOfPages.value = pdfData.pages.value;
}, 1500);
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
});
}
/**
* function filterOption
* @param val คำคนหา
* @param update functoin
*/
function filterFnOptions(val: string, update: Function) {
update(() => {
filterTypeOption.value = filterTypeMain.value.filter(
(v: DataOption) => v.name.indexOf(val) > -1
);
});
}
function monthYearThai(val: DataDateMonthObject) {
if (val == null) return "";
else return monthYear2Thai(val.month, val.year);
}
function formatWeekDisplay(week: Date[]) {
if (week) {
if (!week[0] || !week[1]) return "";
return `${date2Thai(week[0])} - ${date2Thai(week[1])}`;
}
}
/** ฟังก์ชันคำนวณวันเริ่มต้นและวันสิ้นสุดของสัปดาห์นี้ */
function getCurrentWeek() {
const today = new Date();
const firstDayOfWeek = new Date(today);
firstDayOfWeek.setDate(today.getDate() - today.getDay() + 1); //
const lastDayOfWeek = new Date(today);
lastDayOfWeek.setDate(today.getDate() - today.getDay() + 7); //
return [firstDayOfWeek, lastDayOfWeek];
}
function downloadReport(type: string) {
const fileName =
typeReport.value === "1" ? "รายงานการเข้างาน" : "รายงานการเข้างานสาย";
// if (type === "pdf") {
// genReportDocx(detailReport.value, fileName, type);
// } else {
genReportXLSX(detailReport.value, fileName, type);
// }
}
onMounted(() => {
fetchDataTree();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">
รายงานสถการลงเวลา
</div>
<div class="q-pa-sm q-gutter-sm">
<q-card flat bordered class="col-12">
<div class="row q-col-gutter-sm q-pa-sm">
<div class="row col-12">
<div class="row q-col-gutter-sm">
<q-select
outlined
dense
v-model="employeeClass"
:options="employeeClassOption"
label="ประเภทตำแหน่ง"
emit-value
map-options
option-label="name"
option-value="id"
@update:model-value="updateFilterType(filterType)"
>
</q-select>
</div>
<q-space />
<!-- @click.stop.prevent="
genReportXLSX(
detailReport,
`${
typeReport === '1'
? 'รายงานการเข้างาน'
: 'รายงานการเข้างานสาย'
}`
)
" -->
<q-btn
v-if="checkPermission($route)?.attrIsGet"
flat
:disable="!isReport || !nodeId || !employeeClass"
:loading="isLoadPDF"
round
color="primary"
icon="download"
>
<q-menu>
<q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="downloadReport('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-item clickable v-close-popup @click="downloadReport('xlsx')">
<q-item-section avatar
><q-icon color="green" name="mdi-file-excel"
/></q-item-section>
<q-item-section>ไฟล .xlsx</q-item-section>
</q-item>
</q-list>
</q-menu>
</q-btn>
</div>
<div class="col-12 row">
<q-card bordered class="col-12 filter-card q-pa-sm">
<div class="row col-12 q-col-gutter-sm">
<div class="col-lg-2 col-md-4 col-xs-12">
<q-select
class="bg-white"
hide-bottom-space
outlined
dense
lazy-rules
borderless
v-model="typeReport"
:label="`${'รายงาน'}`"
emit-value
map-options
:options="optionReport"
option-value="id"
option-label="name"
@update:model-value="updateFilterType(filterType)"
/>
</div>
<div class="col-lg-2 col-md-4 col-xs-12" v-if="typeReport">
<q-select
class="bg-white"
outlined
dense
v-model="filterType"
:options="filterTypeOption"
emit-value
map-options
option-label="name"
option-value="id"
@update:model-value="updateFilterType"
@filter="(inputValue: string,
doneFn: Function) => filterFnOptions(inputValue, doneFn,)"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template>
</q-select>
</div>
<div
class="col-lg-2 col-md-4 col-xs-12"
v-if="filterType === 'DAY' && typeReport"
>
<datepicker
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
@update:model-value="updateFilterType('DAY')"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="bg-white"
outlined
dense
borderless
:model-value="date ? date2Thai(date) : null"
:label="`${'วันที่'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div
class="col-lg-2 col-md-4 col-xs-12"
v-if="filterType === 'WEEKLY' && typeReport"
>
<datepicker
v-model="dateWeek"
:locale="'th'"
autoApply
:enableTimePicker="false"
@update:model-value="updateFilterType('WEEKLY')"
week-picker
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="bg-white"
outlined
dense
borderless
:label="`${'รายสัปดาห์'}`"
:model-value="formatWeekDisplay(dateWeek)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
></q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div
class="col-lg-2 col-md-4 col-xs-12"
v-if="filterType === 'MONTH' && typeReport"
>
<datepicker
v-model="dateMonth"
:locale="'th'"
autoApply
month-picker
:enableTimePicker="false"
@update:model-value="updateFilterType('MONTH')"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
class="bg-white"
outlined
dense
borderless
:label="`${'เดือน'}`"
:model-value="monthYearThai(dateMonth)"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
></q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</div>
</q-card>
</div>
</div>
</q-card>
<q-card flat bordered class="col-12">
<q-card-section :horizontal="$q.screen.gt.sm">
<q-card-section class="col-lg-3 col-md-4 col-xs-12 q-gutter-sm">
<div class="col">
<q-input dense outlined v-model="filterTree" label="ค้นหา">
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
</div>
<div class="bg-white tree-container q-pa-xs">
<q-tree
dense
:nodes="node"
node-key="orgTreeId"
label-key="labelName"
v-model:expanded="expanded"
:filter="filterTree.trim()"
no-results-label="ไม่พบข้อมูลที่ค้นหา"
no-nodes-label="ไม่มีข้อมูล"
>
<template v-slot:default-header="prop">
<q-item
@click.stop="
onSelectedNode(prop.node.orgTreeId, prop.node.orgLevel)
"
:active="nodeId === prop.node.orgTreeId"
clickable
active-class="my-list-link text-primary text-weight-medium"
class="row col-12 items-center text-dark q-py-xs q-pl-sm rounded-borders my-list"
>
<div>
<div class="text-weight-medium">
{{ prop.node.orgTreeName }}
</div>
<div class="text-weight-light text-grey-8">
{{ prop.node.orgCode == null ? null : prop.node.orgCode }}
{{
prop.node.orgTreeShortName == null
? null
: prop.node.orgTreeShortName
}}
</div>
</div>
</q-item>
</template>
</q-tree>
</div>
</q-card-section>
<q-separator :vertical="$q.screen.gt.xs" />
<q-card-section class="col-lg-9 col-md-8 col-xs-12 scroll">
<q-splitter
horizontal
style="
height: 65vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
"
before-class="overflow-hidden disable"
separator-class="bg-white disabled"
>
<template v-slot:before>
<div class="q-px-sm">
<div class="row items-start items-center">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
</div>
</template>
<template v-slot:after>
<div class="q-pa-md">
<LoadView v-if="isLoadPDF" />
<VuePDF
v-else
ref="vuePDFRef"
:pdf="pdfSrc"
:page="page"
fit-parent
/>
</div>
</template>
<template v-slot:default>
<div class="q-pa-md">
<div class="row items-start items-center">
<div class="col">
<q-btn
padding="xs"
icon="mdi-chevron-left"
color="grey-2"
text-color="grey-5"
size="md"
class="my-auto"
@click="backPage"
:disable="page == 1"
/>
</div>
<div class="col-12 col-md-auto">
<div class="q-pa-md flex">
หนาท {{ page }} จาก {{ numOfPages }}
</div>
</div>
<div class="col text-right">
<q-btn
padding="xs"
icon="mdi-chevron-right"
color="grey-2"
text-color="grey-5"
size="md"
@click="nextPage"
:disable="page === numOfPages"
/>
</div>
</div>
</div>
</template>
</q-splitter>
</q-card-section>
</q-card-section>
</q-card>
</div>
</template>
<style scoped>
.tree-container {
overflow: auto;
height: 60vh;
border: 1px solid #e6e6e7;
border-radius: 10px;
}
.my-list-link {
color: rgb(118, 168, 222);
border-radius: 5px;
background: #a3d3fb48 !important;
font-weight: 600;
border: 1px solid rgba(175, 185, 196, 0.217);
}
</style>

View file

@ -4,7 +4,6 @@ import { ref } from "vue";
/** import Components */
import Tab1 from "@/modules/09_leave/components/02_WorkList/Tab1.vue";
import Tab2 from "@/modules/09_leave/components/02_WorkList/Tab2.vue";
// import DialogReport from "@/modules/09_leave/components/02_WorkList/DialogReport.vue";
const tab = ref("1");

View file

@ -16,6 +16,7 @@ import config from "@/app.config";
import type { DataStructureTree } from "@/interface/main";
import type {
DataOption,
DataOption2,
DataDateMonthObject,
} from "@/modules/09_leave/interface/index/Main";
@ -54,43 +55,28 @@ const pageName = ref<string>(route.name as string);
const dateWeek = ref<Date[]>(getCurrentWeek());
const date = ref<Date>(new Date());
const typeReport = ref<string>("");
const optionReport = ref<DataOption[]>([]);
const optionReportMain = ref<DataOption[]>(
const typeReport = ref<number | null>(null);
const optionReport = ref<DataOption2[]>([
{
id: 3,
name: "รายงานการเข้างาน",
},
{
id: 4,
name: "รายงานการเข้างานสาย",
},
{ id: 1, name: "รายงานการลางานตามประเภทการลา" },
{
id: 2,
name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ",
},
]);
const optionReportMain = ref<DataOption2[]>(
route.name?.toString() === "reportLeave"
? [
{
id: "3",
name: "รายงานการเข้างาน",
},
{
id: "4",
name: "รายงานการเข้างานสาย",
},
{ id: "1", name: "รายงานการลางานตามประเภทการลา" },
{
id: "2",
name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ",
},
]
? optionReport.value
: route.name?.toString() === "leaveReport"
? [
{ id: "1", name: "รายงานการลางานตามประเภทการลา" },
{
id: "2",
name: "รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ",
},
]
: [
{
id: "3",
name: "รายงานการเข้างาน",
},
{
id: "4",
name: "รายงานการเข้างานสาย",
},
]
? optionReport.value.filter((item) => item.id === 1 || item.id === 2)
: optionReport.value.filter((item) => item.id === 3 || item.id === 4)
);
const employeeClass = ref<string>("officer");
@ -158,7 +144,7 @@ function onSelectedNode(data: any) {
*/
async function updateLeaveday() {
const list =
typeReport.value == "3" || typeReport.value == "4"
typeReport.value == 3 || typeReport.value == 4
? leaveType.value
: yearType.value;
switch (list) {
@ -251,11 +237,11 @@ async function fetchLeaveday(
};
const pathAPI =
typeReport.value === "1"
typeReport.value === 1
? config.API.leaveReportLeaveday(type)
: typeReport.value === "2"
: typeReport.value === 2
? config.API.leaveReportLeave2(type)
: typeReport.value === "3"
: typeReport.value === 3
? config.API.leaveReportTimeRecords(type)
: config.API.leaveReportTimeLate(type);
@ -349,7 +335,7 @@ function clearData() {
nodeId.value = "";
nodeLevel.value = 0;
org.value = "";
typeReport.value = "";
typeReport.value = null;
yearType.value = "FULL";
leaveType.value = "DAY";
pdfSrc.value = undefined;
@ -370,7 +356,7 @@ function onSearch() {
updateLeaveday();
fetchLeaveday(
employeeClass.value,
typeReport.value == "3" || typeReport.value == "4"
typeReport.value == 3 || typeReport.value == 4
? leaveType.value
: yearType.value,
dateStart.value,
@ -389,7 +375,7 @@ function getCurrentWeek() {
}
function updateValue(val: string) {
if (typeReport.value == "3" || typeReport.value == "4") {
if (typeReport.value == 3 || typeReport.value == 4) {
leaveType.value = val;
} else {
yearType.value = val;
@ -409,7 +395,7 @@ const isLoad = ref<boolean>(false);
* @param isName อไฟล
* @param fileType pdf/xlsx
*/
function getReport(isName: string) {
function getReport() {
showLoader();
const body = {
type:
@ -449,7 +435,7 @@ function getReport(isName: string) {
//
const link = document.createElement("a");
link.href = url;
link.download = `${isName}.xlsx`; //
link.download = `${reportName()}.xlsx`; //
document.body.appendChild(link);
link.click();
@ -464,6 +450,19 @@ function getReport(isName: string) {
hideLoader();
});
}
const reportName = () => {
const employeeClassName =
employeeClass.value === "officer"
? " (ข้าราชการ กทม. สามัญ)"
: " (ลูกจ้างประจำ กทม.)";
const reportNameVal =
optionReportMain.value.find((item) => item.id === typeReport.value)?.name ||
"";
return reportNameVal + employeeClassName;
};
onMounted(() => {
fetchDataTree();
});
@ -509,7 +508,7 @@ onMounted(() => {
round
color="primary"
icon="download"
v-if="checkPermission($route)?.attrIsGet && typeReport !== '3'"
v-if="checkPermission($route)?.attrIsGet && typeReport !== 3"
>
<q-menu>
<q-list style="min-width: 150px">
@ -517,23 +516,7 @@ onMounted(() => {
clickable
v-close-popup
@click="
genReportXLSX(
detailReport,
`${
typeReport === '1'
? `รายงานการลางานตามประเภทการลา (${
employeeClass === 'officer'
? 'ข้าราชการ กทม. สามัญ'
: 'ลูกจ้างประจำ กทม.'
})`
: `รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ (${
employeeClass === 'officer'
? 'ข้าราชการ กทม. สามัญ'
: 'ลูกจ้างประจำ กทม.'
})`
}`,
'pdf'
)
genReportXLSX(detailReport, `${reportName()}`, 'pdf')
"
>
<q-item-section avatar
@ -544,24 +527,7 @@ onMounted(() => {
<q-item
clickable
v-close-popup
@click="
genReportXLSX(
detailReport,
`${
typeReport === '1'
? `รายงานการลางานตามประเภทการลา (${
employeeClass === 'officer'
? 'ข้าราชการ กทม. สามัญ'
: 'ลูกจ้างประจำ กทม.'
})`
: `รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ (${
employeeClass === 'officer'
? 'ข้าราชการ กทม. สามัญ'
: 'ลูกจ้างประจำ กทม.'
})`
}`
)
"
@click="genReportXLSX(detailReport, `${reportName()}`)"
>
<q-item-section avatar
><q-icon color="green" name="mdi-file-excel"
@ -577,16 +543,8 @@ onMounted(() => {
round
color="primary"
icon="download"
v-if="checkPermission($route)?.attrIsGet && typeReport == '3'"
@click="
getReport(
`${`รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ (${
employeeClass === 'officer'
? 'ข้าราชการ กทม. สามัญ'
: 'ลูกจ้างประจำ กทม.'
})`}`
)
"
v-if="checkPermission($route)?.attrIsGet && typeReport == 3"
@click="getReport()"
>
</q-btn>
</div>
@ -744,12 +702,12 @@ onMounted(() => {
class="bg-white"
dense
:model-value="
typeReport == '3' || typeReport == '4'
typeReport == 3 || typeReport == 4
? leaveType
: yearType
"
:options="
typeReport == '3' || typeReport == '4'
typeReport == 3 || typeReport == 4
? leaveTypeOptionOption
: yearTypeOptionOption
"
@ -765,8 +723,8 @@ onMounted(() => {
class="col-12"
v-if="
yearType !== 'MONTH' &&
typeReport !== '3' &&
typeReport !== '4'
typeReport !== 3 &&
typeReport !== 4
"
>
<datepicker
@ -805,8 +763,8 @@ onMounted(() => {
class="col-12"
v-if="
yearType !== 'MONTH' &&
typeReport !== '3' &&
typeReport !== '4'
typeReport !== 3 &&
typeReport !== 4
"
>
<datepicker
@ -848,8 +806,8 @@ onMounted(() => {
class="col-12"
v-if="
yearType !== 'MONTH' &&
typeReport !== '3' &&
typeReport !== '4'
typeReport !== 3 &&
typeReport !== 4
"
>
<datepicker
@ -885,15 +843,7 @@ onMounted(() => {
</template>
</datepicker>
</div>
<div
class="col-12"
v-if="
(typeReport == '1' && yearType == 'MONTH') ||
(typeReport == '2' && yearType == 'MONTH') ||
(typeReport == '3' && leaveType == 'MONTH') ||
(typeReport == '4' && leaveType == 'MONTH')
"
>
<div class="col-12" v-if="yearType == 'MONTH'">
<datepicker
v-model="dateMonth"
:locale="'th'"
@ -925,15 +875,7 @@ onMounted(() => {
</template>
</datepicker>
</div>
<div
class="col-12"
v-if="
(typeReport == '1' && yearType == 'WEEKLY') ||
(typeReport == '2' && yearType == 'WEEKLY') ||
(typeReport == '3' && leaveType == 'WEEKLY') ||
(typeReport == '4' && leaveType == 'WEEKLY')
"
>
<div class="col-12" v-if="leaveType == 'WEEKLY'">
<datepicker
v-model="dateWeek"
:locale="'th'"
@ -967,8 +909,8 @@ onMounted(() => {
<div
class="col-12"
v-if="
(leaveType == 'DAY' && typeReport == '3') ||
(leaveType == 'DAY' && typeReport == '4')
(leaveType == 'DAY' && typeReport == 3) ||
(leaveType == 'DAY' && typeReport == 4)
"
>
<datepicker
@ -1008,7 +950,7 @@ onMounted(() => {
<q-separator />
<q-card-actions align="right">
<q-btn
v-if="typeReport !== '3'"
v-if="typeReport !== 3"
dense
class="q-px-md"
label="ค้นหา"
@ -1017,9 +959,7 @@ onMounted(() => {
type="submit"
:disable="
typeReport &&
(typeReport == '2' ||
typeReport == '3' ||
typeReport == '4') &&
(typeReport == 2 || typeReport == 3 || typeReport == 4) &&
org
"
/>
@ -1028,7 +968,7 @@ onMounted(() => {
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 col-xs-12 flex">
<q-splitter
v-if="typeReport !== '3'"
v-if="typeReport !== 3"
disable
v-model="splitterModel"
horizontal