รายงานระบบการสรรหาบุคคล
This commit is contained in:
parent
b487ebb5a2
commit
c2f2a122f0
4 changed files with 392 additions and 13 deletions
|
|
@ -41,4 +41,6 @@ export default {
|
|||
exportCandidateList: (id: string) => `${recruit_report}candidate/${id}`,
|
||||
exportPassExamList: (id: string) => `${recruit_report}pass/${id}`,
|
||||
periodRecruitToPlacement: (examId: string) => `${recruit}placement/${examId}`,
|
||||
|
||||
reportRecruit:(type:string)=>`${recruit}${type}`
|
||||
};
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ const Payment = () =>
|
|||
import("@/modules/03_recruiting/views/02_qualify/Payment.vue");
|
||||
const EditorWeb = () =>
|
||||
import("@/modules/03_recruiting/views/03_editor/index.vue");
|
||||
const CompeteReport = () =>
|
||||
import("@/modules/03_recruiting/views/01_compete/CompeteReport.vue");
|
||||
|
||||
export default [
|
||||
{
|
||||
|
|
@ -64,6 +66,16 @@ export default [
|
|||
Role: "STAFF",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/compete/report",
|
||||
name: "competeReport",
|
||||
component: CompeteReport,
|
||||
meta: {
|
||||
Auth: true,
|
||||
Key: "SYS_EXAM_CONTEST_REPORT",
|
||||
Role: "STAFF",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/compete/period/add",
|
||||
name: "competePeriodAdd",
|
||||
|
|
|
|||
369
src/modules/03_recruiting/views/01_compete/CompeteReport.vue
Normal file
369
src/modules/03_recruiting/views/01_compete/CompeteReport.vue
Normal file
|
|
@ -0,0 +1,369 @@
|
|||
<script setup lang="ts">
|
||||
import axios from "axios";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { VuePDF, usePDF } from "@tato30/vue-pdf";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { DataOption } from "@/modules/09_leave/interface/index/Main";
|
||||
|
||||
/** use*/
|
||||
const mixin = useCounterMixin();
|
||||
const $q = useQuasar();
|
||||
const { showLoader, hideLoader, date2Thai, dateToISO, messageError } = mixin;
|
||||
|
||||
const apiGenReport =
|
||||
"https://report-server.frappet.synology.me/api/v1/report-template/xlsx";
|
||||
|
||||
const year = ref<number>(new Date().getFullYear());
|
||||
|
||||
const reportSelect = ref<string>("report1");
|
||||
const reportSelectMain = ref<DataOption[]>([
|
||||
{
|
||||
id: "report1",
|
||||
name: "จำนวนผู้เข้าสอบแข่งขันเพื่อบรรจุเข้ารับราชการเป็นข้าราชการ กทม. สามัญ",
|
||||
},
|
||||
{
|
||||
id: "report2",
|
||||
name: "จำนวนผู้ผ่านการสอบแข่งขันเพื่อบรรจุเข้ารับราชการเป็นข้าราชการ กทม. สามัญ",
|
||||
},
|
||||
]);
|
||||
const reportSelectOption = ref<DataOption[]>(reportSelectMain.value);
|
||||
|
||||
const detailReport = ref<any>();
|
||||
|
||||
/**
|
||||
* function เรียกข้อมูลบัญชีแสดงวันลา
|
||||
* @param type สถานภาพ
|
||||
* @param year ปั
|
||||
* @param startDate วันเริ่มต้น
|
||||
* @param endDate วันสิ้นสุด
|
||||
*/
|
||||
async function getReportRecruit() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(
|
||||
config.API.reportRecruit(reportSelect.value) +
|
||||
`?rootId=&year=${year.value+543}`
|
||||
)
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
data && (await genReport(data));
|
||||
detailReport.value = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function เรียกไฟล์ PDF
|
||||
* @param data ข้อมูลบัญชีวันลา
|
||||
*/
|
||||
async function genReport(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);
|
||||
fileBlob.value = blob;
|
||||
const pdfData = await usePDF(`${objectUrl}`);
|
||||
|
||||
setTimeout(() => {
|
||||
pdfSrc.value = pdfData.pdf.value;
|
||||
numOfPages.value = pdfData.pages.value;
|
||||
}, 1500);
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
hideLoader();
|
||||
}, 2000);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 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]);
|
||||
downloadReport(blob, "xlsx");
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* function Download ไฟล์
|
||||
* @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);
|
||||
}
|
||||
|
||||
const splitterModel = ref(14);
|
||||
const numOfPages = ref<number>(0);
|
||||
const page = ref<number>(1);
|
||||
const pdfSrc = ref<any>();
|
||||
// const modalFull = ref<boolean>(false);
|
||||
const fileBlob = ref<any>();
|
||||
/** ไปหน้าต่อไปของรายงาน */
|
||||
function nextPage() {
|
||||
if (page.value < numOfPages.value) {
|
||||
page.value++;
|
||||
}
|
||||
}
|
||||
|
||||
/** กลับหน้าก่อนหน้าของรายงาน */
|
||||
function backPage() {
|
||||
if (page.value !== 1) {
|
||||
page.value--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function ค้นหาข้อมูล Option
|
||||
* @param val คำค้นหา
|
||||
* @param update function
|
||||
* @param type ประเภท option
|
||||
*/
|
||||
function filterFnOptions(val: any, update: Function) {
|
||||
update(() => {
|
||||
reportSelectOption.value = reportSelectMain.value.filter(
|
||||
(v: DataOption) => v.name.indexOf(val) > -1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getReportRecruit();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">รายงานระบบการสรรหาบุคคล</div>
|
||||
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pa-md">
|
||||
<div class="q-pa-md q-gutter-y-sm">
|
||||
<q-toolbar style="padding: 0">
|
||||
<div class="q-pr-xs">
|
||||
<q-select
|
||||
outlined
|
||||
dense
|
||||
v-model="reportSelect"
|
||||
:options="reportSelectOption"
|
||||
label="ประเภท"
|
||||
emit-value
|
||||
map-options
|
||||
hide-selected
|
||||
fill-input
|
||||
option-label="name"
|
||||
option-value="id"
|
||||
use-input
|
||||
style="width: 500px"
|
||||
@update:model-value="getReportRecruit"
|
||||
@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>
|
||||
<datepicker
|
||||
v-model="year"
|
||||
:locale="'th'"
|
||||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:model-value="getReportRecruit"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
parseInt(value + 543)
|
||||
}}</template>
|
||||
<template #trigger>
|
||||
<q-input
|
||||
class="bg-white"
|
||||
dense
|
||||
outlined
|
||||
:model-value="Number(year) + 543"
|
||||
:label="`${'ปีงบประมาณ'}`"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<q-icon
|
||||
name="event"
|
||||
class="cursor-pointer"
|
||||
style="color: var(--q-primary)"
|
||||
>
|
||||
</q-icon>
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</datepicker>
|
||||
</div>
|
||||
<q-space />
|
||||
<div class="q-py-xs">
|
||||
<q-btn
|
||||
flat
|
||||
round
|
||||
color="primary"
|
||||
icon="download"
|
||||
v-if="checkPermission($route)?.attrIsGet"
|
||||
>
|
||||
<q-menu>
|
||||
<q-list style="min-width: 150px">
|
||||
<q-item
|
||||
clickable
|
||||
v-close-popup
|
||||
@click="downloadReport(fileBlob, '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="genReportXLSX(detailReport)"
|
||||
>
|
||||
<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>
|
||||
</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>
|
||||
<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">
|
||||
<VuePDF 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>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<style scoped></style>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
import { ref, watch,computed } from "vue";
|
||||
import { ref, watch, computed } from "vue";
|
||||
import axios from "axios";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
|
@ -33,9 +33,9 @@ const rangeAge = ref<RangeAge>({
|
|||
max: 80,
|
||||
});
|
||||
|
||||
const objMarkerLabel = computed(()=>{
|
||||
return { 50: `ช่วงอายุ ${rangeAge.value.min}-${rangeAge.value.max} ปี`}
|
||||
})
|
||||
const objMarkerLabel = computed(() => {
|
||||
return { 50: `ช่วงอายุ ${rangeAge.value.min}-${rangeAge.value.max} ปี` };
|
||||
});
|
||||
|
||||
const loadingBtn = ref<boolean>(false);
|
||||
const year = ref<number>(new Date().getFullYear());
|
||||
|
|
@ -218,7 +218,6 @@ function redirectToPagePetition() {
|
|||
|
||||
function onGovernment() {
|
||||
modalReport.value = true;
|
||||
getReport();
|
||||
}
|
||||
|
||||
function closeDialog() {
|
||||
|
|
@ -240,8 +239,7 @@ async function getReport() {
|
|||
)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
detailReport.value = data;
|
||||
console.log("🚀 ~ .then ~ data:", data);
|
||||
genReportXLSX(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -649,7 +647,6 @@ watch(
|
|||
autoApply
|
||||
year-picker
|
||||
:enableTimePicker="false"
|
||||
@update:model-value="getReport"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -676,15 +673,14 @@ watch(
|
|||
</datepicker>
|
||||
</div>
|
||||
<div class="q-pr-xs col-4">
|
||||
<div class="q-px-sm">
|
||||
<div class="q-px-sm q-mx-md">
|
||||
<q-range
|
||||
:model-value="rangeAge"
|
||||
v-model="rangeAge"
|
||||
:min="20"
|
||||
:max="80"
|
||||
label-always
|
||||
label
|
||||
:marker-labels="objMarkerLabel"
|
||||
color="primary"
|
||||
@change="(val:RangeAge) => { rangeAge = val,getReport() }"
|
||||
>
|
||||
</q-range>
|
||||
</div>
|
||||
|
|
@ -696,7 +692,7 @@ watch(
|
|||
color="primary"
|
||||
icon="download"
|
||||
label="ดาวน์โหลดรายงาน"
|
||||
@click="genReportXLSX(detailReport)"
|
||||
@click="getReport"
|
||||
style="width: 100%"
|
||||
>
|
||||
<q-tooltip>ดาวน์โหลดรายงาน</q-tooltip>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue