no message

This commit is contained in:
setthawutttty 2023-08-09 12:09:46 +07:00
parent f4aa92634e
commit 44ab2aa17e
6 changed files with 463 additions and 249 deletions

View file

@ -67,6 +67,7 @@
dense
borderless
option-label="label"
option-value="value"
:outlined="routeName === 'probationWorkAdd'"
v-model="monthSelect"
:label="`ระยะเวลากี่เดือน`"
@ -154,6 +155,7 @@
<div class="col-12 row q-col-gutter-md">
<q-select
:rules="[(val) => !!val || 'กรุณาเลือกผู้ดูเเล']"
option-value="personal_id"
:options="OPcaretaker"
class="col-xs-12 col-sm-6"
:readonly="routeName != 'probationWorkAdd'"
@ -163,10 +165,13 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="caretaker1"
:label="`ผู้ดูแลคนที่ 1`"
option-label="name"
/>
<q-select
:rules="[(val) => !!val || 'กรุณาเลือกผู้ดูเเล']"
:options="OPcaretaker"
option-value="personal_id"
option-label="name"
hide-bottom-space
class="col-xs-12 col-sm-6"
:readonly="routeName != 'probationWorkAdd'"
@ -552,10 +557,18 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="skill"
label="ด้านที่ 1"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.level_description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
ellipsis-2-lines
:option-label="
(item) =>
`${item.title} - ${item.level_description}`
@ -573,7 +586,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="skill2"
label="ด้านที่ 2"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.level_description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -594,7 +614,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="skill3"
label="ด้านที่ 3"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.level_description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -615,7 +642,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="skill4"
label="ด้านที่ 4"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.level_description }}
</div>
</template></q-select
>
</div>
</div>
</div>
@ -641,7 +675,9 @@
option-value="id"
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกสมรรถนะ']"
:options="filterMain(OPmain,[main2,main3,main4,main5])"
:options="
filterMain(OPmain, [main2, main3, main4, main5])
"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -649,7 +685,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="main"
label="ตัวที่ 1"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -659,7 +702,9 @@
option-value="id"
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกสมรรถนะ']"
:options="filterMain(OPmain,[main,main3,main4,main5])"
:options="
filterMain(OPmain, [main, main3, main4, main5])
"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -667,7 +712,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="main2"
label="ตัวที่ 2"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -677,7 +729,9 @@
option-value="id"
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกสมรรถนะ']"
:options="filterMain(OPmain,[main,main2,main4,main5])"
:options="
filterMain(OPmain, [main, main2, main4, main5])
"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -685,7 +739,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="main3"
label="ตัวที่ 3"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -695,7 +756,9 @@
option-value="id"
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกสมรรถนะ']"
:options="filterMain(OPmain,[main,main2,main3,main5])"
:options="
filterMain(OPmain, [main, main2, main3, main5])
"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -703,14 +766,23 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="main4"
label="ตัวที่ 4"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
hide-bottom-space
:rules="[(val) => !!val || 'กรุณาเลือกสมรรถนะ']"
:options="filterMain(OPmain,[main,main2,main3,main4])"
:options="
filterMain(OPmain, [main, main2, main3, main4])
"
:option-label="
(item) => `${item.title} - ${item.description}`
"
@ -722,7 +794,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="main5"
label="ตัวที่ 5"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
</div>
</div>
@ -731,7 +810,6 @@
<div class="col-12 row q-col-gutter-sm">
<div class="col-xs-12 col-sm-6">
<q-select
:option-label="
(item) => `${item.title} - ${item.description}`
"
@ -740,7 +818,7 @@
:rules="[
(val) => !!val || 'กรุณาเลือกสมรรถนะประจํากลุ่มงาน',
]"
:options="filterData(OPgroup,[group2,group3])"
:options="filterData(OPgroup, [group2, group3])"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -748,7 +826,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="group"
label="ตัวที่ 1"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -760,7 +845,7 @@
:rules="[
(val) => !!val || 'กรุณาเลือกสมรรถนะประจํากลุ่มงาน',
]"
:options="filterData(OPgroup,[group,group3])"
:options="filterData(OPgroup, [group, group3])"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -768,7 +853,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="group2"
label="ตัวที่ 2"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
<div class="col-xs-12 col-sm-6">
<q-select
@ -780,7 +872,7 @@
:rules="[
(val) => !!val || 'กรุณาเลือกสมรรถนะประจํากลุ่มงาน',
]"
:options="filterData(OPgroup,[group,group2])"
:options="filterData(OPgroup, [group, group2])"
class="bg-white"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -788,7 +880,14 @@
:outlined="routeName == 'probationWorkAdd'"
v-model="group3"
label="ตัวที่ 3"
/>
>
<template v-slot:selected-item="scope">
<div class="ellipsis-2-lines">
{{ scope.opt.title }} -
{{ scope.opt.description }}
</div>
</template></q-select
>
</div>
</div>
</div>
@ -1179,6 +1278,8 @@
<div class="col-12 row q-col-gutter-md">
<q-select
:options="OPcaretaker"
option-value="personal_id"
option-label="name"
class="col-xs-12 col-sm-8"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -1229,6 +1330,8 @@
</div>
<q-select
:options="OPcaretaker"
option-value="personal_id"
option-label="name"
class="col-xs-12 col-sm-8"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -1287,7 +1390,9 @@
</div>
<div class="col-12 row q-col-gutter-md">
<q-select
:options="OPcaretaker"
:options="OPcommander"
option-value="personal_id"
option-label="name"
class="col-xs-12 col-sm-8"
:readonly="routeName != 'probationWorkAdd'"
dense
@ -1345,14 +1450,19 @@
v-show="routeName == 'probationWorkAdd'"
class="flex justify-end q-pa-sm q-gutter-sm"
>
<q-btn unelevated label="บันทึก" color="public" @click="saveData()" />
<q-btn
unelevated
label="บันทึก"
color="public"
@click="saveData(personalId)"
/>
</div>
</q-card>
</div>
</q-form>
</template>
<script setup lang="ts">
import { useRouter } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import { ref, computed, watch, onMounted } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import { useQuasar } from "quasar";
@ -1370,13 +1480,26 @@ const val1 = ref([
const router = useRouter();
const mixin = useCounterMixin();
const { date2Thai, notifyError } = mixin;
const {
date2Thai,
notifyError,
dateToISO,
success,
messageError,
showLoader,
hideLoader,
} = mixin;
const filterData = (options: any[], excludedGroups: any[]) => {
return options.filter((item) => !excludedGroups.some((group) => group && group.id === item.id));
return options.filter(
(item) => !excludedGroups.some((group) => group && group.id === item.id)
);
};
const filterMain = (options: any[], excludedGroups: any[]) => {
return options.filter((item) => !excludedGroups.some((group) => group && group.id === item.id));
return options.filter(
(item) => !excludedGroups.some((group) => group && group.id === item.id)
);
};
const route = useRoute();
const checkValidate = ref<boolean>(false);
const myForm = ref<any>(null);
const fullnameFoot = ref<string>("");
@ -1384,12 +1507,12 @@ const positionFoot = ref<string>("");
const caretakerFoot = ref<string>("");
const caretakerFoot2 = ref<string>("");
const id = ref<number>();
const personal_id = ref<string>();
const personalId = route.params.personalId as string;
const fullname = ref<string>();
const knowledge_skill_map_no = ref<string[]>([]);
const round_no = ref<number>();
const date_start = ref<Date | null>(null);
const date_finish = ref<Date | null>(null);
const date_start = ref<Date>();
const date_finish = ref<Date>();
const behavior_desc = ref<string>();
const other_desc = ref<object>({});
const other4_desc = ref<string>();
@ -1408,7 +1531,6 @@ const main3 = ref<any>();
const main4 = ref<any>();
const main5 = ref<any>();
const Other = ref<string>("");
const commander = ref<string>("");
@ -1447,19 +1569,36 @@ const routeName = router.currentRoute.value.name;
const name = ref<string>("");
const position = ref<string>("");
const monthSelect = ref<number>();
const monthSelect = ref<number | string>();
const caretaker1 = ref<string>("");
const caretaker2 = ref<string>("");
const OPcaretaker = [
"นางสาวรัชภรณ์ ภักดี",
"นางสาวทวิดา กมลเวชชี",
"test1",
"test2",
"test3",
"test4",
];
const monthOp = [{ value: "6", label: "6 เดือน" }];
const OPcaretaker = ref<
{
personal_id: string;
name: string;
PositionId: string;
PositionLevelId: string;
PositionLineId: string;
OrganizationOrganization: string;
}[]
>([]);
const OPcommander = ref<
{
personal_id: string;
name: string;
PositionId: string;
PositionLevelId: string;
PositionLineId: string;
OrganizationOrganization: string;
}[]
>([]);
interface MonthOption {
value: number;
label: string;
}
const monthOp: MonthOption[] = [];
//-----------------(3.1)-----------//
const activityCount = ref<number>(2);
const activityDataArray = ref<any[]>([]);
@ -1486,10 +1625,10 @@ const resetActivity = () => {
//-----------------(3.2)-----------//
const knowledgeCount = ref<number>(3);
const knowledge = ref<any[]>(Array.from({ length: knowledgeCount.value }, () => null));
const knowledge = ref<any[]>([]);
const OPknowledge = ref<
Array<{
knowledge_id: number;
id: number;
title: number;
options: Array<Option>;
}>
@ -1543,7 +1682,21 @@ interface CheckboxItem {
}
const checkRule = ref<CheckboxItem[]>([]);
const getcompetency = async () => {
const getAssignNew = async (id: string) => {
await http.get(config.API.newAssign(id)).then((res: any) => {
const data = res.data.data;
const monthOption = {
value: data.assign_month,
label: `${data.assign_month} เดือน`,
};
console.log("Assign-New", data);
monthOp.push(monthOption);
monthSelect.value = `${data.assign_month} เดือน`;
OPcaretaker.value = data.mentors;
OPcommander.value = [data.commander];
});
};
const getcompetency = async () => {
await http.get(config.API.competencyOptions()).then((res: any) => {
const data = res.data.data;
OPmain.value = data;
@ -1587,7 +1740,24 @@ const getLaw = async () => {
});
};
const putData = () => {
const postDateTime = async () => {
await http
.post(config.API.calculateDate(), {
month: monthSelect.value !== null ? parseInt(monthSelect.value) : null,
start_date: dateToISO(date_start.value as Date),
})
.then(async (res) => {
const result = res.data;
date_finish.value = result.finish_date;
})
.catch((e) => {})
.finally(async () => {
hideLoader();
});
};
const putData = (id: string) => {
const GUID = id;
const assign_job = activityArray.value.map((item, index) => {
const activityDesc = activity_desc.value[index]?.trim();
const goalDesc = goal_desc.value[index]?.trim();
@ -1599,7 +1769,7 @@ const putData = () => {
goal_desc: goalDesc,
};
} else {
return null;
return null;
}
});
const know_ledge = knowledge.value.map((item) => ({
@ -1607,7 +1777,6 @@ const putData = () => {
level: item ? item.level : null,
}));
const Productivity_assign = ProductivityArray.value.map((item, index) => {
const outputDesc = output_desc.value[index]?.trim();
const indicatorDesc = indicator_desc.value[index]?.trim();
@ -1615,88 +1784,94 @@ const putData = () => {
if (outputDesc !== "" && indicatorDesc !== "") {
return {
id: index + 1,
activity_desc: outputDesc,
goal_desc: indicatorDesc,
output_desc: outputDesc,
indicator_desc: indicatorDesc,
};
} else {
return null;
return null;
}
});
const groupData = group.value
? { id: group.value.id, level: group.value.level }
: null;
const group2Data = group2.value
? { id: group2.value.id, level: group2.value.level }
: null;
const group3Data = group3.value
? { id: group3.value.id, level: group3.value.level }
: null;
const skillData = skill.value
? { id: skill.value.id, level: skill.value.level }
: null;
const skill2Data = skill2.value
? { id: skill2.value.id, level: skill2.value.level }
: null;
const skill3Data = skill3.value
? { id: skill3.value.id, level: skill3.value.level }
: null;
const skill4Data = skill4.value
? { id: skill4.value.id, level: skill4.value.level }
: null;
const allGroup = [];
if (group.value)
allGroup.push({ id: group.value.id, level: group.value.level });
if (group2.value)
allGroup.push({ id: group2.value.id, level: group2.value.level });
if (group3.value)
allGroup.push({ id: group3.value.id, level: group3.value.level });
const mainData = main.value
? { id: main.value.id, level: main.value.level }
: null;
const main2Data = main2.value
? { id: main2.value.id, level: main2.value.level }
: null;
const main3Data = main3.value
? { id: main3.value.id, level: main3.value.level }
: null;
const main4Data = main4.value
? { id: main4.value.id, level: main4.value.level }
: null;
const main5Data = main5.value
? { id: main5.value.id, level: main5.value.level }
: null;
const allSkills = [];
if (skill.value)
allSkills.push({ id: skill.value.id, level: skill.value.level });
if (skill2.value)
allSkills.push({ id: skill2.value.id, level: skill2.value.level });
if (skill3.value)
allSkills.push({ id: skill3.value.id, level: skill3.value.level });
if (skill4.value)
allSkills.push({ id: skill4.value.id, level: skill4.value.level });
const allCompetency = [];
if (main.value)
allCompetency.push({ id: skill.value.id, level: main.value.level });
if (main2.value)
allCompetency.push({ id: main2.value.id, level: main2.value.level });
if (main3.value)
allCompetency.push({ id: main3.value.id, level: main3.value.level });
if (main4.value)
allCompetency.push({ id: main4.value.id, level: main4.value.level });
if (main5.value)
allCompetency.push({ id: main5.value.id, level: main5.value.level });
const assign_director = [
{
personal_id: caretakerFoot.value.personal_id,
role: "mentor",
dated: date2.value instanceof Date ? dateToISO(date2.value) : null,
},
{
personal_id: caretakerFoot2.value.personal_id,
role: "mentor",
dated: date3.value instanceof Date ? dateToISO(date3.value) : null,
},
{
personal_id: commander.value.personal_id,
role: "commander",
dated: date4.value instanceof Date ? dateToISO(date4.value) : null,
},
];
const data = {
personalId: GUID,
fullname: fullname.value,
position: position.value,
monthSelect: monthSelect.value !== undefined ? parseInt((monthSelect.value as any).value) : null,
date_start: date_start.value,
monthSelect:monthSelect.value !== null ? parseInt(monthSelect.value) : null,
date_start:
date_start.value instanceof Date
? dateToISO(date_start.value)
: new Date(),
date_finish: date_finish.value,
caretaker_1: caretaker1.value,
caretaker_2: caretaker2.value,
knowledge: know_ledge,
assign_job: assign_job.filter((item) => item !== null),
otherlaw: OtherLaw.value,
skill: skillData,
skill_2: skill2Data,
skill_3: skill3Data,
skill_4: skill4Data,
main: mainData,
main_2: main2Data,
main_3: main3Data,
main_4: main4Data,
main_5: main5Data,
group: groupData,
group_2: group2Data,
group_3: group3Data,
other: Other.value,
other_5: Other5.value,
productivity_assign: Productivity_assign.filter((item) => item !== null),
commander: commander.value,
date_1: date1.value,
date_2: date2.value,
date_3: date3.value,
date_4: date4.value,
// caretaker_1: caretaker1.value,
// caretaker_2: caretaker2.value,
assign_knowledges: know_ledge,
assign_jobs: assign_job.filter((item) => item !== null),
other_desc: OtherLaw.value,
assign_skill: allSkills,
assign_competency: allCompetency,
assign_competency_group: allGroup,
other4_desc: Other.value,
other5_no1_desc: Other5.value,
assign_outputs: Productivity_assign.filter((item) => item !== null),
// commander: commander.value,
assign_director: assign_director,
experimenter_dated: date1.value instanceof Date ? dateToISO(date1.value) : new Date(),
// date_2: date2.value instanceof Date ? dateToISO(date2.value) : new Date(),
// date_3: date3.value instanceof Date ? dateToISO(date3.value) : new Date(),
// date_4: date4.value instanceof Date ? dateToISO(date4.value) : new Date(),
fullname_foot: fullnameFoot.value,
position_foot: positionFoot.value,
caretaker_foot: caretakerFoot.value,
caretaker_foot2: caretakerFoot2.value,
checkarray: checkRule.value
// caretaker_foot: caretakerFoot.value,
// caretaker_foot2: caretakerFoot2.value,
assign_law: checkRule.value
.filter((item) => item.checked === 1)
.map((item) => ({
id: item.id,
@ -1706,16 +1881,8 @@ const putData = () => {
console.log("test", data);
};
const saveData = async () => {
// myForm.value.resetValidation();
// nameRef.value.validate();
// positionRef.value.validate();
// monthRef.value.validate();
// startDateRef.value.validate();
// caregiverRef1.value.validate();
// caregiverRef2.value.validate();
// workInfopRef.value.validate();
myForm.value.validate().then(async (result: boolean) => {
const saveData = (id: string) => {
myForm.value.validate().then((result: boolean) => {
if (result) {
$q.dialog({
title: "บันทึกข้อมูล",
@ -1726,20 +1893,24 @@ const saveData = async () => {
},
})
.onOk(async () => {
// putData();
const data = putData(id);
await http
.post(config.API.saveFinish(id), data)
.then(async (res) => {})
.catch((e) => {})
.finally(async () => {
hideLoader();
});
})
.onCancel(() => {})
.onDismiss(() => {});
} else {
//
putData();
notifyError($q, "กรุณากรอกข้อมูลให้ครบ");
}
});
};
const OtherLaw = ref<string>("");
const skill = ref<any>();
const skill2 = ref<any>();
const skill3 = ref<any>();
@ -1783,6 +1954,20 @@ onMounted(async () => {
await getCompetencyGroup();
await getSkill();
await getKnowledge();
await getAssignNew(personalId);
});
watch(
() => [monthSelect.value, date_start.value],
() => {
if (monthSelect.value !== undefined && date_start.value !== undefined) {
postDateTime();
}
}
);
watch(knowledge.value, () => {
knowledge.value.forEach((item) => {
OPknowledge.value = OPknowledge.value.filter((e) => e.id != item.id);
});
});
</script>
<style lang="scss" scoped>
@ -1813,4 +1998,12 @@ onMounted(async () => {
align-items: center;
justify-content: center;
}
.q-item span {
white-space: normal;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
</style>