From 6868e209d7c2c7252555210d454896b31c3be012 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Mon, 25 Mar 2024 07:56:07 +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=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=95=E0=B8=B4=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B8=95=E0=B8=B1=E0=B8=A7=20(GET=20history)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/PersonalInformation/01_Profile.vue | 117 ++++++++---------- 1 file changed, 55 insertions(+), 62 deletions(-) diff --git a/src/modules/04_registryNew/components/detail/PersonalInformation/01_Profile.vue b/src/modules/04_registryNew/components/detail/PersonalInformation/01_Profile.vue index 659d5180a..29e5c4558 100644 --- a/src/modules/04_registryNew/components/detail/PersonalInformation/01_Profile.vue +++ b/src/modules/04_registryNew/components/detail/PersonalInformation/01_Profile.vue @@ -12,7 +12,6 @@ import HistoryTable from "@/components/TableHistory.vue"; import DialogHeader from "@/components/DialogHeader.vue"; import type { RequestObject } from "@/modules/04_registryNew/interface/request/Profile"; import type { ResponseObject } from "@/modules/04_registryNew/interface/response/Profile"; -import type { RequestItemsHistoryObject } from "@/modules/04_registryNew/interface/request/Information"; const $q = useQuasar(); const route = useRoute(); @@ -24,8 +23,7 @@ const { hideLoader, date2Thai, messageError, - convertDate, - dateToISO, + dialogConfirm, } = mixin; const { calculateAge, getGender, getRelationship, getReligion, getBloodGroup } = store; @@ -34,9 +32,8 @@ const profileId = ref( ); const modal = ref(false); -const myForm = ref(); const informaData = ref(); -const rowsHistory = ref([]); +const rowsHistory = ref([]); const tittleHistory = ref("ประวัติแก้ไขข้อมูลส่วนตัว"); const filterHistory = ref(""); const modalHistory = ref(false); @@ -44,7 +41,7 @@ const modalHistory = ref(false); const id = ref(""); const age = ref(""); // หลังบ้านไม่มีข้อมูล สัญชาติ -const nationality = ref("") +const nationality = ref(""); const formData = reactive({ citizenId: "", prefix: "", @@ -139,6 +136,7 @@ const columnsHistory = ref([ field: "birthDate", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (v) => date2Thai(v), sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, @@ -147,7 +145,7 @@ const columnsHistory = ref([ align: "left", label: "เพศ", sortable: true, - field: "gender", + field: (v) => (v.gender ? v.gender.name : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -158,7 +156,7 @@ const columnsHistory = ref([ align: "left", label: "สถานภาพ", sortable: true, - field: "relationship", + field: (v) => (v.relationship ? v.relationship.name : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -169,7 +167,7 @@ const columnsHistory = ref([ align: "left", label: "หมู่เลือด", sortable: true, - field: "bloodGroup", + field: (v) => (v.bloodGroup ? v.bloodGroup.name : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -187,11 +185,11 @@ const columnsHistory = ref([ a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, { - name: "race", + name: "ethnicity", align: "left", label: "เชื้อชาติ", sortable: true, - field: "race", + field: "ethnicity", headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -202,7 +200,7 @@ const columnsHistory = ref([ align: "left", label: "ศาสนา", sortable: true, - field: "religion", + field: (v) => (v.religion ? v.religion.name : "-"), headerStyle: "font-size: 14px", style: "font-size: 14px", sort: (a: string, b: string) => @@ -219,28 +217,6 @@ const columnsHistory = ref([ sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, - { - name: "employeeType", - align: "left", - label: "ประเภทการจ้าง", - sortable: true, - field: "employeeType", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, - { - name: "employeeClass", - align: "left", - label: "ประเภทลูกจ้าง", - sortable: true, - field: "employeeClass", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - sort: (a: string, b: string) => - a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), - }, { name: "createdFullName", align: "left", @@ -260,6 +236,7 @@ const columnsHistory = ref([ field: "createdAt", headerStyle: "font-size: 14px", style: "font-size: 14px", + format: (v) => date2Thai(v), sort: (a: string, b: string) => a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }), }, @@ -275,11 +252,9 @@ const visibleColumnsHistory = ref([ "relationship", "bloodGroup", "nationality", - "race", + "ethnicity", "religion", "phone", - "employeeType", - "employeeClass", "createdFullName", "createdAt", ]); @@ -291,6 +266,7 @@ async function getData() { .then((res) => { informaData.value = res.data.result; if (informaData.value) { + id.value = informaData.value.id; age.value = calculateAge(informaData.value.birthDate); } }) @@ -302,6 +278,24 @@ async function getData() { }); } +async function editData() { + showLoader(); + await http + .put(config.API.profileNewProfileById(id.value), { + ...formData, + }) + .then((res) => { + success($q, "บันทึกข้อมูลสำเร็จ"); + getData(), (modal.value = false); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); +} + function onClickOpenDialog() { if (!informaData.value) return; modal.value = true; @@ -322,15 +316,24 @@ function onClickOpenDialog() { formData.phone = informaData.value.phone; } -async function editData() { - showLoader(); +function onSubmit() { + dialogConfirm( + $q, + async () => { + editData(); + modal.value = false; + }, + "ยืนยันการบันทึกข้อมูล", + "ต้องการยืนยันการบันทึกข้อมูลนี้หรือไม่ ?" + ); +} + +async function clickHistory() { + modalHistory.value = true; await http - .put(config.API.profileNewProfileById(id.value), { - ...formData, - }) + .get(config.API.profileNewProfileHisById(id.value)) .then((res) => { - success($q, "บันทึกข้อมูลสำเร็จ"); - getData(), (modal.value = false); + rowsHistory.value = res.data.result; }) .catch((e) => { messageError($q, e); @@ -349,11 +352,6 @@ watch( } ); -function onSubmit() { - editData(); - modal.value = false; -} - onMounted(async () => { await getData(); store.genderOp.length === 0 ? await getGender() : ""; @@ -374,7 +372,7 @@ onMounted(async () => { > แก้ไขข้อมูล - + ประวัติข้อมูลส่วนตัว @@ -384,7 +382,7 @@ onMounted(async () => {
-
+
{
-
+
{{ informaData.citizenId }}
@@ -419,7 +417,7 @@ onMounted(async () => {
-
+
{
-
+
{{ informaData.nationality ? informaData.nationality : "-" }}
@@ -489,6 +487,7 @@ onMounted(async () => { map-options hide-bottom-space input-debounce="0" + new-value-mode="add-unique" v-model="formData.prefix" class="inputgreen" :options="store.prefixOp" @@ -716,14 +715,8 @@ onMounted(async () => {