ปรับ ui รายงาน

This commit is contained in:
setthawutttty 2025-03-14 17:01:50 +07:00
parent ebb5d0e65f
commit 8a6d34a02f
10 changed files with 4166 additions and 3079 deletions

View file

@ -6,7 +6,7 @@ import config from "@/app.config";
import http from "@/plugins/http";
import axios from "axios";
import genReport from "@/plugins/genreport";
import LoadView from "@/components/LoadView.vue";
/**
* importType
*/
@ -43,13 +43,15 @@ const route = useRoute();
/**
* วแปรงาน
*/
const fullNameShow = ref<string>("");
const isLoadPDF = ref<boolean>(false);
const year = ref<number | null>(new Date().getFullYear());
const round = ref<string>("");
const organization = ref<string>("");
const roundOp = ref<DataOption[]>([]);
const organizationOpsMain = ref<DataOption[]>([]);
const organizationOps = ref<DataOption[]>([]);
const typeReport = ref<string>("");
const typeReport = ref<string>("KPI1");
const listReportMain = ref<DataOption[]>([
{
id: "KPI1",
@ -88,7 +90,7 @@ const listReportMain = ref<DataOption[]>([
name: "จัดทำประกาศผู้มีผลการปฏิบัติราชการระดับดีเด่นและดีมาก",
},
]);
const listReport = ref<DataOption[]>([]); //
const listReport = ref<DataOption[]>(listReportMain.value); //
/**
* funtion fetchขอมลรอบการประเม
@ -170,6 +172,7 @@ function fetchListOrg(id: string) {
* function fetch รายงาน
*/
function fetchReport() {
isLoadPDF.value = true;
showLoader();
const body = {
type: typeReport.value,
@ -180,12 +183,14 @@ function fetchReport() {
http
.post(config.API.kpiReport(), body)
.then((res) => {
isLoadPDF.value = false;
dataDownload.value = res.data.result;
page.value = 1;
genPDf(res.data.result);
})
.catch((err) => {
messageError($q, err);
isLoadPDF.value = false;
hideLoader();
});
}
@ -462,8 +467,12 @@ function fetchListPerson() {
* functiuon เลอกราชช
* @param id profile ID
*/
function onSelectPerson(id: string) {
persanalId.value = id;
function onSelectPerson(data: any) {
persanalId.value = data.id;
fullNameShow.value = `${data.prefix ?? ""}${data.firstName ?? ""} ${
data.lastName ?? ""
}`;
onCloseModal();
fetchReport();
}
@ -484,6 +493,14 @@ watch(
}
);
function clearFilter() {
organization.value = "";
year.value = new Date().getFullYear();
typeReport.value = "KPI1";
pdfSrc.value = undefined;
dataDownload.value = undefined;
fullNameShow.value = "";
}
onMounted(() => {
fetchRoundOption();
fetchActiveId();
@ -491,77 +508,353 @@ onMounted(() => {
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">รายงาน</div>
<div class="toptitle text-dark col-12 row items-center">
รายงานประเมนผลการปฏราชการระดบบคคล
</div>
<q-form greedy @submit.prevent @validation-success="fetchReport">
<div class="row q-col-gutter-sm">
<div class="col-12">
<q-card class="q-pa-sm">
<div class="row q-col-gutter-sm no-wrap">
<q-select
:readonly="!checkPermission($route)?.attrIsGet"
dense
style="min-width: 550px"
hide-bottom-space
outlined
option-label="name"
option-value="id"
emit-value
map-options
v-model="typeReport"
:options="listReport"
label="รายงาน"
use-input
hide-selected
fill-input
@update:model-value="changOption"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn ,'typereport')"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
<q-space />
<div>
<q-btn
v-if="checkPermission($route)?.attrIsGet"
flat
round
color="primary"
icon="download"
:disable="!dataDownload"
>
<q-menu>
<q-list style="min-width: 150px">
<q-item
clickable
v-close-popup
@click="downloadReport(dataDownload, '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(dataDownload, '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-list>
</q-menu>
</q-btn>
</div>
</div>
</q-card>
</div>
<div class="col-12">
<q-card class="q-pa-sm">
<div class="row q-col-gutter-sm">
<div class="col">
<q-card flat bordered>
<q-card-section
bordered
class="bg-primary text-subtitle2 text-white q-pa-sm row items-center"
>
<q-icon name="mdi-filter" class="q-mr-xs" />
วกรอง
<q-space />
<q-btn
dense
size="12px"
class="q-px-sm"
rounded
flat
label="ล้างทั้งหมด"
@click.stop.pervent="clearFilter"
/>
</q-card-section>
<q-card-section class="q-pa-none">
<div
class="row"
v-if="
typeReport === 'KPI1' ||
typeReport === 'KPI2' ||
typeReport === 'KPI3' ||
typeReport === 'KPI7' ||
typeReport === 'KPI8' ||
typeReport === 'KPI9'
"
>
<div class="col-12 q-px-sm">
<datepicker
menu-class-name="modalfix"
v-model="year"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="fetchRoundOption()"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
borderless
hide-bottom-space
:model-value="!!year ? year + 543 : null"
:label="`${'ปีงบประมาณ'}`"
class="bg-white"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-12"><q-separator/></div>
<div class="col-12 q-px-sm">
<q-select
ref="roundRef"
class="bg-white"
v-model="round"
label="รอบการประเมิน"
dense
borderless
hide-bottom-space
option-label="name"
option-value="id"
:options="roundOp"
style="min-width: 150px"
emit-value
map-options
:disable="roundOp.length === 0"
@update:model-value="changOption(typeReport)"
lazy-rules
:rules="
typeReport === 'KPI8'
? [(val:string) => !!val || 'กรุณาเลือกรอบการประเมิน']
: []
"
/>
</div>
<div class="col-12"><q-separator/></div>
<div class="col-12 q-pb-xs q-px-sm" v-if="typeReport !== 'KPI8'">
<q-select
class="bg-white"
:disable="roundOp.length === 0"
dense
borderless
hide-selected
fill-input
hide-bottom-space
option-label="name"
option-value="id"
emit-value
map-options
v-model="organization"
:options="organizationOps"
label="หน่วยงาน"
use-input
@update:model-value="changOption(typeReport)"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn,'organization' )"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey">
ไมอม
</q-item-section>
</q-item>
</template></q-select
>
</div>
</div>
<div
class="row q-pa-sm q-col-gutter-xs"
v-if="
typeReport === 'KPI4' ||
typeReport === 'KPI5' ||
typeReport === 'KPI6' ||
typeReport === 'KPI8'
"
>
<div class="col-12">
<q-input
label="ชื่อ-นามสกุล"
dense
disable
:model-value="
fullNameShow ? fullNameShow : 'กรุณาเลือกรายชื่อ'
"
>
</q-input>
</div>
<div class="col-12">
<q-btn
class="full-width"
color="primary"
label="เลือกรายชื่อ"
@click="onClickModal"
:disable="roundOp.length === 0 && typeReport === 'KPI8'"
/>
</div>
</div>
</q-card-section>
</q-card>
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-12 col-xs-12 flex">
<q-splitter
horizontal
style="
height: 75vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
width: 100%;
"
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-if="!isLoadPDF && pdfSrc"
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>
</div>
</div>
</q-card>
</div>
</div>
</q-form>
<q-card flat bordered>
<q-card-section class="q-gutter-y-sm">
<q-toolbar style="padding: 0">
<div class="row q-gutter-sm">
<q-select
:readonly="!checkPermission($route)?.attrIsGet"
dense
style="min-width: 550px"
hide-bottom-space
outlined
option-label="name"
option-value="id"
emit-value
map-options
v-model="typeReport"
:options="listReport"
label="รายงาน"
use-input
hide-selected
fill-input
@update:model-value="changOption"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn ,'typereport')"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
<div class="row q-gutter-sm"></div>
<q-space />
<q-btn
v-if="checkPermission($route)?.attrIsGet"
flat
round
color="primary"
icon="download"
:disable="!dataDownload"
>
<q-menu>
<q-list style="min-width: 150px">
<q-item
clickable
v-close-popup
@click="downloadReport(dataDownload, '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(dataDownload, '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-list>
</q-menu>
</q-btn>
</q-toolbar>
<q-toolbar
class="q-pa-sm bg-grey-2"
style="padding: 0; border-radius: 5px"
@ -577,94 +870,7 @@ onMounted(() => {
typeReport === 'KPI8' ||
typeReport === 'KPI9'
"
>
<datepicker
menu-class-name="modalfix"
v-model="year"
style="width: 150px"
:locale="'th'"
autoApply
year-picker
:enableTimePicker="false"
@update:model-value="fetchRoundOption()"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
dense
outlined
hide-bottom-space
:model-value="!!year ? year + 543 : null"
:label="`${'ปีงบประมาณ'}`"
class="bg-white"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
style="color: var(--q-primary)"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
<q-select
ref="roundRef"
class="bg-white"
v-model="round"
outlined
label="รอบการประเมิน"
dense
hide-bottom-space
option-label="name"
option-value="id"
:options="roundOp"
style="min-width: 150px"
emit-value
map-options
:disable="roundOp.length === 0"
@update:model-value="changOption(typeReport)"
lazy-rules
:rules="
typeReport === 'KPI8'
? [(val:string) => !!val || 'กรุณาเลือกรอบการประเมิน']
: []
"
/>
<q-select
v-if="typeReport !== 'KPI8'"
class="bg-white"
:disable="roundOp.length === 0"
style="min-width: 100px"
dense
hide-selected
fill-input
hide-bottom-space
outlined
option-label="name"
option-value="id"
emit-value
map-options
v-model="organization"
:options="organizationOps"
label="หน่วยงาน"
use-input
@update:model-value="changOption(typeReport)"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn,'organization' )"
>
<template v-slot:no-option>
<q-item>
<q-item-section class="text-grey"> ไมอม </q-item-section>
</q-item>
</template></q-select
>
</div>
></div>
<div
class="q-pa-sm"
@ -674,102 +880,8 @@ onMounted(() => {
typeReport === 'KPI6' ||
typeReport === 'KPI8'
"
>
<q-btn
color="primary"
label="เลือกรายชื่อ"
@click="onClickModal"
:disable="roundOp.length === 0 && typeReport === 'KPI8'"
/>
</div>
></div>
</q-toolbar>
<q-splitter
v-model="splitterModel"
horizontal
style="
height: 70vh;
border: 1px solid rgb(210, 210, 210);
border-radius: 5px;
"
before-class="overflow-hidden disable"
separator-class="bg-white disabled"
>
<template v-slot:before v-if="pdfSrc">
<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 v-if="pdfSrc">
<div class="q-pa-md">
<VuePDF ref="vuePDFRef" :pdf="pdfSrc" :page="page" fit-parent />
</div>
</template>
<template v-slot:default v-if="pdfSrc">
<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>
@ -853,7 +965,7 @@ onMounted(() => {
outline
color="primary"
label="เลือก"
@click="onSelectPerson(props.row.id)"
@click="onSelectPerson(props.row)"
/>
</q-td>
</q-tr>