ทะเบียนประวัติ: ประวัติการศึกษา clean code+แก้การคำนวนปี
This commit is contained in:
parent
ed227359d1
commit
8aa9e2be13
2 changed files with 162 additions and 233 deletions
|
|
@ -204,7 +204,6 @@ const historyRows = ref<ResponseObject[]>([]);
|
|||
const editId = ref<string>("");
|
||||
const route = useRoute();
|
||||
const id = ref<string>(route.params.id.toString());
|
||||
|
||||
const isDate = ref<string>("false");
|
||||
const educationOption = ref([
|
||||
{ label: "ใช่", value: true },
|
||||
|
|
@ -213,6 +212,8 @@ const educationOption = ref([
|
|||
|
||||
const historyDialog = ref<boolean>(false);
|
||||
const educationData = reactive<RequestItemsObject>({
|
||||
isDate: isDate.value === "false" ? false : true,
|
||||
profileId: id.value,
|
||||
educationLevel: "",
|
||||
institute: "",
|
||||
startYear: new Date().getFullYear(),
|
||||
|
|
@ -230,28 +231,18 @@ const educationData = reactive<RequestItemsObject>({
|
|||
duration: "",
|
||||
durationYear: null,
|
||||
note: "",
|
||||
educationLevelId: "",
|
||||
positionPath: "",
|
||||
positionPathId: "",
|
||||
isActive: true,
|
||||
});
|
||||
|
||||
const formFilter = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
});
|
||||
const keyword = ref<string>("");
|
||||
const historyKeyword = ref<string>("");
|
||||
|
||||
const pagination = ref({
|
||||
page: formFilter.page,
|
||||
rowsPerPage: formFilter.pageSize,
|
||||
});
|
||||
|
||||
const historyFormFilter = reactive({
|
||||
page: 1,
|
||||
pageSize: 10,
|
||||
keyword: "",
|
||||
});
|
||||
|
||||
const historyPagination = ref({
|
||||
page: historyFormFilter.page,
|
||||
rowsPerPage: historyFormFilter.pageSize,
|
||||
rowsPerPage: 10,
|
||||
});
|
||||
|
||||
const visibleColumns = ref<string[]>([
|
||||
|
|
@ -289,10 +280,6 @@ const historyVisibleColumns = ref<string[]>([
|
|||
"note",
|
||||
]);
|
||||
|
||||
function validateForm() {
|
||||
onSubmit();
|
||||
}
|
||||
|
||||
async function onSubmit() {
|
||||
dialogConfirm(
|
||||
$q,
|
||||
|
|
@ -364,6 +351,7 @@ async function fetchData(id: string) {
|
|||
.get(config.API.profileNewEducationByProfileId(id))
|
||||
.then(async (res) => {
|
||||
rows.value = res.data.result;
|
||||
console.log(rows.value);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
|
|
@ -391,26 +379,9 @@ async function fetchHistoryData(id: string) {
|
|||
async function addData() {
|
||||
await http
|
||||
.post(config.API.profileNewEducation, {
|
||||
profileId: id.value,
|
||||
isActive: true,
|
||||
country: educationData.country,
|
||||
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,
|
||||
...educationData,
|
||||
startYear: undefined,
|
||||
endYear: undefined,
|
||||
})
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
|
|
@ -424,28 +395,13 @@ async function addData() {
|
|||
});
|
||||
}
|
||||
|
||||
async function editData(idData: string) {
|
||||
await http
|
||||
function editData(idData: string) {
|
||||
http
|
||||
.patch(config.API.profileNewEducationByEducationId(idData), {
|
||||
isActive: true,
|
||||
country: educationData.country,
|
||||
degree: educationData.degree,
|
||||
duration: educationData.duration,
|
||||
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,
|
||||
...educationData,
|
||||
profileId: undefined,
|
||||
startYear: undefined,
|
||||
endYear: undefined,
|
||||
})
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
|
|
@ -459,73 +415,23 @@ async function editData(idData: string) {
|
|||
});
|
||||
}
|
||||
|
||||
async function deleteData(idData: string) {
|
||||
await http
|
||||
.delete(config.API.profileNewEducationByEducationId(idData))
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
function deleteData(idData: string) {
|
||||
dialogRemove($q, () =>
|
||||
http
|
||||
.delete(config.API.profileNewEducationByEducationId(idData))
|
||||
.then(() => {
|
||||
fetchData(id.value);
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.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 () => {
|
||||
await fetchData(id.value);
|
||||
});
|
||||
|
|
@ -551,13 +457,7 @@ onMounted(async () => {
|
|||
>
|
||||
|
||||
<q-space />
|
||||
<q-input
|
||||
dense
|
||||
outlined
|
||||
v-model="formFilter.keyword"
|
||||
label="ค้นหา"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<q-input dense outlined v-model="keyword" label="ค้นหา" class="q-mr-sm">
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
|
|
@ -620,7 +520,7 @@ onMounted(async () => {
|
|||
flat
|
||||
bordered
|
||||
:paging="true"
|
||||
:filter="formFilter.keyword"
|
||||
:filter="keyword"
|
||||
dense
|
||||
v-model:pagination="pagination"
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
|
|
@ -681,9 +581,7 @@ onMounted(async () => {
|
|||
size="14px"
|
||||
icon="mdi-delete"
|
||||
clickable
|
||||
@click.stop="
|
||||
dialogRemove($q, async () => await deleteData(props.row.id))
|
||||
"
|
||||
@click.stop="deleteData(props.row.id)"
|
||||
v-close-popup
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
|
|
@ -806,7 +704,7 @@ onMounted(async () => {
|
|||
|
||||
<q-dialog v-model="dialog" class="dialog" persistent>
|
||||
<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">
|
||||
<dialog-header
|
||||
:tittle="dialogStatus == 'edit' ? 'แก้ไขข้อมูล' : 'เพิ่มข้อมูล'"
|
||||
|
|
@ -815,8 +713,8 @@ onMounted(async () => {
|
|||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<div class="col">
|
||||
<q-card-section class="row q-gutter-sm">
|
||||
<div class="col">
|
||||
<div class="row q-pa-md q-col-gutter-sm">
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
outlined
|
||||
v-model="educationData.educationLevel"
|
||||
|
|
@ -827,7 +725,7 @@ onMounted(async () => {
|
|||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="col-6">
|
||||
<q-input
|
||||
outlined
|
||||
v-model="educationData.institute"
|
||||
|
|
@ -838,8 +736,12 @@ onMounted(async () => {
|
|||
hide-bottom-space
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card flat bordered class="q-px-sm q-mx-md q-mb q-pb-sm borderCard">
|
||||
</div>
|
||||
<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">
|
||||
<q-radio
|
||||
v-model="isDate"
|
||||
|
|
@ -867,7 +769,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
year-picker
|
||||
: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-overlay-value="{ value }">{{
|
||||
|
|
@ -905,7 +812,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
year-picker
|
||||
: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-overlay-value="{ value }">{{
|
||||
|
|
@ -945,6 +857,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
@update:modelValue="
|
||||
(v) =>
|
||||
(educationData.startYear = parseInt(
|
||||
v.toString().slice(11, 15)
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -982,6 +900,12 @@ onMounted(async () => {
|
|||
autoApply
|
||||
:enableTimePicker="false"
|
||||
week-start="0"
|
||||
@update:modelValue="
|
||||
(v) =>
|
||||
(educationData.endYear = parseInt(
|
||||
v.toString().slice(11, 15)
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #year="{ year }">{{ year + 543 }}</template>
|
||||
<template #year-overlay-value="{ value }">{{
|
||||
|
|
@ -1013,7 +937,7 @@ onMounted(async () => {
|
|||
</div>
|
||||
</div>
|
||||
</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">
|
||||
<datepicker
|
||||
menu-class-name="modalfix"
|
||||
|
|
@ -1064,13 +988,14 @@ onMounted(async () => {
|
|||
option-value="value"
|
||||
option-label="label"
|
||||
:rules="[
|
||||
(val) => !!val || `${'กรุณาเลือกวุฒิการศึกษาในตำแหน่ง'}`,
|
||||
(val) =>
|
||||
val !== null || `${'กรุณาเลือกวุฒิการศึกษาในตำแหน่ง'}`,
|
||||
]"
|
||||
label="เป็นวุฒิการศึกษาในตำแหน่ง"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-py-none">
|
||||
</div>
|
||||
<div class="row q-gutter-sm q-px-md q-mb-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -1091,8 +1016,8 @@ onMounted(async () => {
|
|||
dense
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none">
|
||||
</div>
|
||||
<div class="row q-gutter-sm q-px-md q-mb-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -1112,8 +1037,8 @@ onMounted(async () => {
|
|||
mask="#.##"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none">
|
||||
</div>
|
||||
<div class="row q-gutter-sm q-px-md q-mb-sm">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -1132,8 +1057,8 @@ onMounted(async () => {
|
|||
dense
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm q-pb-none">
|
||||
</div>
|
||||
<div class="row q-gutter-sm q-px-md">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -1157,8 +1082,8 @@ onMounted(async () => {
|
|||
dense
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section class="row q-gutter-sm q-pt-sm">
|
||||
</div>
|
||||
<div class="row q-gutter-sm q-px-md">
|
||||
<div class="col">
|
||||
<q-input
|
||||
outlined
|
||||
|
|
@ -1169,7 +1094,7 @@ onMounted(async () => {
|
|||
type="textarea"
|
||||
/>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</div>
|
||||
</div>
|
||||
<q-card-actions align="right">
|
||||
<q-btn
|
||||
|
|
@ -1190,82 +1115,80 @@ onMounted(async () => {
|
|||
|
||||
<q-dialog v-model="historyDialog" class="dialog" persistent>
|
||||
<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">
|
||||
<dialog-header
|
||||
tittle="ประวัติแก้ไขประวัติการศึกษา"
|
||||
:close="closeHistoryDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section>
|
||||
<q-toolbar style="padding: 0px" class="text-primary q-mb-sm">
|
||||
<q-space />
|
||||
<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"
|
||||
<q-card-section class="flex justify-between" style="padding: 0">
|
||||
<dialog-header
|
||||
tittle="ประวัติแก้ไขประวัติการศึกษา"
|
||||
:close="closeHistoryDialog"
|
||||
/>
|
||||
</q-card-section>
|
||||
<q-separator color="grey-4" />
|
||||
<q-card-section>
|
||||
<q-toolbar style="padding: 0px" class="text-primary q-mb-sm">
|
||||
<q-space />
|
||||
<q-input
|
||||
dense
|
||||
:filter="historyFormFilter.keyword"
|
||||
v-model:pagination="historyPagination"
|
||||
:rows-per-page-options="[20, 50, 100]"
|
||||
class="custom-header-table"
|
||||
:visible-columns="historyVisibleColumns"
|
||||
outlined
|
||||
bg-color="white"
|
||||
v-model="historyKeyword"
|
||||
label="ค้นหา"
|
||||
class="q-mr-sm"
|
||||
>
|
||||
<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 v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</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-form>
|
||||
</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
|
||||
: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-dialog>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
interface RequestItemsObject {
|
||||
profileId: string
|
||||
educationLevel: string;
|
||||
institute: string;
|
||||
startYear: number;
|
||||
|
|
@ -16,6 +17,11 @@ interface RequestItemsObject {
|
|||
duration: string;
|
||||
durationYear: number | null;
|
||||
note: string;
|
||||
educationLevelId: string,
|
||||
positionPath: string,
|
||||
positionPathId: string,
|
||||
isActive: boolean,
|
||||
isDate: boolean
|
||||
}
|
||||
|
||||
export type { RequestItemsObject };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue