UI แต่งตั้งคณะกรรมการทดลองงาน

This commit is contained in:
setthawutttty 2024-10-18 16:48:27 +07:00
parent 8dadcb450a
commit 3728587c4e
7 changed files with 470 additions and 96 deletions

View file

@ -7,6 +7,10 @@ import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
import type {
AppointTopic,
AppointTopicMain,
} from "@/modules/05_placement/interface/index/Main";
const $q = useQuasar();
const isEdit = ref<boolean>(false);
@ -27,6 +31,10 @@ const personalId = route.params.personalId as string;
const assignId = ref<string>(route.params.form as string);
const routeName = router.currentRoute.value.name;
const appointTopic = ref<AppointTopicMain>();
const appointOp = ref<AppointTopicMain[]>([]);
const appointAll = ref<AppointTopicMain[]>([]);
const fullname = ref<string>();
const date_start = ref<Date>();
const date_finish = ref<any>();
@ -121,19 +129,8 @@ const OPcaretaker = ref<
positionLevel: string;
}>[]
>([]);
const OPcommander = ref<
Array<{
id: string;
prefix: string;
firstName: string;
lastName: string;
name: string;
citizenId: number;
isDirector: boolean;
position: string;
positionLevel: string;
}>[]
>([]);
const OPcaretakerNew = ref<any[]>([]);
const OPcommander = ref<any[]>([]);
const OPchairman = ref<
Array<{
id: string;
@ -152,6 +149,10 @@ interface MonthOption {
value: number;
label: string;
}
interface optionsValue {
id: string;
name: string;
}
interface CheckboxItem {
id: number;
parent_id: number;
@ -332,53 +333,53 @@ async function getUser() {
position: item.position,
}));
OPcommander.value = data.commander.map((item: any) => ({
id: item.id,
name:
(item.prefix == null ? "" : item.prefix) +
item.firstName +
" " +
item.lastName,
label: item.position
? `${item.prefix == null ? "" : item.prefix} ${item.firstName} ${
item.lastName
} (${item.position}${
item.posLevel && item.posType
? ", " + item.posType + ": " + item.posLevel
: ""
})`
: `${item.prefix == null ? "" : item.prefix} ${item.firstName} ${
item.lastName
}`,
citizenId: item.citizenId,
posLevel: item.posLevel,
posType: item.posType,
position: item.position,
}));
// OPcommander.value = data.commander.map((item: any) => ({
// id: item.id,
// name:
// (item.prefix == null ? "" : item.prefix) +
// item.firstName +
// " " +
// item.lastName,
// label: item.position
// ? `${item.prefix == null ? "" : item.prefix} ${item.firstName} ${
// item.lastName
// } (${item.position}${
// item.posLevel && item.posType
// ? ", " + item.posType + ": " + item.posLevel
// : ""
// })`
// : `${item.prefix == null ? "" : item.prefix} ${item.firstName} ${
// item.lastName
// }`,
// citizenId: item.citizenId,
// posLevel: item.posLevel,
// posType: item.posType,
// position: item.position,
// }));
OPchairman.value = data.chairman.map((item: any) => ({
id: item.id,
name:
(item.prefix == null ? "-" : item.prefix) +
item.firstName +
" " +
item.lastName,
label: item.position
? `${item.prefix == null ? "-" : item.prefix} ${item.firstName} ${
item.lastName
} (${item.position}${
item.posLevel && item.posType
? ", " + item.posType + ": " + item.posLevel
: ""
})`
: `${item.prefix == null ? "-" : item.prefix} ${item.firstName} ${
item.lastName
}`,
citizenId: item.citizenId,
posLevel: item.posLevel,
posType: item.posType,
position: item.position,
}));
// OPchairman.value = data.chairman.map((item: any) => ({
// id: item.id,
// name:
// (item.prefix == null ? "-" : item.prefix) +
// item.firstName +
// " " +
// item.lastName,
// label: item.position
// ? `${item.prefix == null ? "-" : item.prefix} ${item.firstName} ${
// item.lastName
// } (${item.position}${
// item.posLevel && item.posType
// ? ", " + item.posType + ": " + item.posLevel
// : ""
// })`
// : `${item.prefix == null ? "-" : item.prefix} ${item.firstName} ${
// item.lastName
// }`,
// citizenId: item.citizenId,
// posLevel: item.posLevel,
// posType: item.posType,
// position: item.position,
// }));
});
}
@ -630,6 +631,7 @@ function putDataEdit(id: string) {
});
}
const data = {
appointId: appointTopic.value ? appointTopic.value.id : "",
fullname: fullname.value,
position: position.value,
monthSelect:
@ -762,6 +764,7 @@ function putData(id: string) {
});
}
const data = {
appointId: appointTopic.value ? appointTopic.value.id : "",
personalId: GUID,
fullname: fullname.value,
position: position.value,
@ -954,9 +957,9 @@ watch(
* @param update fn
*/
function filterFnCaretaker(val: string, update: any) {
const dataFilter = filtermantor(OPcaretaker.value, [caretaker2.value]).filter(
(i: any) => i.id !== chairman.value.id
);
const dataFilter = filtermantor(OPcaretakerNew.value, [
caretaker2.value,
]).filter((i: any) => i.id !== chairman.value.id);
if (val == "") {
update(() => {
optionCaretaker.value = dataFilter;
@ -1022,25 +1025,6 @@ function filterFnCommander(val: string, update: any) {
* @param update fn
*/
function filterFnChairman(val: string, update: any) {
const dataFilter = OPchairman.value.filter(
(i: any) =>
i.id !== caretaker1.value.id &&
i.id !== caretaker2.value.id &&
i.id !== commander.value.id
);
if (val == "") {
update(() => {
OPchairmanFn.value = dataFilter;
});
} else {
update(() => {
OPchairmanFn.value = dataFilter.filter(
(e: any) => e.name.search(val) !== -1
);
});
}
}
/**
* ลเตอรเเลตาม กรอก
* @param val บค input
@ -1058,6 +1042,73 @@ function filterFnKnowledge(val: string, update: any) {
});
}
async function getAppoint(id: string) {
http
.get(config.API.appointMainList(id))
.then((res) => {
const data = res.data.data;
appointOp.value = data;
appointAll.value = data;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
}
function updateAppointMent() {
if (appointTopic.value) {
const data = appointTopic.value.directors;
const dataFindChairman = data.find(
(item: AppointTopic) => item.role === "chairman"
);
const dataFindCommittee = data
.filter((item: AppointTopic) => item.role === "committee")
.map((i: AppointTopic) => ({
id: i.id,
name: i.name,
label: i.position
? `${i.name} (${i.position}${
i.positionLevel && i.positionType
? ", " + i.positionType + ": " + i.positionLevel
: ""
})`
: i.name,
posLevel: i.positionLevel,
posType: i.positionType,
position: i.position,
}));
const createChairmanObject = (chairmanData: AppointTopic) => ({
id: chairmanData.id,
name: chairmanData.name,
label: chairmanData.position
? `${chairmanData.name} (${chairmanData.position}${
chairmanData.positionLevel && chairmanData.positionType
? ", " +
chairmanData.positionType +
": " +
chairmanData.positionLevel
: ""
})`
: chairmanData.name,
posLevel: chairmanData.positionLevel,
posType: chairmanData.positionType,
position: chairmanData.position,
});
OPcaretakerNew.value = dataFindCommittee;
OPcommander.value = dataFindCommittee;
OPchairmanFn.value = dataFindChairman
? createChairmanObject(dataFindChairman)
: null;
chairman.value = dataFindChairman
? createChairmanObject(dataFindChairman)
: null;
}
}
/** เมื่อโหลดหน้า เรียกใช้งานฟังชั่น */
onMounted(async () => {
await getUser();
@ -1067,6 +1118,7 @@ onMounted(async () => {
await getKnowledge(personalId);
await getcompetency(personalId);
await getCompetencyGroup(personalId);
await getAppoint(personalId);
if (assignId.value !== undefined) {
await getAssign();
}
@ -1182,6 +1234,25 @@ onMounted(async () => {
<div class="row col-12">
<div class="row col-12 q-gutter-lg">
<div class="col-12 row">
<div class="col-6 q-mb-sm">
<q-select
outlined
dense
label="เลือกคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ"
bg-color="white"
:rules="[(val:string) => !!val || 'กรุณาเลือกคณะกรรมการประเมินผลการทดลองปฏิบัติหน้าที่ราชการ']"
hide-bottom-space
:options="appointOp"
class="col-xs-12 col-sm-6"
:readonly="!isEdit && routeName !== 'probationWorkAdd'"
borderless
option-label="topic"
option-value="id"
v-model="appointTopic"
map-options
@update:model-value="updateAppointMent"
></q-select>
</div>
<div class="col-12 text-top0 items-center">
<q-avatar class="bg-grey-2 q-mr-sm" size="28px">1</q-avatar>
ทดลองปฏหนาทราชการ
@ -1329,7 +1400,7 @@ onMounted(async () => {
<q-select
:rules="[(val:string) => !!val || 'กรุณาเลือกผู้ดูเเล']"
option-value="id"
:options="optionCaretaker"
:options="OPcaretakerNew"
class="col-xs-12 col-sm-6"
:readonly="isEdit != true"
dense
@ -1384,7 +1455,7 @@ onMounted(async () => {
<q-select
:rules="[(val:string) => !!val || 'กรุณาเลือกผู้ดูเเล']"
option-value="id"
:options="filtermantor(OPcaretaker, [caretaker2])"
:options="filtermantor(OPcaretakerNew, [caretaker2])"
class="col-xs-12 col-sm-6"
:readonly="!isEdit && routeName !== 'probationWorkAdd'"
dense
@ -2912,16 +2983,14 @@ onMounted(async () => {
:options="OPchairmanFn"
option-label="label"
class="col-xs-12 col-sm-8"
:readonly="isEdit != true"
readonly
dense
borderless
outlined
v-model="chairman"
label="ประธานกรรมการ"
:rules="[(val:string) => !!val || 'กรุณาเลือก ประธานกรรมการ']"
use-input
behavior="menu"
@filter="filterFnChairman"
bg-color="white"
>
<template v-slot:no-option>
@ -2939,16 +3008,14 @@ onMounted(async () => {
option-value="id"
option-label="label"
class="col-xs-12 col-sm-8"
:readonly="!isEdit && routeName !== 'probationWorkAdd'"
readonly
dense
borderless
outlined
v-model="chairman"
:rules="[(val:string) => !!val || 'กรุณาเลือก ประธานกรรมการ']"
label="ประธานกรรมการ"
use-input
behavior="menu"
@filter="filterFnChairman"
bg-color="white"
>
<template v-slot:no-option>
@ -3014,7 +3081,7 @@ onMounted(async () => {
.q-item span {
white-space: normal;
display: -webkit-box;
// -webkit-line-clamp: 2;
// -webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;