Refactoring code module 05_placement

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-09-19 15:02:44 +07:00
parent 202fbf27b6
commit 4678ead38e
75 changed files with 3110 additions and 10795 deletions

View file

@ -13,18 +13,17 @@ import { useCounterMixin } from "@/stores/mixin";
const { date2Thai } = useCounterMixin();
/** props*/
const selected = defineModel("selectedPos", { required: true });
const positionId = defineModel<string>("positionId", { required: true });
const seletcId = defineModel<string>("seletcId", { required: true });
const date = defineModel<Date>("datePos", { required: true });
const positionData = defineModel<any[]>("position", { required: true });
const isAll = defineModel<boolean>("isAll", { required: true });
const isBlank = defineModel<boolean>("isBlank", { required: true });
const selected = defineModel("selectedPos", { required: true }); //
const positionId = defineModel<string>("positionId", { required: true }); //id
const seletcId = defineModel<string>("seletcId", { required: true }); //
const date = defineModel<Date>("datePos", { required: true }); //
const positionData = defineModel<any[]>("position", { required: true }); //
const isAll = defineModel<boolean>("isAll", { required: true }); //
const isBlank = defineModel<boolean>("isBlank", { required: true }); //
const filters = ref<string>("");
const rowsPosition = ref<Positions[]>([]);
/** columns*/
//Table
const filters = ref<string>(""); //
const rowsPosition = ref<Positions[]>([]); //
const columns = ref<QTableProps["columns"]>([
{
name: "isPosition",
@ -90,7 +89,6 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const columnsPostition = ref<QTableProps["columns"]>([
{
name: "no",
@ -165,7 +163,6 @@ const columnsPostition = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
]);
const visibleColumns = ref<string[]>([
"isPosition",
"no",
@ -195,10 +192,12 @@ async function onClickSelectPos(id: string) {
(e) => e.id === seletcId.value
);
}
console.log(selected.value);
}
}
/**
* ทำงานเม Components กเรยกใชงาน
*/
onMounted(async () => {
if (positionId.value) {
setTimeout(async () => {

View file

@ -1,22 +1,24 @@
<script setup lang="ts">
import { ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import DialogHeader from "@/components/DialogHeader.vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import type { QTableProps } from "quasar";
import type { DataEducation } from "@/modules/05_placement/interface/index/Main";
import type {
DataPerson,
Education,
} from "@/modules/05_placement/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
const $q = useQuasar();
const mixin = useCounterMixin(); //
const { showLoader, hideLoader, date2Thai, messageError } = mixin;
const rows = ref<any[]>([]);
const myForm = ref<any>([]);
const selection = ref<any>([]);
const personalForm = ref<any>([]);
/** รับค่ามาจากหน้าหลัก */
const props = defineProps({
Modal: Boolean,
@ -34,6 +36,9 @@ const props = defineProps({
},
});
const rows = ref<DataEducation[]>([]);
const personalForm = ref<DataPerson>();
/**หัวตาราง */
const columns = ref<QTableProps["columns"]>([
{
@ -78,16 +83,18 @@ const columns = ref<QTableProps["columns"]>([
},
]);
/** get ข้อมูลการศึกษา */
/**
* งกนดงขอมลรายละเอยด
*/
async function fetchData() {
showLoader();
await http
.get(config.API.getDatapersonal(props.personalId))
.then((res) => {
personalForm.value = res.data.result;
personalForm.value.education.map((e: any) => {
personalForm.value?.education.map((e: Education) => {
rows.value.push({
university: e.name,
university: e.institute,
degree: e.degree,
major: e.field,
graduation: date2Thai(e.finishDate),
@ -103,8 +110,8 @@ async function fetchData() {
}
/**
* convert text
* @param val type
* งกนแปลงประเภทขาราชการ เปนไทย
* @param val ประเภทขาราชการ
*/
function formBmaofficer(val: string) {
switch (val) {
@ -119,14 +126,17 @@ function formBmaofficer(val: string) {
}
}
/** ปิด POPUP ข้อมูล */
/**
* POPUP อม
*/
async function close() {
props.close();
selection.value = [];
rows.value = [];
}
/** เมื่อ props.Modal จะเรียกข้อมูลการศึกษา */
/**
* เม props.Modal เป true จะเรยกขอมลการศกษา
*/
watch(props, () => {
if (props.Modal === true) {
fetchData();
@ -136,9 +146,9 @@ watch(props, () => {
<template>
<q-dialog v-model="props.Modal" persistent>
<q-card style="max-width: 100%; width: 80%">
<q-form ref="myForm">
<q-form>
<DialogHeader
:tittle="`รายละเอียดของ ${personalForm.fullName}`"
:tittle="`รายละเอียดของ ${personalForm?.fullName}`"
:close="close"
/>
@ -150,7 +160,7 @@ watch(props, () => {
<div class="row items-center q-pa-xs header-text">
อมลทวไป
<span
v-if="personalForm.bmaOfficer != null"
v-if="personalForm?.bmaOfficer != null"
class="check-officer"
>
<q-icon name="mdi-check" />
@ -166,10 +176,10 @@ watch(props, () => {
<div class="col-4 sub-text">
<div class="q-pb-md">
{{ personalForm.idCard }}
{{ personalForm?.idCard }}
</div>
<div>
{{ date2Thai(personalForm.dateOfBirth) }}
{{ date2Thai(personalForm?.dateOfBirth) }}
</div>
</div>
@ -179,10 +189,10 @@ watch(props, () => {
</div>
<div class="col-3 sub-text">
<div class="q-pb-md">
{{ personalForm.fullName }}
{{ personalForm?.fullName }}
</div>
<div>
{{ personalForm.gender }}
{{ personalForm?.gender }}
</div>
</div>
</div>
@ -195,7 +205,7 @@ watch(props, () => {
<div class="row q-pa-xs">
<div class="col-3 header-sub-text">อย</div>
<div class="col-9 sub-text">
{{ personalForm.address }}
{{ personalForm?.registAddress }}
</div>
</div>
</q-card>
@ -233,10 +243,10 @@ watch(props, () => {
</div>
<div class="col-5 sub-text-exam">
<div class="q-pb-sm">
{{ personalForm.pass }}
{{ personalForm?.pass }}
</div>
<div class="q-pb-sm">{{ personalForm.examNumber }}</div>
<div class="q-pb-sm">{{ personalForm.examRound }}</div>
<div class="q-pb-sm">{{ personalForm?.examNumber }}</div>
<div class="q-pb-sm">{{ personalForm?.examRound }}</div>
</div>
</div>
</div>

View file

@ -1,32 +1,30 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import { tokenParsed } from "@/plugins/auth";
import { useQuasar } from "quasar";
import { tokenParsed } from "@/plugins/auth";
import { useRouter, useRoute } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import { usePlacementDataStore } from "@/modules/05_placement/store";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
import { usePlacementDataStore } from "@/modules/05_placement/store";
import CardTop from "@/modules/05_placement/components/PersonalList/StatCard.vue";
import AddTablePosition from "@/modules/05_placement/components/PersonalList/Table.vue";
const DataStore = usePlacementDataStore();
let roleAdmin = ref<boolean>(false);
const $q = useQuasar;
const mixin = useCounterMixin();
const { messageError, showLoader, hideLoader } = mixin;
const $q = useQuasar();
const router = useRouter();
const route = useRoute();
const mixin = useCounterMixin();
const DataStore = usePlacementDataStore();
const { messageError, showLoader, hideLoader } = mixin;
const examId = route.params.examId;
const year = ref<string>("");
const round = ref<string>("");
const title = ref<string>("");
const examData = ref<any>();
const roleAdmin = ref<boolean>(false);
const stat = ref<any>({
total: 0,
unContain: 0,
@ -35,7 +33,9 @@ const stat = ref<any>({
disclaim: 0,
});
/** เรียกข้อมูล Stat */
/**
* เรยกขอม Stat
*/
async function getStat() {
const examIdString = Array.isArray(examId) ? examId[0] : examId;
await http
@ -56,7 +56,9 @@ async function getStat() {
});
}
/** get รายละเอียด ของการสอบ */
/**
* get รายละเอยด ของการสอบ
*/
async function fetchPlacementData() {
showLoader();
await http

View file

@ -16,13 +16,23 @@ import type { QTableProps } from "quasar";
import type { DataList } from "@/modules/05_placement/interface/response/SelectOrg";
import DialogSelectOrg from "@/modules/05_placement/components/PersonalList/DialogSelectOrg.vue";
import Table from "@/modules/05_placement/components/PersonalList/TableView.vue";
import DialogCard from "@/modules/05_placement/components/PersonalList/DialogDetail.vue";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import DialogHeader from "@/components/DialogHeader.vue";
let roleAdmin = ref<boolean>(false);
const route = useRoute();
const mixin = useCounterMixin(); //
const $q = useQuasar(); // show dialog
const {
messageError,
showLoader,
hideLoader,
dateText,
success,
dialogConfirm,
date2Thai,
} = mixin;
/** รับค่ามาจากหน้าหลัก */
const props = defineProps({
@ -32,6 +42,7 @@ const props = defineProps({
},
});
let roleAdmin = ref<boolean>(false);
const edit = ref<boolean>(true);
const modal = ref<boolean>(false); //modal +
const editRow = ref<boolean>(false); //
@ -49,8 +60,7 @@ const rows = ref<any[]>([]);
const rowsFilter = ref<any>([]);
const myForm = ref<any>();
const files = ref<any>(null);
const mixin = useCounterMixin(); //
const $q = useQuasar(); // show dialog
const appointModal = ref<boolean>(false);
const getNumFile = ref(0);
const dataRes = ref<any>([]);
@ -69,25 +79,12 @@ const checkSelected = computed(() => {
return true;
}
});
const pagination = ref({
page: 1,
rowsPerPage: 10,
});
const dataInfo = reactive({
reason: "",
reliefDoc: "",
});
const {
messageError,
showLoader,
hideLoader,
dateText,
success,
dialogConfirm,
date2Thai,
} = mixin;
const route = useRoute();
const examId = route.params.examId;
const examIdString = Array.isArray(examId) ? examId[0] : examId;
const personalId = ref<string>("");
@ -251,6 +248,10 @@ function convertContainStatus(val: string, type: string = "") {
}
}
/**
* แปลงสถานะ
* @param val type
*/
function convertTypeCommand(val: string) {
switch (val) {
case "APPOINTED":
@ -281,7 +282,9 @@ function convertDraft(val: boolean) {
}
}
/**เรียกข้อมูลรายชื่อผู้สอบผ่าน */
/**
* เรยกขอมลรายชอผสอบผาน
*/
async function getTable() {
showLoader();
await http
@ -389,7 +392,9 @@ async function getTable() {
});
}
/**ยืนยันการผ่อนผัน */
/**
* นยนการผอนผ
*/
async function saveDeferment() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
@ -402,7 +407,9 @@ async function saveDeferment() {
}
});
}
/**post ผ่อนผัน */
/**
* post อนผ
*/
async function postDeferment() {
showLoader();
const formData = new FormData();
@ -425,7 +432,9 @@ async function postDeferment() {
});
}
/**ยืนยันการสละสิทธิ์ */
/**
* นยนการสละสทธ
*/
async function saveDisclaim() {
myForm.value.validate().then(async (result: boolean) => {
if (result) {
@ -439,7 +448,9 @@ async function saveDisclaim() {
});
}
/**post การสละสิทธิ์ */
/**
* post การสละสทธ
*/
async function postDisclaimf() {
showLoader();
const dataPost = {
@ -462,12 +473,16 @@ async function postDisclaimf() {
});
}
/** เปิด dialog */
/**
* dialog
*/
function clickEditRow() {
editRow.value = true;
}
/** เปลี่ยน class true/false */
/**
* เปลยน class true/false
*/
function getClass(val: boolean) {
return {
"full-width inputgreen cursor-pointer ": val,
@ -553,26 +568,23 @@ function openAppointModal(
data: DataList,
typeCommandVal: "APPOINTED" | "APPOINT" | "SLIP" | "MOVE"
) {
// appointModal.value = true;
// personalId.value = pid;
// personal.value = dataRes.value.filter(
// (e: any) => e.personalId == personalId.value
// );
// console.log(personal.value);
dataRow.value = data;
typeCommand.value = typeCommandVal;
modalDialogSelectOrg.value = !modalDialogSelectOrg.value;
}
/** close dialog */
/**
* close dialog
*/
async function clickCloseModalTree() {
await getTable();
appointModal.value = false;
props.statCard();
}
/** validate */
/**
* validate
*/
async function validateData() {
checkValidate.value = true;
await myForm.value.validate().then((result: boolean) => {
@ -582,12 +594,16 @@ async function validateData() {
});
}
/** ปิด dialog */
/**
* dialog
*/
function clickCloseSendModal() {
modaladdlist.value = false;
}
/** validate */
/**
* validate
*/
async function clickClose() {
userNote.value = "";
if (editRow.value == true) {
@ -610,7 +626,9 @@ async function clickClose() {
}
}
/** ยืนยันส่งรายชื่อไปหน่วยงาน */
/**
* นยนสงรายชอไปหนวยงาน
*/
function savelist() {
selected.value.map((e: any) => {
personal_selected.value.push(e.personalId);
@ -654,14 +672,6 @@ function paginationLabel(start: number, end: number, total: number) {
else return start + "-" + end + " ใน " + total;
}
watch(containStatus, () => {
if (containStatus.value) {
rows.value = rowsAll.value.filter((x: any) => x.statusId == "CONTAIN");
} else {
rows.value = rowsAll.value.filter((x: any) => x.statusId != "CONTAIN");
}
});
function onRestorePos(id: string) {
dialogConfirm(
$q,
@ -713,6 +723,14 @@ function onSubmitDate() {
});
}
watch(containStatus, () => {
if (containStatus.value) {
rows.value = rowsAll.value.filter((x: any) => x.statusId == "CONTAIN");
} else {
rows.value = rowsAll.value.filter((x: any) => x.statusId != "CONTAIN");
}
});
onMounted(async () => {
const user = await tokenParsed();
if (user) {
@ -754,7 +772,7 @@ onMounted(async () => {
:boss="true"
:saveNoDraft="true"
:role-admin="roleAdmin"
:displayAdd="displayAdd"
:display-add="displayAdd"
row-key="fullname"
>
<template #columns="props">
@ -1382,24 +1400,6 @@ onMounted(async () => {
</div>
</q-item-section>
</q-item>
<!-- <div class="row col-12 text-no-wrap items-center">
<img
v-if="props.row.avatar == ''"
src="@/assets/avatar_user.jpg"
class="col-4 img-info"
/>
<img
v-else
:src="props.row.avatar"
class="col-4 img-info"
/>
<div class="col-4">
<div class="text-weight-medium">{{ props.row.name }}</div>
<div class="text-weight-light">
{{ props.row.idCard }}
</div>
</div>
</div> -->
</template>
<template v-else-if="col.name === 'examNumber'">
<div class="text-weight-medium">
@ -1482,17 +1482,6 @@ onMounted(async () => {
</q-td>
</q-tr>
</template>
<!-- <template v-slot:pagination="scope">
<q-pagination
v-model="pagination.page"
color="primary"
:max="scope.pagesNumber"
:max-pages="5"
size="sm"
boundary-links
direction-links
></q-pagination>
</template> -->
</d-table>
</q-card-section>
<q-separator />
@ -1513,10 +1502,10 @@ onMounted(async () => {
<!-- เลอกหนวยงานทบรรจ -->
<DialogSelectOrg
v-model:modal="modalDialogSelectOrg"
:dataRow="dataRow"
:fetchTable="getTable"
:fetchStatCard="statCard"
:typeCommand="typeCommand"
:data-row="dataRow"
:fetch-table="getTable"
:fetch-stat-card="statCard"
:type-command="typeCommand"
/>
<!-- dialog นรายงานต-->