From c2d386c0262075852256c0ec9c1d2f15f0a3cff3 Mon Sep 17 00:00:00 2001 From: oat_dev Date: Thu, 21 Mar 2024 14:46:19 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5?= =?UTF-8?q?=E0=B8=A2=E0=B8=99=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1?= =?UTF-8?q?=E0=B8=95=E0=B8=B4:=20=E0=B8=84=E0=B8=A7=E0=B8=B2=E0=B8=A1?= =?UTF-8?q?=E0=B8=AA=E0=B8=B2=E0=B8=A1=E0=B8=B2=E0=B8=A3=E0=B8=96=E0=B8=9E?= =?UTF-8?q?=E0=B8=B4=E0=B9=80=E0=B8=A8=E0=B8=A9=20clean=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PersonalInformation/05_Education.vue | 9 +- .../PersonalInformation/06_SpecialSkill.vue | 229 ++++++++---------- .../interface/request/Education.ts | 1 - .../interface/request/SpecialSkill.ts | 3 + 4 files changed, 107 insertions(+), 135 deletions(-) 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 2e2b9d0ab..06d4d0512 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/05_Education.vue @@ -234,7 +234,6 @@ const educationData = reactive({ educationLevelId: "", positionPath: "", positionPathId: "", - isActive: true, }); const keyword = ref(""); @@ -770,7 +769,7 @@ onMounted(async () => { year-picker :enableTimePicker="false" @update:modelValue=" - (v) => + (v:number) => (educationData.startDate = new Date( `${v}-01-01T00:00:02.010+07:00` )) @@ -813,7 +812,7 @@ onMounted(async () => { year-picker :enableTimePicker="false" @update:modelValue=" - (v) => + (v:number) => (educationData.endDate = new Date( `${v}-01-01T00:00:02.010+07:00` )) @@ -858,7 +857,7 @@ onMounted(async () => { :enableTimePicker="false" week-start="0" @update:modelValue=" - (v) => + (v: Date) => (educationData.startYear = parseInt( v.toString().slice(11, 15) )) @@ -901,7 +900,7 @@ onMounted(async () => { :enableTimePicker="false" week-start="0" @update:modelValue=" - (v) => + (v: Date) => (educationData.endYear = parseInt( v.toString().slice(11, 15) )) diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/06_SpecialSkill.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/06_SpecialSkill.vue index 0d5250ee8..c1e11e9e6 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/06_SpecialSkill.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/06_SpecialSkill.vue @@ -76,34 +76,22 @@ const historyRows = ref([]); const route = useRoute(); const id = ref(route.params.id.toString()); const editId = ref(""); - -const formFilter = reactive({ - page: 1, - pageSize: 10, - keyword: "", -}); +const keyword = ref(""); +const historyKeyword = ref(""); const specialSkill = reactive({ field: "", detail: "", remark: "", reference: "", + profileId: id.value, + dateStart: null, + dateEnd: null, }); 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([ @@ -127,10 +115,6 @@ function closeHistoryDialog() { historyDialog.value = false; } -function validateForm() { - onSubmit(); -} - async function onSubmit() { dialogConfirm( $q, @@ -166,7 +150,6 @@ async function fetchData(id: string) { .get(config.API.profileNewAbilityByProfileId(id)) .then(async (res) => { rows.value = res.data.result; - console.log(rows.value); }) .catch((err) => { messageError($q, err); @@ -194,12 +177,7 @@ async function fetchHistoryData(id: string) { async function addData() { await http .post(config.API.profileNewAbility, { - profileId: id.value, - isActive: true, - remark: specialSkill.remark, - field: specialSkill.field, - reference: specialSkill.reference, - detail: specialSkill.detail, + ...specialSkill, dateStart: null, dateEnd: null, }) @@ -218,13 +196,10 @@ async function addData() { async function editData(idData: string) { await http .patch(config.API.profileNewAbilityByAbilityId(idData), { - isActive: true, - remark: specialSkill.remark, - field: specialSkill.field, - reference: specialSkill.reference, - detail: specialSkill.detail, + ...specialSkill, dateStart: null, dateEnd: null, + profileId: undefined, }) .then(() => { fetchData(id.value); @@ -239,17 +214,20 @@ async function editData(idData: string) { } async function deleteData(idData: string) { - await http - .delete(config.API.profileNewAbilityByAbilityId(idData)) - .then(() => { - fetchData(id.value); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); + dialogRemove($q, () => + http + .delete(config.API.profileNewAbilityByAbilityId(idData)) + .then(() => { + fetchData(id.value); + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }) + ); } onMounted(async () => { @@ -268,13 +246,7 @@ onMounted(async () => { เพิ่ม - + @@ -338,7 +310,7 @@ onMounted(async () => { :columns="columns" :rows="rows" :paging="true" - :filter="formFilter.keyword" + :filter="keyword" v-model:pagination="pagination" :rows-per-page-options="[20, 50, 100]" :visible-columns="visibleColumns" @@ -396,9 +368,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 > ลบข้อมูล @@ -461,9 +431,12 @@ onMounted(async () => { - + - + @@ -527,80 +500,78 @@ onMounted(async () => { - - - - - - - - - - - - - - - + + + + + + + - diff --git a/src/modules/04_registryNew/interface/request/Education.ts b/src/modules/04_registryNew/interface/request/Education.ts index 67d89b59c..624ac34ba 100644 --- a/src/modules/04_registryNew/interface/request/Education.ts +++ b/src/modules/04_registryNew/interface/request/Education.ts @@ -20,7 +20,6 @@ interface RequestItemsObject { educationLevelId: string, positionPath: string, positionPathId: string, - isActive: boolean, isDate: boolean } diff --git a/src/modules/04_registryNew/interface/request/SpecialSkill.ts b/src/modules/04_registryNew/interface/request/SpecialSkill.ts index 5e1aeea3e..6cb687908 100644 --- a/src/modules/04_registryNew/interface/request/SpecialSkill.ts +++ b/src/modules/04_registryNew/interface/request/SpecialSkill.ts @@ -3,6 +3,9 @@ interface RequestItemsObject { detail: string; remark: string; reference: string; + dateStart: Date | null, + dateEnd: Date | null , + profileId: string, } export type { RequestItemsObject };