diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue index 721fabea6..2e2b9d0ab 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue @@ -204,7 +204,6 @@ const historyRows = ref([]); const editId = ref(""); const route = useRoute(); const id = ref(route.params.id.toString()); - const isDate = ref("false"); const educationOption = ref([ { label: "ใช่", value: true }, @@ -213,6 +212,8 @@ const educationOption = ref([ const historyDialog = ref(false); const educationData = reactive({ + isDate: isDate.value === "false" ? false : true, + profileId: id.value, educationLevel: "", institute: "", startYear: new Date().getFullYear(), @@ -230,28 +231,18 @@ const educationData = reactive({ duration: "", durationYear: null, note: "", + educationLevelId: "", + positionPath: "", + positionPathId: "", + isActive: true, }); -const formFilter = reactive({ - page: 1, - pageSize: 10, - keyword: "", -}); +const keyword = ref(""); +const historyKeyword = ref(""); 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([ @@ -289,10 +280,6 @@ const historyVisibleColumns = ref([ "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 () => { > - + @@ -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 > ลบข้อมูล @@ -806,7 +704,7 @@ onMounted(async () => { - + {
- -
+
+
{ hide-bottom-space />
-
+
{ hide-bottom-space />
- - +
+
{ autoApply year-picker :enableTimePicker="false" - @update:modelValue="educationData.startYear" + @update:modelValue=" + (v) => + (educationData.startDate = new Date( + `${v}-01-01T00:00:02.010+07:00` + )) + " >