Refactoring code module 06_retirement

This commit is contained in:
STW_TTTY\stwtt 2024-09-18 15:18:57 +07:00
parent 1225254062
commit ea921b39b0
29 changed files with 730 additions and 823 deletions

View file

@ -2,9 +2,10 @@
import { onMounted, reactive, ref } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import type { QForm } from "quasar";
@ -116,64 +117,8 @@ const question10Desc = ref<string>("ความคิดเห็นและ
const question10Answer = ref<any>([]);
const question10Score = ref<number>(0);
/**
* วเลอกแบบสอบถาม(จำลอง)
*/
const exitFactor = ref<any>([]);
const reasonWork = ref<any>([]);
const adjust = ref<any>([]);
const timeThink = ref<any>();
const realReason = ref<any>("");
const notExitFactor = ref<any>("");
const haveJob = ref<any>();
const suggestFriends = ref<any>();
const futureWork = ref<any>();
const suggestion = ref<any>("");
const suggestFriendsReason = ref("");
const suggestFriends_option = ref<any>([
{ label: "แนะนำ ", value: true },
{ label: "ไม่แนะนำ (ระบุ)", value: false },
]);
const haveJobReason = ref<any>("");
const haveJob_option = ref<any>([
{ label: "มี (ระบุ) ", value: true },
{ label: "ไม่มี", value: false },
]);
const futureWorkReason = ref<any>("");
const futureWork_option = ref<any>([
{ label: "อยาก ", value: true },
{ label: "ไม่อยาก (ระบุ)", value: false },
]);
const adjustOther = ref("");
const adjust_option = ref<any>([
{ label: "อัตราเงินเดือน ", value: 0 },
{ label: "สวัสดิการ", value: 1 },
{ label: "ลักษณะงาน ", value: 2 },
{ label: "ระบบการทำงาน ", value: 3 },
{ label: "ระบบสนับสนุนการปฏิบัติงาน ", value: 4 },
{ label: "การมอบหมายงานที่ชัดเจนและเหมาะสม ", value: 5 },
{ label: "การบริหารงานของผู้บังคับบัญชา", value: 6 },
{ label: "การทำงานเป็นทีมกับเพื่อนร่วมงาน ", value: 7 },
{ label: "ระบบบริหารงานภายในหน่วยงาน ", value: 8 },
{ label: "บรรยากาศในการทำงาน ", value: 9 },
{ label: "การปฏิบัติอย่างเป็นธรรม ", value: 10 },
{ label: "การยอมรับความแตกต่างหลากหลาย ", value: 11 },
{ label: "การดูแลและให้ความช่วยเหลือในช่วงเริ่มต้นปฏิบัติงาน ", value: 12 },
{ label: "การพัฒนาอย่างเป็นระบบและต่อเนื่อง ", value: 13 },
{ label: "โอกาสความก้าวหน้า ", value: 14 },
// { label: " () ", value: 15 },
]);
/**
* HOOK
*/
onMounted(async () => {
await getData();
});
//
const getData = async () => {
async function getData() {
showLoader();
await http
.get(config.API.questionExitInterview())
@ -216,15 +161,15 @@ const getData = async () => {
.finally(() => {
hideLoader();
});
};
}
/**
* งกนเชคขอมลกอนคอนเฟร
*/
const confirmClick = () => {
function confirmClick() {
dialogConfirm($q, () => putData());
};
const putData = () => {
}
function putData() {
const body = {
question1Desc: question1Desc.value,
question1Score: question1Score.value,
@ -279,7 +224,14 @@ const putData = () => {
.finally(() => {
hideLoader();
});
};
}
/**
* HOOK
*/
onMounted(async () => {
await getData();
});
</script>
<template>
<div class="toptitle text-dark col-12 row items-center">

View file

@ -2,17 +2,17 @@
import { ref, onMounted } from "vue";
import { useQuasar, QForm } from "quasar";
import { useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { checkPermission } from "@/utils/permissions";
/**Import type */
import type { QTableProps } from "quasar";
import type { ResponseItems } from "@/modules/06_retirement/interface/response/exitInterview";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import DialogHeader from "@/components/DialogHeader.vue";
import { checkPermission } from "@/utils/permissions";
import DialogHeader from "@/components/DialogHeader.vue";
/** use */
const $q = useQuasar(); // noti quasar
@ -157,16 +157,8 @@ const modal = ref<boolean>(false);
const filterKeyword = ref<string>("");
const filterRef = ref<any>(null);
/** HOOK */
onMounted(async () => {
await fecthlist();
if (columns.value) {
visibleColumns.value = columns.value.map((r: any) => r.name);
}
});
// API
const fecthlist = async () => {
async function fecthlist() {
showLoader();
await http
.get(config.API.listExitInterview())
@ -202,10 +194,10 @@ const fecthlist = async () => {
.finally(() => {
hideLoader();
});
};
}
//
const saveAppoint = async () => {
async function saveAppoint() {
await myForm.value!.validate().then(async (result: boolean) => {
if (result) {
dialogConfirm($q, async () => {
@ -229,13 +221,13 @@ const saveAppoint = async () => {
});
}
});
};
}
/**
* งก validate DATE ไทย
* @param thaiDate นทไทย
*/
const validationDate = (thaiDate: string | null) => {
function validationDate(thaiDate: string | null) {
if (thaiDate && daterow.value) {
let a = convertThaiDateToNumeric(thaiDate);
let b = daterow.value;
@ -243,10 +235,10 @@ const validationDate = (thaiDate: string | null) => {
return a > b;
}
}
};
}
//
const convertThaiDateToNumeric = (thaiDate: string) => {
function convertThaiDateToNumeric(thaiDate: string) {
const parts = thaiDate.split(" ");
if (parts.length !== 3) return null;
const [day, month, year] = parts;
@ -267,22 +259,31 @@ const convertThaiDateToNumeric = (thaiDate: string) => {
if (!(month in monthMap)) return null;
const numericDate = `${year}${monthMap[month]}${day}`;
return numericDate;
};
}
/**
* modal Setting
*/
const openModal = () => (modal.value = true);
const closeModal = () => (modal.value = false);
const resetFilter = () => {
function resetFilter() {
filterKeyword.value = "";
filterRef.value.focus();
};
const openModalCalendar = (rows: any) => {
}
function openModalCalendar(rows: any) {
openModal();
dateBreak.value = null;
id.value = rows.id;
daterow.value = convertThaiDateToNumeric(rows.datetext);
};
}
/** HOOK */
onMounted(async () => {
await fecthlist();
if (columns.value) {
visibleColumns.value = columns.value.map((r: any) => r.name);
}
});
</script>
<template v-slot:body="props">
<div class="toptitle text-dark col-12 row items-center">
@ -445,9 +446,7 @@ const openModalCalendar = (rows: any) => {
</div>
</q-td>
<q-td key="appointDate" :props="props">
{{
props.row.appointDate ? props.row.appointDate : "-"
}}
{{ props.row.appointDate ? props.row.appointDate : "-" }}
</q-td>
<q-td key="datetext" :props="props">
{{ props.row.datetext ? props.row.datetext : "-" }}

View file

@ -2,15 +2,17 @@
import { onMounted, reactive, ref, watch } from "vue";
import { useQuasar } from "quasar";
import { useRoute, useRouter } from "vue-router";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
import { tokenParsed } from "@/plugins/auth";
import { useCounterMixin } from "@/stores/mixin";
/**import type*/
import type {
OptionQuestions,
OptionQuestions2,
QuestionDesc,
} from "@/modules/06_retirement/interface/request/Main";
import type { QForm } from "quasar";
@ -80,18 +82,29 @@ const haveJobReason = ref<any>("");
const futureWorkReason = ref<any>("");
const adjustOther = ref("");
/** HOOK */
onMounted(async () => {
const user = await tokenParsed();
if (user) {
roleAdmin.value = await user.role.includes("placement1");
}
await getData();
await fecthquestion();
//
const questionDesc = reactive<QuestionDesc>({
question1Desc: "",
question2Desc: "",
question3Desc: "",
question4Desc: "",
question5Desc: "",
question6Desc: "",
question7Desc: "",
question8Desc: "",
question9Desc: "",
question10Desc: "",
});
const question1Answer = ref<OptionQuestions[]>([]);
const question2Answer = ref<OptionQuestions[]>([]);
const question3Answer = ref<OptionQuestions[]>([]);
const question4Answer = ref<OptionQuestions[]>([]);
const question7Answer = ref<OptionQuestions2[]>([]);
const question8Answer = ref<OptionQuestions2[]>([]);
const question9Answer = ref<OptionQuestions2[]>([]);
//
const getData = async () => {
async function getData() {
showLoader();
await http
.get(config.API.ExitInterviewByid(dataId))
@ -133,29 +146,8 @@ const getData = async () => {
.finally(() => {
hideLoader();
});
};
//
const questionDesc = reactive<any>([
{
question1Desc: "",
question2Desc: "",
question3Desc: "",
question4Desc: "",
question5Desc: "",
question6Desc: "",
question7Desc: "",
question8Desc: "",
question9Desc: "",
question10Desc: "",
},
]);
const question1Answer = ref<OptionQuestions[]>([]);
const question2Answer = ref<OptionQuestions[]>([]);
const question3Answer = ref<OptionQuestions[]>([]);
const question4Answer = ref<OptionQuestions[]>([]);
const question7Answer = ref<OptionQuestions2[]>([]);
const question8Answer = ref<OptionQuestions2[]>([]);
const question9Answer = ref<OptionQuestions2[]>([]);
}
async function fecthquestion() {
showLoader();
await http
@ -164,8 +156,8 @@ async function fecthquestion() {
const data = await result.data.result;
//
for (let i = 1; i <= 10; i++) {
questionDesc[`question${i}Desc`] =
`${i}.` + " " + data[`question${i}Desc`];
const key = `question${i}Desc` as keyof QuestionDesc;
questionDesc[key] = `${i}.` + " " + data[key];
}
//
const Answer1 = data.question1Answer.map((e: any, index: number) => ({
@ -227,17 +219,11 @@ async function fecthquestion() {
hideLoader();
});
}
//
watch(score, () => {
scoreTotal.value = score.reduce((accumulator, object) => {
return accumulator + Number(object.score);
}, 0);
});
/**
* นทกใหคะเเนน
*/
const saveClick = () => {
function saveClick() {
if (
comment.value === "" ||
score[0].score === "" ||
@ -256,12 +242,12 @@ const saveClick = () => {
} else {
dialogConfirm($q, () => putData());
}
};
}
/**
* งคะเเนนผาน API
*/
const putData = () => {
function putData() {
const body = {
score1: Number(score[0].score),
score2: Number(score[1].score),
@ -289,7 +275,24 @@ const putData = () => {
.finally(() => {
hideLoader();
});
};
}
//
watch(score, () => {
scoreTotal.value = score.reduce((accumulator, object) => {
return accumulator + Number(object.score);
}, 0);
});
/** HOOK */
onMounted(async () => {
const user = await tokenParsed();
if (user) {
roleAdmin.value = await user.role.includes("placement1");
}
await getData();
await fecthquestion();
});
</script>
<template>