diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/02_NameChangeHistory.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/02_NameChangeHistory.vue index 91fd224cd..b5be35f35 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/02_NameChangeHistory.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/02_NameChangeHistory.vue @@ -24,20 +24,19 @@ const { success, dialogConfirm, messageError, - typeChangeName, showLoader, hideLoader, dialogRemove, } = mixin; -const { calculateAge, fetchPerson } = store; +const { fetchPerson } = store; const profileId = ref(route.params.id.toString()); const editId = ref(""); const dialog = ref(false); const dialogStatus = ref("create"); const filterSearch = ref(""); const filterHistory = ref(""); -const fileName = ref(""); + const modalHistory = ref(false); const rowsHistory = ref([]); const changeNameData = reactive({ @@ -50,20 +49,23 @@ const changeNameData = reactive({ documentId: "", }); +const profileInfo = ref([]); + const statusOption = ref([ "เปลี่ยนคำนำหน้าชื่อ", "เปลี่ยนชื่อ", "เปลี่ยนนามสกุล", "เปลี่ยนชื่อ-นามสกุล", + "เปลี่ยนคำนำหน้าชื่อ และชื่อ", "เปลี่ยนคำนำหน้าชื่อ และนามสกุล", "เปลี่ยนคำนำหน้าชื่อ และชื่อ-นามสกุล", ]); -const prefixFilter = ref([]); const statusOptionFilter = ref([ "เปลี่ยนคำนำหน้าชื่อ", "เปลี่ยนชื่อ", "เปลี่ยนนามสกุล", "เปลี่ยนชื่อ-นามสกุล", + "เปลี่ยนคำนำหน้าชื่อ และชื่อ", "เปลี่ยนคำนำหน้าชื่อ และนามสกุล", "เปลี่ยนคำนำหน้าชื่อ และชื่อ-นามสกุล", ]); @@ -258,13 +260,13 @@ function closeDialog() { dialog.value = false; } -function clearForm() { - changeNameData.status = ""; - changeNameData.prefix = ""; - changeNameData.firstName = ""; - changeNameData.lastName = ""; - alertUpload.value = false; -} +// function clearForm() { +// changeNameData.status = ""; +// changeNameData.prefix = ""; +// changeNameData.firstName = ""; +// changeNameData.lastName = ""; +// alertUpload.value = false; +// } async function onSubmit() { if (!!fileUpload.value) { @@ -334,6 +336,21 @@ async function uploadFileURL(uploadUrl: string, file: any) { }); } +async function fetchDataPersonal() { + showLoader(); + await http + .get(config.API.registryNewByProfileId(profileId.value)) + .then((res) => { + profileInfo.value = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + async function fetchProfile(id: string) { showLoader(); await http @@ -396,24 +413,23 @@ function editData(idData: string) { } function deleteData(idData: string) { - // dialogRemove($q, () => - http - .delete(config.API.profileNewChangeNameByChangeNameId(idData)) - .then(() => { - fetchData(profileId.value); - success($q, "ลบข้อมูลสำเร็จ"); - }) - .catch((err) => { - messageError($q, err); - }) - .finally(() => { - hideLoader(); - }); - // ); + dialogRemove($q, () => + http + .delete(config.API.profileNewChangeNameByChangeNameId(idData)) + .then(() => { + fetchData(profileId.value); + success($q, "ลบข้อมูลสำเร็จ"); + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }) + ); } function deleteFileData(idData: string) { - // dialogRemove($q, () => http .delete( config.API.subFile( @@ -432,7 +448,6 @@ function deleteFileData(idData: string) { .finally(() => { hideLoader(); }); - // ); } async function fetchHistoryData(id: string) { @@ -487,9 +502,9 @@ onMounted(async () => { ) { await fetchPerson(); } - prefixFilter.value = store.Ops.prefixOps; fetchData(profileId.value); + fetchDataPersonal(); }); function filterSelector(val: string, update: Function, refData: string) { switch (refData) { @@ -502,7 +517,7 @@ function filterSelector(val: string, update: Function, refData: string) { break; case "prefixOps": update(() => { - store.Ops.prefixOps = prefixFilter.value.filter( + store.Ops.prefixOps = store.OpsFilter.prefixOps.filter( (v: any) => v.name.indexOf(val) > -1 ); }); @@ -523,9 +538,12 @@ function filterSelector(val: string, update: Function, refData: string) { size="16px" @click=" () => { + changeNameData.prefix = profileInfo.prefix; + changeNameData.firstName = profileInfo.firstName; + changeNameData.lastName = profileInfo.lastName; + changeNameData.status = ''; dialogStatus = 'create'; dialog = true; - clearForm(); } " > @@ -669,7 +687,7 @@ function filterSelector(val: string, update: Function, refData: string) { @@ -717,6 +735,15 @@ function filterSelector(val: string, update: Function, refData: string) {