Merge branch 'oat_dev' into develop

This commit is contained in:
oat_dev 2024-03-21 14:21:11 +07:00
commit e6f2307110
2 changed files with 162 additions and 233 deletions

View file

@ -204,7 +204,6 @@ const historyRows = ref<ResponseObject[]>([]);
const editId = ref<string>(""); const editId = ref<string>("");
const route = useRoute(); const route = useRoute();
const id = ref<string>(route.params.id.toString()); const id = ref<string>(route.params.id.toString());
const isDate = ref<string>("false"); const isDate = ref<string>("false");
const educationOption = ref([ const educationOption = ref([
{ label: "ใช่", value: true }, { label: "ใช่", value: true },
@ -213,6 +212,8 @@ const educationOption = ref([
const historyDialog = ref<boolean>(false); const historyDialog = ref<boolean>(false);
const educationData = reactive<RequestItemsObject>({ const educationData = reactive<RequestItemsObject>({
isDate: isDate.value === "false" ? false : true,
profileId: id.value,
educationLevel: "", educationLevel: "",
institute: "", institute: "",
startYear: new Date().getFullYear(), startYear: new Date().getFullYear(),
@ -230,28 +231,18 @@ const educationData = reactive<RequestItemsObject>({
duration: "", duration: "",
durationYear: null, durationYear: null,
note: "", note: "",
educationLevelId: "",
positionPath: "",
positionPathId: "",
isActive: true,
}); });
const formFilter = reactive({ const keyword = ref<string>("");
page: 1, const historyKeyword = ref<string>("");
pageSize: 10,
keyword: "",
});
const pagination = ref({ const pagination = ref({
page: formFilter.page,
rowsPerPage: formFilter.pageSize,
});
const historyFormFilter = reactive({
page: 1, page: 1,
pageSize: 10, rowsPerPage: 10,
keyword: "",
});
const historyPagination = ref({
page: historyFormFilter.page,
rowsPerPage: historyFormFilter.pageSize,
}); });
const visibleColumns = ref<string[]>([ const visibleColumns = ref<string[]>([
@ -289,10 +280,6 @@ const historyVisibleColumns = ref<string[]>([
"note", "note",
]); ]);
function validateForm() {
onSubmit();
}
async function onSubmit() { async function onSubmit() {
dialogConfirm( dialogConfirm(
$q, $q,
@ -364,6 +351,7 @@ async function fetchData(id: string) {
.get(config.API.profileNewEducationByProfileId(id)) .get(config.API.profileNewEducationByProfileId(id))
.then(async (res) => { .then(async (res) => {
rows.value = res.data.result; rows.value = res.data.result;
console.log(rows.value);
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -391,26 +379,9 @@ async function fetchHistoryData(id: string) {
async function addData() { async function addData() {
await http await http
.post(config.API.profileNewEducation, { .post(config.API.profileNewEducation, {
profileId: id.value, ...educationData,
isActive: true, startYear: undefined,
country: educationData.country, endYear: undefined,
degree: educationData.degree,
duration: educationData.duration,
durationYear: educationData.durationYear ? educationData.durationYear : 0,
field: educationData.field,
finishDate: educationData.finishDate,
fundName: educationData.fundName,
gpa: educationData.gpa,
institute: educationData.institute,
other: educationData.other,
startDate: educationData.startDate,
endDate: educationData.endDate,
educationLevel: educationData.educationLevel,
educationLevelId: "educationLevelId",
positionPath: "positionPath",
positionPathId: "positionPathId",
isDate: isDate.value === "true" ? true : false,
isEducation: educationData.isEducation,
}) })
.then(() => { .then(() => {
fetchData(id.value); fetchData(id.value);
@ -424,28 +395,13 @@ async function addData() {
}); });
} }
async function editData(idData: string) { function editData(idData: string) {
await http http
.patch(config.API.profileNewEducationByEducationId(idData), { .patch(config.API.profileNewEducationByEducationId(idData), {
isActive: true, ...educationData,
country: educationData.country, profileId: undefined,
degree: educationData.degree, startYear: undefined,
duration: educationData.duration, endYear: undefined,
durationYear: educationData.durationYear,
field: educationData.field,
finishDate: educationData.finishDate,
fundName: educationData.fundName,
gpa: educationData.gpa,
institute: educationData.institute,
other: educationData.other,
startDate: educationData.startDate,
endDate: educationData.endDate,
educationLevel: educationData.educationLevel,
educationLevelId: "educationLevelId",
positionPath: "positionPath",
positionPathId: "positionPathId",
isDate: isDate.value === "true" ? true : false,
isEducation: educationData.isEducation,
}) })
.then(() => { .then(() => {
fetchData(id.value); fetchData(id.value);
@ -459,73 +415,23 @@ async function editData(idData: string) {
}); });
} }
async function deleteData(idData: string) { function deleteData(idData: string) {
await http dialogRemove($q, () =>
.delete(config.API.profileNewEducationByEducationId(idData)) http
.then(() => { .delete(config.API.profileNewEducationByEducationId(idData))
fetchData(id.value); .then(() => {
}) fetchData(id.value);
.catch((err) => { success($q, "ลบข้อมูลสำเร็จ");
messageError($q, err); })
}) .catch((err) => {
.finally(() => { messageError($q, err);
hideLoader(); })
}); .finally(() => {
hideLoader();
})
);
} }
watch(
() => isDate.value,
() => {
if (isDate.value === "false") {
educationData.startYear = +educationData.startDate
.toString()
.slice(11, 15);
educationData.endYear = +educationData.endDate.toString().slice(11, 15);
educationData.startDate = new Date(educationData.startYear + "-01-01");
educationData.endDate = new Date(educationData.endYear + "-01-01");
} else {
educationData.startDate = new Date(educationData.startYear + "-01-01");
educationData.endDate = new Date(educationData.endYear + "-01-01");
}
}
);
watch(
() => educationData.startYear,
() => {
if (isDate.value === "false") {
educationData.startDate = new Date(educationData.startYear + "-01-01");
}
}
);
watch(
() => educationData.endYear,
() => {
if (isDate.value === "false") {
educationData.endDate = new Date(educationData.endYear + "-01-01");
}
}
);
watch(
() => educationData.startDate,
() => {
if (isDate.value === "true") {
educationData.startYear = +educationData.startDate
.toString()
.slice(11, 15);
}
}
);
watch(
() => educationData.endDate,
() => {
if (isDate.value === "true") {
educationData.endYear = +educationData.endDate.toString().slice(11, 15);
}
}
);
onMounted(async () => { onMounted(async () => {
await fetchData(id.value); await fetchData(id.value);
}); });
@ -551,13 +457,7 @@ onMounted(async () => {
> >
<q-space /> <q-space />
<q-input <q-input dense outlined v-model="keyword" label="ค้นหา" class="q-mr-sm">
dense
outlined
v-model="formFilter.keyword"
label="ค้นหา"
class="q-mr-sm"
>
<template v-slot:append> <template v-slot:append>
<q-icon name="search" /> <q-icon name="search" />
</template> </template>
@ -620,7 +520,7 @@ onMounted(async () => {
flat flat
bordered bordered
:paging="true" :paging="true"
:filter="formFilter.keyword" :filter="keyword"
dense dense
v-model:pagination="pagination" v-model:pagination="pagination"
:rows-per-page-options="[20, 50, 100]" :rows-per-page-options="[20, 50, 100]"
@ -681,9 +581,7 @@ onMounted(async () => {
size="14px" size="14px"
icon="mdi-delete" icon="mdi-delete"
clickable clickable
@click.stop=" @click.stop="deleteData(props.row.id)"
dialogRemove($q, async () => await deleteData(props.row.id))
"
v-close-popup v-close-popup
> >
<q-tooltip>ลบขอม</q-tooltip> <q-tooltip>ลบขอม</q-tooltip>
@ -806,7 +704,7 @@ onMounted(async () => {
<q-dialog v-model="dialog" class="dialog" persistent> <q-dialog v-model="dialog" class="dialog" persistent>
<q-card style="min-width: 40%" class="bg-white"> <q-card style="min-width: 40%" class="bg-white">
<q-form @submit.prevent greedy @validation-success="validateForm"> <q-form @submit.prevent greedy @validation-success="onSubmit()">
<q-card-section class="flex justify-between" style="padding: 0"> <q-card-section class="flex justify-between" style="padding: 0">
<dialog-header <dialog-header
:tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'" :tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
@ -815,8 +713,8 @@ onMounted(async () => {
</q-card-section> </q-card-section>
<q-separator color="grey-4" /> <q-separator color="grey-4" />
<div class="col"> <div class="col">
<q-card-section class="row q-gutter-sm"> <div class="row q-pa-md q-col-gutter-sm">
<div class="col"> <div class="col-6">
<q-input <q-input
outlined outlined
v-model="educationData.educationLevel" v-model="educationData.educationLevel"
@ -827,7 +725,7 @@ onMounted(async () => {
hide-bottom-space hide-bottom-space
/> />
</div> </div>
<div class="col"> <div class="col-6">
<q-input <q-input
outlined outlined
v-model="educationData.institute" v-model="educationData.institute"
@ -838,8 +736,12 @@ onMounted(async () => {
hide-bottom-space hide-bottom-space
/> />
</div> </div>
</q-card-section> </div>
<q-card flat bordered class="q-px-sm q-mx-md q-mb q-pb-sm borderCard"> <q-card
flat
bordered
class="q-mx-md q-px-md q-pb-md q-mb-md borderCard"
>
<div class="row col-12 q-gutter-md q-py-sm text-grey-7"> <div class="row col-12 q-gutter-md q-py-sm text-grey-7">
<q-radio <q-radio
v-model="isDate" v-model="isDate"
@ -867,7 +769,12 @@ onMounted(async () => {
autoApply autoApply
year-picker year-picker
:enableTimePicker="false" :enableTimePicker="false"
@update:modelValue="educationData.startYear" @update:modelValue="
(v) =>
(educationData.startDate = new Date(
`${v}-01-01T00:00:02.010+07:00`
))
"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{
@ -905,7 +812,12 @@ onMounted(async () => {
autoApply autoApply
year-picker year-picker
:enableTimePicker="false" :enableTimePicker="false"
@update:modelValue="educationData.endYear" @update:modelValue="
(v) =>
(educationData.endDate = new Date(
`${v}-01-01T00:00:02.010+07:00`
))
"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{
@ -945,6 +857,12 @@ onMounted(async () => {
autoApply autoApply
:enableTimePicker="false" :enableTimePicker="false"
week-start="0" week-start="0"
@update:modelValue="
(v) =>
(educationData.startYear = parseInt(
v.toString().slice(11, 15)
))
"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{
@ -982,6 +900,12 @@ onMounted(async () => {
autoApply autoApply
:enableTimePicker="false" :enableTimePicker="false"
week-start="0" week-start="0"
@update:modelValue="
(v) =>
(educationData.endYear = parseInt(
v.toString().slice(11, 15)
))
"
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{ <template #year-overlay-value="{ value }">{{
@ -1013,7 +937,7 @@ onMounted(async () => {
</div> </div>
</div> </div>
</q-card> </q-card>
<q-card-section class="row q-gutter-sm q-pt-sm"> <div class="row q-gutter-sm q-px-md">
<div class="col"> <div class="col">
<datepicker <datepicker
menu-class-name="modalfix" menu-class-name="modalfix"
@ -1064,13 +988,14 @@ onMounted(async () => {
option-value="value" option-value="value"
option-label="label" option-label="label"
:rules="[ :rules="[
(val) => !!val || `${'กรุณาเลือกวุฒิการศึกษาในตำแหน่ง'}`, (val) =>
val !== null || `${'กรุณาเลือกวุฒิการศึกษาในตำแหน่ง'}`,
]" ]"
label="เป็นวุฒิการศึกษาในตำแหน่ง" label="เป็นวุฒิการศึกษาในตำแหน่ง"
/> />
</div> </div>
</q-card-section> </div>
<q-card-section class="row q-gutter-sm q-py-none"> <div class="row q-gutter-sm q-px-md q-mb-sm">
<div class="col"> <div class="col">
<q-input <q-input
outlined outlined
@ -1091,8 +1016,8 @@ onMounted(async () => {
dense dense
/> />
</div> </div>
</q-card-section> </div>
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none"> <div class="row q-gutter-sm q-px-md q-mb-sm">
<div class="col"> <div class="col">
<q-input <q-input
outlined outlined
@ -1112,8 +1037,8 @@ onMounted(async () => {
mask="#.##" mask="#.##"
/> />
</div> </div>
</q-card-section> </div>
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none"> <div class="row q-gutter-sm q-px-md q-mb-sm">
<div class="col"> <div class="col">
<q-input <q-input
outlined outlined
@ -1132,8 +1057,8 @@ onMounted(async () => {
dense dense
/> />
</div> </div>
</q-card-section> </div>
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none"> <div class="row q-gutter-sm q-px-md">
<div class="col"> <div class="col">
<q-input <q-input
outlined outlined
@ -1157,8 +1082,8 @@ onMounted(async () => {
dense dense
/> />
</div> </div>
</q-card-section> </div>
<q-card-section class="row q-gutter-sm q-pt-sm"> <div class="row q-gutter-sm q-px-md">
<div class="col"> <div class="col">
<q-input <q-input
outlined outlined
@ -1169,7 +1094,7 @@ onMounted(async () => {
type="textarea" type="textarea"
/> />
</div> </div>
</q-card-section> </div>
</div> </div>
<q-card-actions align="right"> <q-card-actions align="right">
<q-btn <q-btn
@ -1190,82 +1115,80 @@ onMounted(async () => {
<q-dialog v-model="historyDialog" class="dialog" persistent> <q-dialog v-model="historyDialog" class="dialog" persistent>
<q-card style="min-width: 70%" class="bg-white"> <q-card style="min-width: 70%" class="bg-white">
<q-form @submit.prevent greedy @validation-success="validateForm"> <q-card-section class="flex justify-between" style="padding: 0">
<q-card-section class="flex justify-between" style="padding: 0"> <dialog-header
<dialog-header tittle="ประวัติแก้ไขประวัติการศึกษา"
tittle="ประวัติแก้ไขประวัติการศึกษา" :close="closeHistoryDialog"
:close="closeHistoryDialog" />
/> </q-card-section>
</q-card-section> <q-separator color="grey-4" />
<q-separator color="grey-4" /> <q-card-section>
<q-card-section> <q-toolbar style="padding: 0px" class="text-primary q-mb-sm">
<q-toolbar style="padding: 0px" class="text-primary q-mb-sm"> <q-space />
<q-space /> <q-input
<q-input
dense
outlined
bg-color="white"
v-model="historyFormFilter.keyword"
label="ค้นหา"
class="q-mr-sm"
>
<template v-slot:append>
<q-icon name="search" />
</template>
</q-input>
<q-select
v-model="historyVisibleColumns"
multiple
outlined
dense
bg-color="white"
options-dense
:display-value="$q.lang.table.columns"
emit-value
map-options
:options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
:rows="historyRows"
row-key="name"
flat
bordered
:paging="true"
dense dense
:filter="historyFormFilter.keyword" outlined
v-model:pagination="historyPagination" bg-color="white"
:rows-per-page-options="[20, 50, 100]" v-model="historyKeyword"
class="custom-header-table" label="ค้นหา"
:visible-columns="historyVisibleColumns" class="q-mr-sm"
> >
<template v-slot:header="props"> <template v-slot:append>
<q-tr :props="props"> <q-icon name="search" />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template> </template>
<template v-slot:body="props"> </q-input>
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id"> <q-select
<div> v-model="historyVisibleColumns"
{{ col.value === "" ? "-" : col.value }} multiple
</div> outlined
</q-td> dense
<q-td auto-width> </q-td> bg-color="white"
</q-tr> options-dense
</template> :display-value="$q.lang.table.columns"
</d-table> emit-value
</q-card-section> map-options
</q-form> :options="columns"
option-value="name"
options-cover
style="min-width: 150px"
/>
</q-toolbar>
<d-table
ref="table"
:columns="columns"
:rows="historyRows"
row-key="name"
flat
bordered
:paging="true"
dense
:filter="historyKeyword"
v-model:pagination="pagination"
:rows-per-page-options="[20, 50, 100]"
class="custom-header-table"
:visible-columns="historyVisibleColumns"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
<q-th auto-width />
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.id">
<div>
{{ col.value === "" ? "-" : col.value }}
</div>
</q-td>
<q-td auto-width> </q-td>
</q-tr>
</template>
</d-table>
</q-card-section>
</q-card> </q-card>
</q-dialog> </q-dialog>
</template> </template>

View file

@ -1,4 +1,5 @@
interface RequestItemsObject { interface RequestItemsObject {
profileId: string
educationLevel: string; educationLevel: string;
institute: string; institute: string;
startYear: number; startYear: number;
@ -16,6 +17,11 @@ interface RequestItemsObject {
duration: string; duration: string;
durationYear: number | null; durationYear: number | null;
note: string; note: string;
educationLevelId: string,
positionPath: string,
positionPathId: string,
isActive: boolean,
isDate: boolean
} }
export type { RequestItemsObject }; export type { RequestItemsObject };