Refactoring code module 03_recruiting

This commit is contained in:
STW_TTTY\stwtt 2024-09-17 15:56:06 +07:00
parent b223c2433e
commit 87e2e3b080
36 changed files with 6139 additions and 6335 deletions

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>