Refactoring code module 03_recruiting
This commit is contained in:
parent
b223c2433e
commit
87e2e3b080
36 changed files with 6139 additions and 6335 deletions
|
|
@ -1,139 +1,23 @@
|
|||
<!-- page:detail page สรรหา -->
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
<q-btn
|
||||
icon="mdi-arrow-left"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
flat
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
@click="router.go(-1)"
|
||||
/>
|
||||
รายชื่อผู้สมัครสอบแข่งขัน {{ name }} ครั้งที่ {{ round }}/{{ year }}
|
||||
<q-space />
|
||||
<q-btn
|
||||
size="md"
|
||||
icon="mdi-content-save-move-outline"
|
||||
round
|
||||
flat
|
||||
color="indigo"
|
||||
v-if="rows.length > 0"
|
||||
@click="candidateToPlacement"
|
||||
>
|
||||
<q-tooltip>บรรจุผู้ผ่านการสอบแข่งขัน</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="bg-teal-1" 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="downloadExam()">
|
||||
<q-item-section class="text-blue"
|
||||
>ส่งออกข้อมูลผู้มีสิทธิ์สอบ</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="downloadPassExam()">
|
||||
<q-item-section class="text-primary"
|
||||
>ส่งออกข้อมูลผู้สอบผ่านภาค ก.</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="downloadPassResultExam()">
|
||||
<q-item-section class="text-amber-9"
|
||||
>ส่งออกข้อมูลผู้สอบแข่งขันได้</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 row q-mt-sm q-pt-sm q-pa-md">
|
||||
<div class="col-12">
|
||||
<Table
|
||||
:count="count"
|
||||
:pass="pass"
|
||||
:notpass="notpass"
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:filter="filter"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:inputfilter="filter"
|
||||
v-model:inputvisible="visibleColumns"
|
||||
:nornmalData="false"
|
||||
:conclude="true"
|
||||
>
|
||||
<template #columns="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="clickDetail(props.row.examID)"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name == 'fullname'">
|
||||
<div class="row col-12 items-center">
|
||||
<img
|
||||
:src="props.row.avatar"
|
||||
class="q-mr-sm col-4"
|
||||
style="width: 28px; height: 28px; border-radius: 50%"
|
||||
/>
|
||||
<div class="col-4">
|
||||
<div class="text-weight-medium">
|
||||
{{ props.row.fullname }}
|
||||
</div>
|
||||
<div class="text-weight-light">
|
||||
{{ props.row.citizenId }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c1'">
|
||||
<q-checkbox disable v-model="props.row.c1" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c2'">
|
||||
<q-checkbox disable v-model="props.row.c2" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c3'">
|
||||
<q-checkbox disable v-model="props.row.c3" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c4'">
|
||||
<q-checkbox disable v-model="props.row.c4" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c5'">
|
||||
<q-checkbox disable v-model="props.row.c5" />
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import type { RecruitDetailResponse } from "@/modules/03_recruiting/interface/response/Period";
|
||||
import Table from "@/modules/03_recruiting/components/Table.vue";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
const $q = useQuasar();
|
||||
import type { RecruitDetailResponse } from "@/modules/03_recruiting/interface/response/Period";
|
||||
import Table from "@/modules/03_recruiting/components/Table.vue";
|
||||
|
||||
const $q = useQuasar();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, success, showLoader, hideLoader } = mixin;
|
||||
|
||||
const year = ref<string>("");
|
||||
const round = ref<string>("");
|
||||
const name = ref<string>("");
|
||||
|
|
@ -364,16 +248,11 @@ const columns = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
const clickDetail = (examID: string) => {
|
||||
function clickDetail(examID: string) {
|
||||
router.push(`/compete/import/${importId.value}/${examID}`);
|
||||
};
|
||||
}
|
||||
|
||||
const downloadExam = async () => {
|
||||
async function downloadExam() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.exportExam(importId.value), {
|
||||
|
|
@ -392,9 +271,10 @@ const downloadExam = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const downloadPassExam = async () => {
|
||||
/** ดาวห์โลหด รายชื่อผู้สอบผ่าน */
|
||||
async function downloadPassExam() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.exportPassExam(importId.value), {
|
||||
|
|
@ -413,9 +293,10 @@ const downloadPassExam = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const downloadPassResultExam = async () => {
|
||||
/** ดาวห์โลหด สอบแข่งขันได้ */
|
||||
async function downloadPassResultExam() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.exportPassResultExam(importId.value), {
|
||||
|
|
@ -434,9 +315,10 @@ const downloadPassResultExam = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const fetchData = async () => {
|
||||
/** ดึงข้อมูล */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.getExamResultById(importId.value), {
|
||||
|
|
@ -449,8 +331,6 @@ const fetchData = async () => {
|
|||
count.value = header.count;
|
||||
pass.value = header.pass;
|
||||
notpass.value = header.notpass;
|
||||
|
||||
// period information
|
||||
if (period != null) {
|
||||
name.value = period.name;
|
||||
round.value = period.order;
|
||||
|
|
@ -476,9 +356,9 @@ const fetchData = async () => {
|
|||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const candidateToPlacement = async () => {
|
||||
async function candidateToPlacement() {
|
||||
$q.dialog({
|
||||
title: "ยืนยันการนำผู้ผ่านสอบแข่งขันเข้าสู่ระบบบรรจุ",
|
||||
message: "ต้องการนำผู้ผ่านสอบแข่งขันเข้าสู่ระบบบรรจุใช่หรือไม่?",
|
||||
|
|
@ -505,7 +385,128 @@ const candidateToPlacement = async () => {
|
|||
})
|
||||
.onCancel(() => {})
|
||||
.onDismiss(() => {});
|
||||
};
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
await fetchData();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
<q-btn
|
||||
icon="mdi-arrow-left"
|
||||
unelevated
|
||||
round
|
||||
dense
|
||||
flat
|
||||
color="primary"
|
||||
class="q-mr-sm"
|
||||
@click="router.go(-1)"
|
||||
/>
|
||||
รายชื่อผู้สมัครสอบแข่งขัน {{ name }} ครั้งที่ {{ round }}/{{ year }}
|
||||
<q-space />
|
||||
<q-btn
|
||||
size="md"
|
||||
icon="mdi-content-save-move-outline"
|
||||
round
|
||||
flat
|
||||
color="indigo"
|
||||
v-if="rows.length > 0"
|
||||
@click="candidateToPlacement"
|
||||
>
|
||||
<q-tooltip>บรรจุผู้ผ่านการสอบแข่งขัน</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn class="bg-teal-1" 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="downloadExam()">
|
||||
<q-item-section class="text-blue"
|
||||
>ส่งออกข้อมูลผู้มีสิทธิ์สอบ</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="downloadPassExam()">
|
||||
<q-item-section class="text-primary"
|
||||
>ส่งออกข้อมูลผู้สอบผ่านภาค ก.</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
<q-item clickable v-close-popup @click="downloadPassResultExam()">
|
||||
<q-item-section class="text-amber-9"
|
||||
>ส่งออกข้อมูลผู้สอบแข่งขันได้</q-item-section
|
||||
>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-menu>
|
||||
</q-btn>
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 row q-mt-sm q-pt-sm q-pa-md">
|
||||
<div class="col-12">
|
||||
<Table
|
||||
:count="count"
|
||||
:pass="pass"
|
||||
:notpass="notpass"
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:filter="filter"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:inputfilter="filter"
|
||||
v-model:inputvisible="visibleColumns"
|
||||
:nornmalData="false"
|
||||
:conclude="true"
|
||||
>
|
||||
<template #columns="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td
|
||||
v-for="col in props.cols"
|
||||
:key="col.name"
|
||||
:props="props"
|
||||
@click="clickDetail(props.row.examID)"
|
||||
>
|
||||
<div v-if="col.name == 'no'">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div v-else-if="col.name == 'fullname'">
|
||||
<div class="row col-12 items-center">
|
||||
<img
|
||||
:src="props.row.avatar"
|
||||
class="q-mr-sm col-4"
|
||||
style="width: 28px; height: 28px; border-radius: 50%"
|
||||
/>
|
||||
<div class="col-4">
|
||||
<div class="text-weight-medium">
|
||||
{{ props.row.fullname }}
|
||||
</div>
|
||||
<div class="text-weight-light">
|
||||
{{ props.row.citizenId }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c1'">
|
||||
<q-checkbox disable v-model="props.row.c1" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c2'">
|
||||
<q-checkbox disable v-model="props.row.c2" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c3'">
|
||||
<q-checkbox disable v-model="props.row.c3" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c4'">
|
||||
<q-checkbox disable v-model="props.row.c4" />
|
||||
</div>
|
||||
<div v-else-if="col.name == 'c5'">
|
||||
<q-checkbox disable v-model="props.row.c5" />
|
||||
</div>
|
||||
<div v-else>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,137 @@
|
|||
<!-- page:detail page สรรหา -->
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const profile_id = ref<string>("");
|
||||
const birthdate = ref<string>("");
|
||||
const gender = ref<string>("");
|
||||
const university = ref<string>("");
|
||||
const position_name = ref<string>("");
|
||||
const degree = ref<string>("");
|
||||
const major = ref<string>("");
|
||||
const cert_issuedate = ref<string>("");
|
||||
const examAttribute = ref<string>("");
|
||||
const examResultinscore = ref<string>("");
|
||||
const scoreAFull = ref<string>("");
|
||||
const scoreA = ref<string>("");
|
||||
const scoreBFull = ref<string>("");
|
||||
const scoreB = ref<string>("");
|
||||
const scoreCFull = ref<string>("");
|
||||
const scoreC = ref<string>("");
|
||||
const scoreSumFull = ref<string>("");
|
||||
const scoreSum = ref<string>("");
|
||||
const examOrder = ref<string>("");
|
||||
const number = ref<string>("");
|
||||
const score_expired = ref<string>("");
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, showLoader, hideLoader } = mixin;
|
||||
const examID = ref<string>("62150001");
|
||||
const prefix = ref<string>("นาย");
|
||||
const fullname = ref<string>("เกียรติศักดิ์ บัณฑิต");
|
||||
const importId = ref<string>(route.params.id as string); // Period Import Id
|
||||
const examId = ref<string>(route.params.examId as string); // เลขประจำตัวสอบ
|
||||
|
||||
/** ดึงข้อมูล */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getExamDetail(importId.value, examId.value))
|
||||
.then((res) => {
|
||||
let data = res.data.result;
|
||||
if (data != null) {
|
||||
profile_id.value = data.profileID;
|
||||
examID.value = data.examID;
|
||||
prefix.value = data.prefix;
|
||||
fullname.value = data.fullName;
|
||||
birthdate.value = data.dateOfBirth;
|
||||
gender.value = data.gender;
|
||||
degree.value = data.degree;
|
||||
major.value = data.major;
|
||||
university.value = data.university;
|
||||
position_name.value = data.positionName;
|
||||
cert_issuedate.value = data.certificateIssueDate;
|
||||
examAttribute.value = data.examAttribute;
|
||||
number.value = data.number;
|
||||
examOrder.value = data.examOrder;
|
||||
score_expired.value = data.scoreExpire;
|
||||
if (data.scoreResult != null) {
|
||||
scoreAFull.value = data.scoreResult.scoreAFull;
|
||||
scoreA.value = data.scoreResult.scoreA;
|
||||
scoreBFull.value = data.scoreResult.scoreBFull;
|
||||
scoreB.value = data.scoreResult.scoreB;
|
||||
scoreCFull.value = data.scoreResult.scoreCFull;
|
||||
scoreC.value = data.scoreResult.scoreC;
|
||||
scoreSumFull.value = data.scoreResult.scoreSumFull;
|
||||
scoreSum.value = data.scoreResult.scoreSum;
|
||||
examResultinscore.value = data.scoreResult.examResult;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadScore() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.downloadScoreReport(importId.value, examId.value), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((res) => {
|
||||
var a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(res.data);
|
||||
a.download = `ผลคะแนน_${examId.value}.pdf`;
|
||||
// start download
|
||||
a.click();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
async function downloadCertificate() {
|
||||
showLoader();
|
||||
let type = degree.value.includes("บัณฑิต") ? 2 : 1;
|
||||
await http
|
||||
.get(config.API.downloadExamReport(importId.value, examId.value, type), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((res) => {
|
||||
var a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(res.data);
|
||||
a.download = `เอกสารรับรอง_${examId.value}.pdf`;
|
||||
// start download
|
||||
a.click();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
<q-btn
|
||||
|
|
@ -233,138 +366,5 @@
|
|||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useQuasar } from "quasar";
|
||||
|
||||
const $q = useQuasar();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
const profile_id = ref<string>("");
|
||||
const birthdate = ref<string>("");
|
||||
const gender = ref<string>("");
|
||||
const university = ref<string>("");
|
||||
const position_name = ref<string>("");
|
||||
const degree = ref<string>("");
|
||||
const major = ref<string>("");
|
||||
const cert_issuedate = ref<string>("");
|
||||
const examAttribute = ref<string>("");
|
||||
const examResultinscore = ref<string>("");
|
||||
const scoreAFull = ref<string>("");
|
||||
const scoreA = ref<string>("");
|
||||
const scoreBFull = ref<string>("");
|
||||
const scoreB = ref<string>("");
|
||||
const scoreCFull = ref<string>("");
|
||||
const scoreC = ref<string>("");
|
||||
const scoreSumFull = ref<string>("");
|
||||
const scoreSum = ref<string>("");
|
||||
const examOrder = ref<string>("");
|
||||
const number = ref<string>("");
|
||||
const score_expired = ref<string>("");
|
||||
const mixin = useCounterMixin();
|
||||
const { messageError, showLoader, hideLoader } = mixin;
|
||||
const examID = ref<string>("62150001");
|
||||
const prefix = ref<string>("นาย");
|
||||
const fullname = ref<string>("เกียรติศักดิ์ บัณฑิต");
|
||||
const importId = ref<string>(route.params.id as string); // Period Import Id
|
||||
const examId = ref<string>(route.params.examId as string); // เลขประจำตัวสอบ
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
const fetchData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getExamDetail(importId.value, examId.value))
|
||||
.then((res) => {
|
||||
let data = res.data.result;
|
||||
if (data != null) {
|
||||
profile_id.value = data.profileID;
|
||||
examID.value = data.examID;
|
||||
prefix.value = data.prefix;
|
||||
fullname.value = data.fullName;
|
||||
birthdate.value = data.dateOfBirth;
|
||||
gender.value = data.gender;
|
||||
degree.value = data.degree;
|
||||
major.value = data.major;
|
||||
university.value = data.university;
|
||||
position_name.value = data.positionName;
|
||||
cert_issuedate.value = data.certificateIssueDate;
|
||||
examAttribute.value = data.examAttribute;
|
||||
number.value = data.number;
|
||||
examOrder.value = data.examOrder;
|
||||
score_expired.value = data.scoreExpire;
|
||||
if (data.scoreResult != null) {
|
||||
scoreAFull.value = data.scoreResult.scoreAFull;
|
||||
scoreA.value = data.scoreResult.scoreA;
|
||||
scoreBFull.value = data.scoreResult.scoreBFull;
|
||||
scoreB.value = data.scoreResult.scoreB;
|
||||
scoreCFull.value = data.scoreResult.scoreCFull;
|
||||
scoreC.value = data.scoreResult.scoreC;
|
||||
scoreSumFull.value = data.scoreResult.scoreSumFull;
|
||||
scoreSum.value = data.scoreResult.scoreSum;
|
||||
examResultinscore.value = data.scoreResult.examResult;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const downloadScore = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.downloadScoreReport(importId.value, examId.value), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((res) => {
|
||||
var a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(res.data);
|
||||
a.download = `ผลคะแนน_${examId.value}.pdf`;
|
||||
// start download
|
||||
a.click();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const downloadCertificate = async () => {
|
||||
showLoader();
|
||||
let type = degree.value.includes("บัณฑิต") ? 2 : 1;
|
||||
await http
|
||||
.get(config.API.downloadExamReport(importId.value, examId.value, type), {
|
||||
responseType: "blob",
|
||||
})
|
||||
.then((res) => {
|
||||
var a = document.createElement("a");
|
||||
a.href = URL.createObjectURL(res.data);
|
||||
a.download = `เอกสารรับรอง_${examId.value}.pdf`;
|
||||
// start download
|
||||
a.click();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
messageError($q, JSON.parse(await e.response.data.text()));
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
|
|
@ -1,86 +1,7 @@
|
|||
<!-- page:main page สรรหา -->
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
รายการนำเข้าข้อมูลผู้สมัครสอบแข่งขัน
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
|
||||
<div>
|
||||
<Table
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:filter="filter"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:inputfilter="filter"
|
||||
v-model:inputvisible="visibleColumns"
|
||||
:nornmalData="false"
|
||||
>
|
||||
<template #columns="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'" @click="clickEdit(props.row.year)">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="col.name == 'name'"
|
||||
class="table_ellipsis2"
|
||||
@click="clickEdit(props.row.year)"
|
||||
>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
<div v-else-if="col.name == 'file'">
|
||||
<q-btn
|
||||
size="13px"
|
||||
flat
|
||||
class="bg-blue-1 q-ml-xs"
|
||||
color="blue"
|
||||
v-if="col.value == null || file == false"
|
||||
>
|
||||
<q-icon
|
||||
name="mdi-file-excel-outline"
|
||||
size="20px"
|
||||
class="q-mr-sm"
|
||||
/>
|
||||
นำเข้าไฟล์
|
||||
<q-tooltip>นำเข้าไฟล์ excel</q-tooltip>
|
||||
</q-btn>
|
||||
<div v-else>
|
||||
<q-chip
|
||||
removable
|
||||
color="grey-2"
|
||||
text-color="grey-9"
|
||||
:label="col.value"
|
||||
size="14px"
|
||||
square
|
||||
icon-remove="mdi-close"
|
||||
v-model="file"
|
||||
@remove="remove"
|
||||
>
|
||||
<q-tooltip>{{ col.value }}</q-tooltip>
|
||||
</q-chip>
|
||||
<q-btn
|
||||
size="14px"
|
||||
flat
|
||||
dense
|
||||
color="positive"
|
||||
icon="mdi-content-save-settings-outline"
|
||||
>
|
||||
<q-tooltip>บันทึกคะแนนสอบ</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else @click="clickEdit(props.row.year)">
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
import Table from "@/modules/03_recruiting/components/Table.vue";
|
||||
|
|
@ -178,19 +99,17 @@ const columns = ref<QTableProps["columns"]>([
|
|||
},
|
||||
]);
|
||||
|
||||
/**
|
||||
* เปืด dialog digital
|
||||
* @param id
|
||||
*/
|
||||
const rows = ref<any[]>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
const fetchData = () => {};
|
||||
|
||||
const clickEdit = (id: string) => {
|
||||
function clickEdit(id: string) {
|
||||
router.push(`/compete/import/${id}`);
|
||||
};
|
||||
}
|
||||
|
||||
const remove = () => {
|
||||
function remove() {
|
||||
$q.dialog({
|
||||
title: "ยืนยันการลบเอกสารข้อมูล",
|
||||
message: "ต้องการลบเอกสารนี้ใช่หรือไม่?",
|
||||
|
|
@ -207,7 +126,87 @@ const remove = () => {
|
|||
file.value = true;
|
||||
})
|
||||
.onDismiss(() => {});
|
||||
};
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
รายการนำเข้าข้อมูลผู้สมัครสอบแข่งขัน
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-pt-sm q-pa-md">
|
||||
<div>
|
||||
<Table
|
||||
:rows="rows"
|
||||
:columns="columns"
|
||||
:filter="filter"
|
||||
:visible-columns="visibleColumns"
|
||||
v-model:inputfilter="filter"
|
||||
v-model:inputvisible="visibleColumns"
|
||||
:nornmalData="false"
|
||||
>
|
||||
<template #columns="props">
|
||||
<q-tr :props="props" class="cursor-pointer">
|
||||
<q-td v-for="col in props.cols" :key="col.name" :props="props">
|
||||
<div v-if="col.name == 'no'" @click="clickEdit(props.row.year)">
|
||||
{{ props.rowIndex + 1 }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="col.name == 'name'"
|
||||
class="table_ellipsis2"
|
||||
@click="clickEdit(props.row.year)"
|
||||
>
|
||||
{{ col.value }}
|
||||
</div>
|
||||
<div v-else-if="col.name == 'file'">
|
||||
<q-btn
|
||||
size="13px"
|
||||
flat
|
||||
class="bg-blue-1 q-ml-xs"
|
||||
color="blue"
|
||||
v-if="col.value == null || file == false"
|
||||
>
|
||||
<q-icon
|
||||
name="mdi-file-excel-outline"
|
||||
size="20px"
|
||||
class="q-mr-sm"
|
||||
/>
|
||||
นำเข้าไฟล์
|
||||
<q-tooltip>นำเข้าไฟล์ excel</q-tooltip>
|
||||
</q-btn>
|
||||
<div v-else>
|
||||
<q-chip
|
||||
removable
|
||||
color="grey-2"
|
||||
text-color="grey-9"
|
||||
:label="col.value"
|
||||
size="14px"
|
||||
square
|
||||
icon-remove="mdi-close"
|
||||
v-model="file"
|
||||
@remove="remove"
|
||||
>
|
||||
<q-tooltip>{{ col.value }}</q-tooltip>
|
||||
</q-chip>
|
||||
<q-btn
|
||||
size="14px"
|
||||
flat
|
||||
dense
|
||||
color="positive"
|
||||
icon="mdi-content-save-settings-outline"
|
||||
>
|
||||
<q-tooltip>บันทึกคะแนนสอบ</q-tooltip>
|
||||
</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else @click="clickEdit(props.row.year)">
|
||||
{{ col.value }}
|
||||
</div>
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
</Table>
|
||||
</div>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,415 @@
|
|||
<!-- page:จัดการรอบการสอบ สรรหา -->
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
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 { Pagination } from "@/modules/03_recruiting/interface/index/Main";
|
||||
import type {
|
||||
ResponseRecruitPeriod,
|
||||
ResponseHistoryObject,
|
||||
} from "@/modules/03_recruiting/interface/response/Period";
|
||||
|
||||
import Table from "@/modules/03_recruiting/components/Table.vue";
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
import HistoryTable from "@/components/TableHistory.vue";
|
||||
|
||||
const $q = useQuasar(); // show dialog
|
||||
const mixin = useCounterMixin();
|
||||
const { success, dateText, showLoader, hideLoader, messageError } = mixin;
|
||||
|
||||
const router = useRouter();
|
||||
const name = ref<string>("");
|
||||
const year = ref<number>(new Date().getFullYear() + 543);
|
||||
const order = ref<number>(1);
|
||||
|
||||
const files = ref<any>(null);
|
||||
const files_score = ref<any>(null);
|
||||
const files_candidate = ref<any>(null);
|
||||
const modalAdd = ref<boolean>(false);
|
||||
const modalScore = ref<boolean>(false);
|
||||
const modalCandidate = ref<boolean>(false);
|
||||
const selected_row_id = ref<string>("");
|
||||
const rowsHistory = ref<ResponseHistoryObject[]>([]); //select data history
|
||||
const tittleHistory = ref<string>("ประวัติการนำเข้าข้อมูล"); //
|
||||
const filterHistory = ref<string>(""); //search data table history
|
||||
const modalHistory = ref<boolean>(false); //modal ประวัติการแก้ไขข้อมูล
|
||||
const modalError = ref<boolean>(false); // modal สำหรับแจ้งเตือนerror
|
||||
const modalErrorTittle = ref<string>(""); // tittle modal error
|
||||
const modalErrorDetail = ref<string>(""); // detail modal error
|
||||
const statusCode = ref<number>();
|
||||
const filter = ref<string>(""); //search data table
|
||||
const textTittle = ref<string>("");
|
||||
const textTittleScore = ref<string>("");
|
||||
const textTittleCandidate = ref<string>("");
|
||||
const rows = ref<ResponseRecruitPeriod[]>([]);
|
||||
const initialPagination = ref<Pagination>({
|
||||
rowsPerPage: 0,
|
||||
});
|
||||
const visibleColumns = ref<String[]>([
|
||||
"no",
|
||||
"name",
|
||||
"order",
|
||||
"year",
|
||||
"examCount",
|
||||
"scoreCount",
|
||||
]);
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "รอบสอบแข่งขัน",
|
||||
sortable: true,
|
||||
field: "name",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "order",
|
||||
align: "left",
|
||||
label: "ครั้งที่",
|
||||
sortable: true,
|
||||
field: "order",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "year",
|
||||
align: "left",
|
||||
label: "ปีงบประมาณ",
|
||||
sortable: true,
|
||||
field: "year",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "examCount",
|
||||
label: "จำนวนผู้สอบทั้งหมด",
|
||||
align: "right",
|
||||
field: "examCount",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "scoreCount",
|
||||
label: "จำนวนที่บันทึกผลสอบ",
|
||||
align: "right",
|
||||
field: "scoreCount",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const columnsHistory = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "description",
|
||||
align: "left",
|
||||
label: "รายละเอียด",
|
||||
sortable: true,
|
||||
field: "description",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "createdAt",
|
||||
align: "center",
|
||||
label: "วันที่ดำเนินการ",
|
||||
sortable: true,
|
||||
field: "createdAt",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "createdFullName",
|
||||
align: "left",
|
||||
label: "ผู้ดำเนินการ",
|
||||
sortable: true,
|
||||
field: "createdFullName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumnsHistory = ref<String[]>([
|
||||
"description",
|
||||
"createdAt",
|
||||
"createdFullName",
|
||||
]);
|
||||
|
||||
/**
|
||||
* ฟังก์ชันแปลง date เป็นภาษาไทย
|
||||
* @param value วันที่ type datetime ที่จะแปลงเป็นไทย
|
||||
*/
|
||||
function textDate(value: Date) {
|
||||
return dateText(value);
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล รอบสอบแข่งขัน */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getCandidates)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
let result: ResponseRecruitPeriod[] = [];
|
||||
if (data.length > 0) {
|
||||
data.map((r: ResponseRecruitPeriod) => {
|
||||
if (r.score != null) {
|
||||
r.scoreCount = r.score.scoreCount;
|
||||
r.scoreImportDate = r.score.importDate;
|
||||
}
|
||||
result.push(r);
|
||||
});
|
||||
}
|
||||
|
||||
rows.value = result;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ดาวน์โหลดรายชื่อผู้สอบแข่งขันได้
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
function clickPassExam(id: string) {
|
||||
window.open(config.API.exportPassExamList(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* ดาวน์โหลดรายชื่อผู้มีสิทธิ์สอบ
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
function clickCandidateList(id: string) {
|
||||
window.open(config.API.exportCandidateList(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* รายละเอียด รอบสอบเเข่งขัน
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
function clickDetail(id: string) {
|
||||
router.push(`/compete/import/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* นำเข้าไฟล์ผลคะแนนสอบอีกครั้ง
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
async function clickEdit(id: string) {
|
||||
modalScore.value = true;
|
||||
textTittleScore.value = "นำเข้าผลคะแนนสอบแข่งขัน";
|
||||
selected_row_id.value = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* นำเข้าไฟล์ผู้สมัครสอบอีกครั้ง
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
async function clickUpload(id: string) {
|
||||
modalCandidate.value = true;
|
||||
textTittleCandidate.value = "นำเข้าผู้สมัครสอบแข่งขัน";
|
||||
selected_row_id.value = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* แก้ไขรอบสอบแข่งขัน
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
function clickEditPeriod(id: string) {
|
||||
router.push(`/compete/period/${id}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* ประวัติ
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
async function clickHistory(id: string) {
|
||||
modalHistory.value = true;
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getImportHistory(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
rowsHistory.value = [];
|
||||
if (data.length > 0) {
|
||||
data.map((i: ResponseHistoryObject) => {
|
||||
rowsHistory.value.push({
|
||||
createdAt: i.createdAt,
|
||||
createdFullName: i.createdFullName,
|
||||
createdUserId: i.createdUserId,
|
||||
id: i.id,
|
||||
isActive: i.isActive,
|
||||
lastUpdateFullName: i.lastUpdateFullName,
|
||||
lastUpdateUserId: i.lastUpdateUserId,
|
||||
lastUpdatedAt: i.lastUpdatedAt,
|
||||
description: i.description,
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
modalError.value = true;
|
||||
modalErrorTittle.value = "ไม่พบประวัติการเผยแพร่";
|
||||
modalErrorDetail.value = e.response.data.message;
|
||||
statusCode.value = e.response.data.status;
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบข้อมูล
|
||||
*
|
||||
* @param id รอบสอบเเข่งขัน
|
||||
*/
|
||||
function clickDelete(id: string) {
|
||||
$q.dialog({
|
||||
title: "ยืนยันการลบข้อมูล",
|
||||
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
|
||||
cancel: {
|
||||
flat: true,
|
||||
color: "negative",
|
||||
},
|
||||
persistent: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.deleteCandidates(id))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลการสอบสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
})
|
||||
.onCancel(() => {})
|
||||
.onDismiss(() => {});
|
||||
}
|
||||
|
||||
/** ไปหน้าเพิ่มรอบสอบแข่งขัน */
|
||||
function clickAdd() {
|
||||
router.push({ name: "competePeriodAdd" });
|
||||
}
|
||||
|
||||
/** ปิด dialog */
|
||||
async function clickClose() {
|
||||
modalAdd.value = false;
|
||||
await fetchData();
|
||||
}
|
||||
|
||||
/** ปิด dialog คะเเนน */
|
||||
async function clickCloseScore() {
|
||||
modalScore.value = false;
|
||||
await fetchData();
|
||||
}
|
||||
|
||||
/** ปิด dialog เลือกไฟล์ผู้สมัครสอบแข่งขัน */
|
||||
async function clickCloseCandidate() {
|
||||
modalCandidate.value = false;
|
||||
await fetchData();
|
||||
}
|
||||
|
||||
/** บันทึกข้อมูล เลือกไฟล์ผู้สมัครสอบแข่งขัน */
|
||||
async function checkSaveCandidate() {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files_candidate.value[0]);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.uploadCandidates(selected_row_id.value), fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผู้สมัครสอบสำเร็จ");
|
||||
modalCandidate.value = false;
|
||||
selected_row_id.value = "";
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** บันทึด คะเเนน */
|
||||
async function checkSaveScore() {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files_score.value[0]);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.saveScores(selected_row_id.value), fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผลคะแนนสอบสำเร็จ");
|
||||
modalScore.value = false;
|
||||
selected_row_id.value = "";
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** save data */
|
||||
async function checkSave() {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files.value[0]);
|
||||
fd.append("year", year.value.toString());
|
||||
fd.append("order", order.value.toString());
|
||||
fd.append("name", name.value);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.saveCandidates, fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผู้สมัครสอบแข่งขันสำเร็จ");
|
||||
modalAdd.value = false;
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** ดึงข้อมูล เมื่อโหลดหน้า component */
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
await fetchData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
จัดการรอบสอบแข่งขัน
|
||||
|
|
@ -373,370 +784,5 @@
|
|||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { checkPermission } from "@/utils/permissions";
|
||||
import type { QTableProps } from "quasar";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import type {
|
||||
ResponseRecruitPeriod,
|
||||
ResponseHistoryObject,
|
||||
} from "@/modules/03_recruiting/interface/response/Period";
|
||||
import type { Pagination } from "@/modules/03_recruiting/interface/index/Main";
|
||||
import Table from "@/modules/03_recruiting/components/Table.vue";
|
||||
import DialogHeader from "@/components/DialogHeader.vue";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import HistoryTable from "@/components/TableHistory.vue";
|
||||
|
||||
const $q = useQuasar(); // show dialog
|
||||
const router = useRouter();
|
||||
const name = ref<string>("");
|
||||
const year = ref<number>(new Date().getFullYear() + 543);
|
||||
const order = ref<number>(1);
|
||||
const mixin = useCounterMixin();
|
||||
const { success, dateToISO, dateText, showLoader, hideLoader } = mixin;
|
||||
const files = ref<any>(null);
|
||||
const files_score = ref<any>(null);
|
||||
const files_candidate = ref<any>(null);
|
||||
const modalAdd = ref<boolean>(false);
|
||||
const modalScore = ref<boolean>(false);
|
||||
const modalCandidate = ref<boolean>(false);
|
||||
const selected_row_id = ref<string>("");
|
||||
const rowsHistory = ref<ResponseHistoryObject[]>([]); //select data history
|
||||
const tittleHistory = ref<string>("ประวัติการนำเข้าข้อมูล"); //
|
||||
const filterHistory = ref<string>(""); //search data table history
|
||||
const modalHistory = ref<boolean>(false); //modal ประวัติการแก้ไขข้อมูล
|
||||
const modalError = ref<boolean>(false); // modal สำหรับแจ้งเตือนerror
|
||||
const modalErrorTittle = ref<string>(""); // tittle modal error
|
||||
const modalErrorDetail = ref<string>(""); // detail modal error
|
||||
const statusCode = ref<number>();
|
||||
const filter = ref<string>(""); //search data table
|
||||
const textTittle = ref<string>("");
|
||||
const { messageError } = mixin;
|
||||
const textTittleScore = ref<string>("");
|
||||
const textTittleCandidate = ref<string>("");
|
||||
const rows = ref<any[]>([]);
|
||||
const initialPagination = ref<Pagination>({
|
||||
rowsPerPage: 0,
|
||||
});
|
||||
const visibleColumns = ref<String[]>([
|
||||
"no",
|
||||
"name",
|
||||
"order",
|
||||
"year",
|
||||
"examCount",
|
||||
"scoreCount",
|
||||
]);
|
||||
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "no",
|
||||
align: "left",
|
||||
label: "ลำดับ",
|
||||
sortable: false,
|
||||
field: "no",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "รอบสอบแข่งขัน",
|
||||
sortable: true,
|
||||
field: "name",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "order",
|
||||
align: "left",
|
||||
label: "ครั้งที่",
|
||||
sortable: true,
|
||||
field: "order",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "year",
|
||||
align: "left",
|
||||
label: "ปีงบประมาณ",
|
||||
sortable: true,
|
||||
field: "year",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "examCount",
|
||||
label: "จำนวนผู้สอบทั้งหมด",
|
||||
align: "right",
|
||||
field: "examCount",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "scoreCount",
|
||||
label: "จำนวนที่บันทึกผลสอบ",
|
||||
align: "right",
|
||||
field: "scoreCount",
|
||||
sortable: true,
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const columnsHistory = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "description",
|
||||
align: "left",
|
||||
label: "รายละเอียด",
|
||||
sortable: true,
|
||||
field: "description",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "createdAt",
|
||||
align: "center",
|
||||
label: "วันที่ดำเนินการ",
|
||||
sortable: true,
|
||||
field: "createdAt",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "createdFullName",
|
||||
align: "left",
|
||||
label: "ผู้ดำเนินการ",
|
||||
sortable: true,
|
||||
field: "createdFullName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
]);
|
||||
|
||||
const visibleColumnsHistory = ref<String[]>([
|
||||
"description",
|
||||
"createdAt",
|
||||
"createdFullName",
|
||||
]);
|
||||
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
await fetchData();
|
||||
});
|
||||
|
||||
/**
|
||||
* ฟังก์ชันแปลง date เป็นภาษาไทย
|
||||
* @param value วันที่ type datetime ที่จะแปลงเป็นไทย
|
||||
*/
|
||||
const textDate = (value: Date) => {
|
||||
return dateText(value);
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getCandidates)
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
let result: ResponseRecruitPeriod[] = [];
|
||||
if (data.length > 0) {
|
||||
data.map((r: ResponseRecruitPeriod) => {
|
||||
if (r.score != null) {
|
||||
r.scoreCount = r.score.scoreCount;
|
||||
r.scoreImportDate = r.score.importDate;
|
||||
}
|
||||
result.push(r);
|
||||
});
|
||||
}
|
||||
|
||||
rows.value = result;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const clickPassExam = (id: string) => {
|
||||
window.open(config.API.exportPassExamList(id));
|
||||
};
|
||||
|
||||
const clickCandidateList = (id: string) => {
|
||||
window.open(config.API.exportCandidateList(id));
|
||||
};
|
||||
|
||||
const clickDetail = (id: string) => {
|
||||
router.push(`/compete/import/${id}`);
|
||||
};
|
||||
|
||||
const clickEdit = async (id: string) => {
|
||||
modalScore.value = true;
|
||||
textTittleScore.value = "นำเข้าผลคะแนนสอบแข่งขัน";
|
||||
selected_row_id.value = id;
|
||||
};
|
||||
|
||||
const clickUpload = async (id: string) => {
|
||||
modalCandidate.value = true;
|
||||
textTittleCandidate.value = "นำเข้าผู้สมัครสอบแข่งขัน";
|
||||
selected_row_id.value = id;
|
||||
};
|
||||
|
||||
const clickEditPeriod = (id: string) => {
|
||||
router.push(`/compete/period/${id}`);
|
||||
};
|
||||
|
||||
const clickHistory = async (id: string) => {
|
||||
modalHistory.value = true;
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getImportHistory(id))
|
||||
.then((res) => {
|
||||
const data = res.data.result;
|
||||
rowsHistory.value = [];
|
||||
if (data.length > 0) {
|
||||
data.map((i: ResponseHistoryObject) => {
|
||||
rowsHistory.value.push({
|
||||
createdAt: i.createdAt,
|
||||
createdFullName: i.createdFullName,
|
||||
createdUserId: i.createdUserId,
|
||||
id: i.id,
|
||||
isActive: i.isActive,
|
||||
lastUpdateFullName: i.lastUpdateFullName,
|
||||
lastUpdateUserId: i.lastUpdateUserId,
|
||||
lastUpdatedAt: i.lastUpdatedAt,
|
||||
description: i.description,
|
||||
});
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
modalError.value = true;
|
||||
modalErrorTittle.value = "ไม่พบประวัติการเผยแพร่";
|
||||
modalErrorDetail.value = e.response.data.message;
|
||||
statusCode.value = e.response.data.status;
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const clickDelete = (id: string) => {
|
||||
$q.dialog({
|
||||
title: "ยืนยันการลบข้อมูล",
|
||||
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
|
||||
cancel: {
|
||||
flat: true,
|
||||
color: "negative",
|
||||
},
|
||||
persistent: true,
|
||||
})
|
||||
.onOk(async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.deleteCandidates(id))
|
||||
.then((res) => {
|
||||
success($q, "ลบข้อมูลการสอบสำเร็จ");
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
})
|
||||
.onCancel(() => {})
|
||||
.onDismiss(() => {});
|
||||
};
|
||||
|
||||
const clickAdd = () => {
|
||||
router.push({ name: "competePeriodAdd" });
|
||||
};
|
||||
|
||||
const clickClose = async () => {
|
||||
modalAdd.value = false;
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const clickCloseScore = async () => {
|
||||
modalScore.value = false;
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const clickCloseCandidate = async () => {
|
||||
modalCandidate.value = false;
|
||||
await fetchData();
|
||||
};
|
||||
|
||||
const checkSaveCandidate = async () => {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files_candidate.value[0]);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.uploadCandidates(selected_row_id.value), fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผู้สมัครสอบสำเร็จ");
|
||||
modalCandidate.value = false;
|
||||
selected_row_id.value = "";
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const checkSaveScore = async () => {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files_score.value[0]);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.saveScores(selected_row_id.value), fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผลคะแนนสอบสำเร็จ");
|
||||
modalScore.value = false;
|
||||
selected_row_id.value = "";
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const checkSave = async () => {
|
||||
const fd = new FormData();
|
||||
fd.append("attachment", files.value[0]);
|
||||
fd.append("year", year.value.toString());
|
||||
fd.append("order", order.value.toString());
|
||||
fd.append("name", name.value);
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.saveCandidates, fd)
|
||||
.then((res) => {
|
||||
success($q, "นำเข้าข้อมูลผู้สมัครสอบแข่งขันสำเร็จ");
|
||||
modalAdd.value = false;
|
||||
fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,361 @@
|
|||
<!-- page:จัดการรอบการสอบแข่งขัน สรรหา -->
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { useQuasar, QForm } from "quasar";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
import type { RequestPeriodCompete } from "@/modules/03_recruiting/interface/request/Period";
|
||||
import type {
|
||||
DataOption,
|
||||
UploadType,
|
||||
} from "@/modules/02_organizational/interface/index/Main";
|
||||
|
||||
const $q = useQuasar(); // show dialog
|
||||
const mixin = useCounterMixin();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { date2Thai, success, dateToISO, messageError, showLoader, hideLoader } =
|
||||
mixin;
|
||||
|
||||
const myForm = ref<QForm | null>(null); //form data input
|
||||
const name = ref<string>("");
|
||||
const note = ref<string>("");
|
||||
const editor = ref<string>("");
|
||||
const announcementExam = ref<boolean>(true);
|
||||
const fee = ref<number>(0);
|
||||
const round = ref<number>(1);
|
||||
const yearly = ref<number>(new Date().getFullYear());
|
||||
const dateRegister = ref<[Date, Date] | null>(null); //วันที่สมัคร
|
||||
const datePayment = ref<[Date, Date] | null>(null); //วันที่จ่ายเงิน
|
||||
const dateAnnouncement = ref<[Date, Date] | null>(null); //วันที่ประกาศ
|
||||
const dateExam = ref<Date | null>(null); //วันที่สอบ
|
||||
const dateAnnounce = ref<Date | null>(null); //วันที่ประกาศผล
|
||||
const positionPathOptions = ref<DataOption[]>([]);
|
||||
const organizationShortName = ref<DataOption>({ id: "", name: "" });
|
||||
const organizationName = ref<DataOption>({ id: "", name: "" });
|
||||
const organizationNameOptions = ref<DataOption[]>([]);
|
||||
const fileDocDataUpload = ref<File[]>([]);
|
||||
const fileDocs = ref<UploadType[]>([]);
|
||||
const fileImgDataUpload = ref<File[]>([]);
|
||||
const fileImgs = ref<UploadType[]>([]);
|
||||
const id = ref<string>("");
|
||||
const edit = ref<boolean>(false);
|
||||
|
||||
/** กลับไปหน้าหลัก */
|
||||
function clickBack() {
|
||||
router.push({ name: "competePeriod" });
|
||||
}
|
||||
|
||||
/** ดึงรายละเอียด */
|
||||
async function fetchData() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getPeriodById(id.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result.periods;
|
||||
const images = res.data.result.images;
|
||||
const files = res.data.result.files;
|
||||
|
||||
id.value = data.id;
|
||||
name.value = data.name;
|
||||
round.value = data.order;
|
||||
yearly.value = data.year;
|
||||
fee.value = data.fee;
|
||||
dateAnnouncement.value =
|
||||
data.announcementStartDate != null && data.announcementEndDate != null
|
||||
? [
|
||||
new Date(data.announcementStartDate),
|
||||
new Date(data.announcementEndDate),
|
||||
]
|
||||
: null;
|
||||
dateExam.value = data.examDate != null ? new Date(data.examDate) : null;
|
||||
dateRegister.value =
|
||||
data.registerStartDate != null && data.registerEndDate != null
|
||||
? [new Date(data.registerStartDate), new Date(data.registerEndDate)]
|
||||
: null;
|
||||
datePayment.value =
|
||||
data.paymentStartDate != null && data.paymentEndDate != null
|
||||
? [new Date(data.paymentStartDate), new Date(data.paymentEndDate)]
|
||||
: null;
|
||||
|
||||
editor.value = data.detail;
|
||||
note.value = data.note;
|
||||
dateAnnounce.value =
|
||||
data.announcementDate != null ? new Date(data.announcementDate) : null;
|
||||
|
||||
fileDocs.value = files;
|
||||
fileImgs.value = images;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** อัพโหลดไฟล์ */
|
||||
async function fileUploadDoc(files: any) {
|
||||
files.forEach((file: any) => {
|
||||
fileDocDataUpload.value.push(file);
|
||||
});
|
||||
}
|
||||
|
||||
/** ลบไฟล์ เอกสาร */
|
||||
async function fileRemoveDoc(files: any) {
|
||||
files.forEach((file: any) => {
|
||||
const index = fileDocDataUpload.value.findIndex(
|
||||
(x: any) => x.__key == file.__key
|
||||
);
|
||||
if (index > -1) {
|
||||
fileDocDataUpload.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** อัพโหลด เอกสาร */
|
||||
async function uploadDocData() {
|
||||
const formData = new FormData();
|
||||
if (fileDocDataUpload.value.length > 0) {
|
||||
fileDocDataUpload.value.forEach((file: any) => {
|
||||
formData.append("", file);
|
||||
});
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.periodRecruitDoc(id.value), formData)
|
||||
.then((res) => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
clickBack();
|
||||
});
|
||||
} else {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
clickBack();
|
||||
}
|
||||
}
|
||||
|
||||
/** อัปโหลด รูปภาพ */
|
||||
async function uploadImgData() {
|
||||
if (fileImgDataUpload.value.length > 0) {
|
||||
const formData = new FormData();
|
||||
fileImgDataUpload.value.forEach((file: any) => {
|
||||
formData.append("", file);
|
||||
});
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.periodRecruitImg(id.value), formData)
|
||||
.then((res) => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** อัพโหลดไฟล์ immg */
|
||||
async function fileUploadImg(files: any) {
|
||||
files.forEach((file: any) => {
|
||||
fileImgDataUpload.value.push(file);
|
||||
});
|
||||
}
|
||||
|
||||
/** ฟังชั่น ลบ รูป */
|
||||
async function fileRemoveImg(files: any) {
|
||||
files.forEach((file: any) => {
|
||||
const index = fileImgDataUpload.value.findIndex(
|
||||
(x: any) => x.__key == file.__key
|
||||
);
|
||||
if (index > -1) {
|
||||
fileImgDataUpload.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ดาวห์โหลดไฟล์
|
||||
* @param path ที่อยู่ url
|
||||
*/
|
||||
async function downloadData(path: string) {
|
||||
window.open(path);
|
||||
}
|
||||
|
||||
/**
|
||||
* อัพเดต ปี
|
||||
* @param e ปี
|
||||
*/
|
||||
async function updateYear(e: number) {
|
||||
yearly.value = e;
|
||||
}
|
||||
|
||||
/** ฟังชั่น add edit */
|
||||
async function checkSave() {
|
||||
if (myForm.value !== null) {
|
||||
myForm.value.validate().then(async (success) => {
|
||||
if (success) {
|
||||
if (edit.value) {
|
||||
await editData(id.value);
|
||||
} else {
|
||||
await addData();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** body ที่บันทึก */
|
||||
function sendData() {
|
||||
const valueData: RequestPeriodCompete = {
|
||||
announcementEndDate:
|
||||
dateAnnouncement.value !== null
|
||||
? dateToISO(dateAnnouncement.value[1])
|
||||
: null,
|
||||
announcementStartDate:
|
||||
dateAnnouncement.value !== null
|
||||
? dateToISO(dateAnnouncement.value[0])
|
||||
: null,
|
||||
examDate: dateExam.value !== null ? dateToISO(dateExam.value) : null,
|
||||
detail: editor.value,
|
||||
fee: fee.value,
|
||||
id: "",
|
||||
name: name.value,
|
||||
note: note.value,
|
||||
paymentEndDate:
|
||||
datePayment.value !== null ? dateToISO(datePayment.value[1]) : null,
|
||||
paymentStartDate:
|
||||
datePayment.value !== null ? dateToISO(datePayment.value[0]) : null,
|
||||
registerEndDate:
|
||||
dateRegister.value !== null ? dateToISO(dateRegister.value[1]) : null,
|
||||
registerStartDate:
|
||||
dateRegister.value !== null ? dateToISO(dateRegister.value[0]) : null,
|
||||
order: round.value,
|
||||
year: yearly.value,
|
||||
announcementDate:
|
||||
dateAnnounce.value !== null ? dateToISO(dateAnnounce.value) : null,
|
||||
};
|
||||
return valueData;
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบ เอกสารประกอบ
|
||||
* @param docId id เอกสาร
|
||||
*/
|
||||
async function deleteDocData(docId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.periodDeleteDoc(docId))
|
||||
.then(async () => {
|
||||
await fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบรูปประกอบ
|
||||
* @param docId id ของรูป
|
||||
*/
|
||||
async function deleteImgData(docId: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.periodDeleteImg(docId))
|
||||
.then(async () => {
|
||||
await fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/** เพิ่ม รอบสอบแข่งขัน */
|
||||
async function addData() {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.savePeriod, sendData())
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
id.value = data.id;
|
||||
await uploadImgData();
|
||||
await uploadDocData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* บันทึก แก้ไขข้อมูล
|
||||
* @param id
|
||||
*/
|
||||
async function editData(id: string) {
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.editPeriod(id), sendData())
|
||||
.then(async () => {
|
||||
await uploadImgData();
|
||||
await uploadDocData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* แปลงช่วงวันที่ถ้า2ค่าเป็นวันเดียวกันจะโชววันเดียวแต่ถ้าไม่เท่ากันจะแสดงเป็นช่วง
|
||||
* @param val ช่วงวันที่
|
||||
*/
|
||||
function dateThaiRange(val: [Date, Date]) {
|
||||
if (val === null) {
|
||||
return "";
|
||||
} else if (date2Thai(val[0], true) === date2Thai(val[1], true)) {
|
||||
return `${date2Thai(val[0], true)}`;
|
||||
} else {
|
||||
return `${date2Thai(val[0], true)} - ${date2Thai(val[1], true)}`;
|
||||
}
|
||||
}
|
||||
|
||||
watch(organizationShortName, (count: DataOption, prevCount: DataOption) => {
|
||||
organizationNameOptions.value = [];
|
||||
});
|
||||
|
||||
watch(organizationName, (count: DataOption, prevCount: DataOption) => {
|
||||
positionPathOptions.value = [];
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
if (route.params.id != undefined) {
|
||||
edit.value = true;
|
||||
id.value = route.params.id.toString();
|
||||
await fetchData();
|
||||
} else {
|
||||
edit.value = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
<q-btn
|
||||
|
|
@ -36,6 +393,7 @@
|
|||
label="รอบการสอบ(ครั้ง)"
|
||||
dense
|
||||
lazy-rules
|
||||
hide-bottom-space
|
||||
:rules="[(val) => val > 0 || `${'กรุณากรอกรอบการสอบให้ถูกต้อง'}`]"
|
||||
></q-input>
|
||||
</div>
|
||||
|
|
@ -56,6 +414,7 @@
|
|||
<template #trigger>
|
||||
<q-input
|
||||
dense
|
||||
hide-bottom-space
|
||||
outlined
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือกปีงบประมาณ'}`]"
|
||||
:model-value="yearly + 543"
|
||||
|
|
@ -77,6 +436,7 @@
|
|||
<q-input
|
||||
outlined
|
||||
v-model="fee"
|
||||
hide-bottom-space
|
||||
type="number"
|
||||
label="ค่าธรรมเนียม"
|
||||
lazy-rules
|
||||
|
|
@ -655,405 +1015,5 @@
|
|||
</q-form>
|
||||
</q-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import type { QTableProps } from "quasar";
|
||||
import { onMounted, ref, watch } from "vue";
|
||||
import { useQuasar, QForm } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import type { RequestPeriodCompete } from "@/modules/03_recruiting/interface/request/Period";
|
||||
import type {
|
||||
DataOption,
|
||||
UploadType,
|
||||
} from "@/modules/02_organizational/interface/index/Main";
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
const $q = useQuasar(); // show dialog
|
||||
const mixin = useCounterMixin();
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const { date2Thai, success, dateToISO, notifyError, showLoader, hideLoader } =
|
||||
mixin;
|
||||
const myForm = ref<QForm | null>(null); //form data input
|
||||
const name = ref<string>("");
|
||||
const note = ref<string>("");
|
||||
const editor = ref<string>("");
|
||||
const announcementExam = ref<boolean>(true);
|
||||
const fee = ref<number>(0);
|
||||
const round = ref<number>(1);
|
||||
const yearly = ref<number>(new Date().getFullYear());
|
||||
const dateRegister = ref<[Date, Date] | null>(null); //วันที่สมัคร
|
||||
const datePayment = ref<[Date, Date] | null>(null); //วันที่จ่ายเงิน
|
||||
const dateAnnouncement = ref<[Date, Date] | null>(null); //วันที่ประกาศ
|
||||
const dateExam = ref<Date | null>(null); //วันที่สอบ
|
||||
const dateAnnounce = ref<Date | null>(null); //วันที่ประกาศผล
|
||||
const positionPathOptions = ref<DataOption[]>([]);
|
||||
const organizationShortName = ref<DataOption>({ id: "", name: "" });
|
||||
const organizationName = ref<DataOption>({ id: "", name: "" });
|
||||
const organizationNameOptions = ref<DataOption[]>([]);
|
||||
const { messageError } = mixin;
|
||||
const fileDocDataUpload = ref<File[]>([]);
|
||||
const fileDocs = ref<UploadType[]>([]);
|
||||
const fileImgDataUpload = ref<File[]>([]);
|
||||
const fileImgs = ref<UploadType[]>([]);
|
||||
const id = ref<string>("");
|
||||
const pay = ref<string>("");
|
||||
const edit = ref<boolean>(false);
|
||||
const columnsPayment = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "accountNumber",
|
||||
align: "left",
|
||||
label: "เลขบัญชี",
|
||||
sortable: true,
|
||||
field: "accountNumber",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "bankName",
|
||||
align: "left",
|
||||
label: "ธนาคาร",
|
||||
sortable: true,
|
||||
field: "bankName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "accountName",
|
||||
align: "left",
|
||||
label: "ชื่อบัญชี",
|
||||
sortable: true,
|
||||
field: "accountName",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
const visibleColumnsPosition = ref<String[]>(["position", "type"]);
|
||||
const columnsPosition = ref<QTableProps["columns"]>([
|
||||
{
|
||||
name: "position",
|
||||
align: "left",
|
||||
label: "ตำแหน่ง",
|
||||
sortable: true,
|
||||
field: "position",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "type",
|
||||
align: "left",
|
||||
label: "ประเภทแบบฟอร์ม",
|
||||
sortable: true,
|
||||
field: "type",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
watch(organizationShortName, (count: DataOption, prevCount: DataOption) => {
|
||||
organizationNameOptions.value = [];
|
||||
});
|
||||
|
||||
watch(organizationName, (count: DataOption, prevCount: DataOption) => {
|
||||
positionPathOptions.value = [];
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
hideLoader();
|
||||
if (route.params.id != undefined) {
|
||||
edit.value = true;
|
||||
id.value = route.params.id.toString();
|
||||
await fetchData();
|
||||
} else {
|
||||
edit.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
const clickBack = () => {
|
||||
router.push({ name: "competePeriod" });
|
||||
};
|
||||
|
||||
const fetchData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.getPeriodById(id.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result.periods;
|
||||
const images = res.data.result.images;
|
||||
const files = res.data.result.files;
|
||||
|
||||
id.value = data.id;
|
||||
name.value = data.name;
|
||||
round.value = data.order;
|
||||
yearly.value = data.year;
|
||||
fee.value = data.fee;
|
||||
dateAnnouncement.value =
|
||||
data.announcementStartDate != null && data.announcementEndDate != null
|
||||
? [
|
||||
new Date(data.announcementStartDate),
|
||||
new Date(data.announcementEndDate),
|
||||
]
|
||||
: null;
|
||||
dateExam.value = data.examDate != null ? new Date(data.examDate) : null;
|
||||
dateRegister.value =
|
||||
data.registerStartDate != null && data.registerEndDate != null
|
||||
? [new Date(data.registerStartDate), new Date(data.registerEndDate)]
|
||||
: null;
|
||||
datePayment.value =
|
||||
data.paymentStartDate != null && data.paymentEndDate != null
|
||||
? [new Date(data.paymentStartDate), new Date(data.paymentEndDate)]
|
||||
: null;
|
||||
|
||||
editor.value = data.detail;
|
||||
note.value = data.note;
|
||||
dateAnnounce.value =
|
||||
data.announcementDate != null ? new Date(data.announcementDate) : null;
|
||||
|
||||
fileDocs.value = files;
|
||||
fileImgs.value = images;
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const fileUploadDoc = async (files: any) => {
|
||||
files.forEach((file: any) => {
|
||||
fileDocDataUpload.value.push(file);
|
||||
});
|
||||
};
|
||||
|
||||
const fileRemoveDoc = async (files: any) => {
|
||||
files.forEach((file: any) => {
|
||||
const index = fileDocDataUpload.value.findIndex(
|
||||
(x: any) => x.__key == file.__key
|
||||
);
|
||||
if (index > -1) {
|
||||
fileDocDataUpload.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const uploadDocData = async () => {
|
||||
const formData = new FormData();
|
||||
if (fileDocDataUpload.value.length > 0) {
|
||||
fileDocDataUpload.value.forEach((file: any) => {
|
||||
formData.append("", file);
|
||||
});
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.periodRecruitDoc(id.value), formData)
|
||||
.then((res) => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
clickBack();
|
||||
});
|
||||
} else {
|
||||
success($q, "บันทึกข้อมูลสำเร็จ");
|
||||
clickBack();
|
||||
}
|
||||
};
|
||||
|
||||
const uploadImgData = async () => {
|
||||
if (fileImgDataUpload.value.length > 0) {
|
||||
const formData = new FormData();
|
||||
fileImgDataUpload.value.forEach((file: any) => {
|
||||
formData.append("", file);
|
||||
});
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.periodRecruitImg(id.value), formData)
|
||||
.then((res) => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const fileUploadImg = async (files: any) => {
|
||||
files.forEach((file: any) => {
|
||||
fileImgDataUpload.value.push(file);
|
||||
});
|
||||
};
|
||||
|
||||
const fileRemoveImg = async (files: any) => {
|
||||
files.forEach((file: any) => {
|
||||
const index = fileImgDataUpload.value.findIndex(
|
||||
(x: any) => x.__key == file.__key
|
||||
);
|
||||
if (index > -1) {
|
||||
fileImgDataUpload.value.splice(index, 1);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const downloadData = async (path: string) => {
|
||||
window.open(path);
|
||||
};
|
||||
|
||||
const updateYear = async (e: number) => {
|
||||
yearly.value = e;
|
||||
};
|
||||
|
||||
const checkSave = async () => {
|
||||
if (myForm.value !== null) {
|
||||
myForm.value.validate().then(async (success) => {
|
||||
if (success) {
|
||||
if (edit.value) {
|
||||
await editData(id.value);
|
||||
} else {
|
||||
await addData();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const sendData = () => {
|
||||
const valueData: RequestPeriodCompete = {
|
||||
announcementEndDate:
|
||||
dateAnnouncement.value !== null
|
||||
? dateToISO(dateAnnouncement.value[1])
|
||||
: null,
|
||||
announcementStartDate:
|
||||
dateAnnouncement.value !== null
|
||||
? dateToISO(dateAnnouncement.value[0])
|
||||
: null,
|
||||
examDate: dateExam.value !== null ? dateToISO(dateExam.value) : null,
|
||||
detail: editor.value,
|
||||
fee: fee.value,
|
||||
id: "",
|
||||
name: name.value,
|
||||
note: note.value,
|
||||
paymentEndDate:
|
||||
datePayment.value !== null ? dateToISO(datePayment.value[1]) : null,
|
||||
paymentStartDate:
|
||||
datePayment.value !== null ? dateToISO(datePayment.value[0]) : null,
|
||||
registerEndDate:
|
||||
dateRegister.value !== null ? dateToISO(dateRegister.value[1]) : null,
|
||||
registerStartDate:
|
||||
dateRegister.value !== null ? dateToISO(dateRegister.value[0]) : null,
|
||||
order: round.value,
|
||||
year: yearly.value,
|
||||
announcementDate:
|
||||
dateAnnounce.value !== null ? dateToISO(dateAnnounce.value) : null,
|
||||
};
|
||||
return valueData;
|
||||
};
|
||||
|
||||
const deleteDocData = async (docId: string) => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.periodDeleteDoc(docId))
|
||||
.then(async () => {
|
||||
await fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const deleteImgData = async (docId: string) => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.periodDeleteImg(docId))
|
||||
.then(async () => {
|
||||
await fetchData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const addData = async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.post(config.API.savePeriod, sendData())
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
id.value = data.id;
|
||||
await uploadImgData();
|
||||
await uploadDocData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
const editData = async (id: string) => {
|
||||
showLoader();
|
||||
await http
|
||||
.put(config.API.editPeriod(id), sendData())
|
||||
.then(async () => {
|
||||
await uploadImgData();
|
||||
await uploadDocData();
|
||||
})
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {
|
||||
hideLoader();
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* แปลงช่วงวันที่ถ้า2ค่าเป็นวันเดียวกันจะโชววันเดียวแต่ถ้าไม่เท่ากันจะแสดงเป็นช่วง
|
||||
* @param val ช่วงวันที่
|
||||
*/
|
||||
const dateThaiRange = (val: [Date, Date]) => {
|
||||
if (val === null) {
|
||||
return "";
|
||||
} else if (date2Thai(val[0], true) === date2Thai(val[1], true)) {
|
||||
return `${date2Thai(val[0], true)}`;
|
||||
} else {
|
||||
return `${date2Thai(val[0], true)} - ${date2Thai(val[1], true)}`;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,4 @@
|
|||
<!-- page:จัดการรอบการสอบ สรรหา -->
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
สถิติสมัครสอบแข่งขัน
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-px-md q-py-sm">
|
||||
<iframe
|
||||
:src="panelUrl"
|
||||
style="height: 80vh; width: 100%; border: none; overflow: hidden"
|
||||
></iframe>
|
||||
</q-card>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import config from "@/app.config";
|
||||
import { ref, onBeforeMount } from "vue";
|
||||
|
|
@ -21,4 +10,16 @@ onBeforeMount(async () => {
|
|||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="toptitle text-dark col-12 row items-center">
|
||||
สถิติสมัครสอบแข่งขัน
|
||||
</div>
|
||||
<q-card flat bordered class="col-12 q-mt-sm q-px-md q-py-sm">
|
||||
<iframe
|
||||
:src="panelUrl"
|
||||
style="height: 80vh; width: 100%; border: none; overflow: hidden"
|
||||
></iframe>
|
||||
</q-card>
|
||||
</template>
|
||||
|
||||
<style></style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue