diff --git a/src/modules/05_placement/components/PersonalDetail/CheckInformation/01_FormInformations.vue b/src/modules/05_placement/components/PersonalDetail/CheckInformation/01_FormInformations.vue index 3404b2b22..ac9e81160 100644 --- a/src/modules/05_placement/components/PersonalDetail/CheckInformation/01_FormInformations.vue +++ b/src/modules/05_placement/components/PersonalDetail/CheckInformation/01_FormInformations.vue @@ -21,6 +21,7 @@ const { showLoader, hideLoader, messageError, dateToISO, date2Thai } = mixin; const informaData = defineModel("formInformations", { required: true, }); +const age = defineModel("age", { required: true }); const props = defineProps({ Ops: { type: Object as PropType, @@ -30,8 +31,6 @@ const props = defineProps({ }, }); -const age = ref(true); //อายุ - /** * ฟังก์เลือกวันเดือนปีเกิด * @param modelData วันเดือนปีเกิด @@ -165,7 +164,6 @@ function filterSelector(val: string, update: Function, refData: string) { lazy-rules v-model="informaData.prefixId" emit-value - readonly map-options option-label="name" :options="Ops.prefixOps" @@ -183,7 +181,6 @@ function filterSelector(val: string, update: Function, refData: string) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="informaData.firstname" @@ -196,7 +193,6 @@ function filterSelector(val: string, update: Function, refData: string) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="informaData.lastname" @@ -209,7 +205,6 @@ function filterSelector(val: string, update: Function, refData: string) { v-model="informaData.dateOfBirth" :locale="'th'" autoApply - readonly :enableTimePicker="false" week-start="0" :max-date="new Date()" @@ -225,7 +220,6 @@ function filterSelector(val: string, update: Function, refData: string) { { outlined dense lazy-rules - readonly type="textarea" autogrow v-model="addressData.registAddress" @@ -352,7 +351,6 @@ onMounted(() => { :rules="[(val: string) => !!val || `${'กรุณาเลือก จังหวัด'}`]" outlined dense - readonly lazy-rules v-model="registAddress.provinceId" emit-value @@ -376,7 +374,6 @@ onMounted(() => { :rules="[(val: string) => !!val || `${'กรุณาเลือก เขต / อำเภอ'}`]" outlined dense - readonly lazy-rules v-model="registAddress.districtId" emit-value @@ -401,7 +398,6 @@ onMounted(() => { outlined dense lazy-rules - readonly v-model="registAddress.subDistrictId" emit-value map-options @@ -440,7 +436,6 @@ onMounted(() => { checked-icon="task_alt" unchecked-icon="panorama_fish_eye" val="1" - disable label="ใช่" dense /> @@ -449,7 +444,6 @@ onMounted(() => { checked-icon="task_alt" unchecked-icon="panorama_fish_eye" val="0" - disable label="ไม่" dense /> @@ -462,7 +456,6 @@ onMounted(() => { outlined dense lazy-rules - readonly type="textarea" autogrow v-model="addressData.currentAddress" @@ -481,7 +474,6 @@ onMounted(() => { outlined dense lazy-rules - readonly v-model="currentAddress.provinceId" emit-value map-options @@ -507,7 +499,6 @@ onMounted(() => { :rules="[(val: string) => !!val || `${'กรุณาเลือก เขต / อำเภอ'}`]" outlined dense - readonly lazy-rules v-model="currentAddress.districtId" emit-value @@ -534,7 +525,6 @@ onMounted(() => { :rules="[(val: string) => !!val || `${'กรุณาเลือก แขวง / ตำบล '}`]" outlined dense - readonly lazy-rules v-model="currentAddress.subDistrictId" emit-value diff --git a/src/modules/05_placement/components/PersonalDetail/CheckInformation/03_FormFamily.vue b/src/modules/05_placement/components/PersonalDetail/CheckInformation/03_FormFamily.vue index dd66018c3..802e06fd5 100644 --- a/src/modules/05_placement/components/PersonalDetail/CheckInformation/03_FormFamily.vue +++ b/src/modules/05_placement/components/PersonalDetail/CheckInformation/03_FormFamily.vue @@ -56,7 +56,6 @@ function selectRadio(e: boolean) { v-model="familyData.fatherPrefixId" emit-value map-options - readonly option-label="name" :options="Ops.prefixOps" option-value="id" @@ -74,7 +73,6 @@ function selectRadio(e: boolean) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="familyData.fatherFirstName" @@ -88,7 +86,6 @@ function selectRadio(e: boolean) { hide-bottom-space outlined dense - readonly lazy-rules v-model="familyData.fatherLastName" :rules="[(val:string) => !!val || `${'กรุณากรอก นามสกุล'}`]" @@ -101,7 +98,6 @@ function selectRadio(e: boolean) { hide-bottom-space outlined dense - readonly lazy-rules v-model="familyData.fatherOccupation" :label="`${'อาชีพ'}`" @@ -117,7 +113,6 @@ function selectRadio(e: boolean) { :rules="[(val:string) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]" outlined dense - readonly lazy-rules v-model="familyData.motherPrefixId" emit-value @@ -139,7 +134,6 @@ function selectRadio(e: boolean) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="familyData.motherFirstName" @@ -152,7 +146,6 @@ function selectRadio(e: boolean) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="familyData.motherLastName" @@ -165,7 +158,6 @@ function selectRadio(e: boolean) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="familyData.motherOccupation" @@ -182,7 +174,6 @@ function selectRadio(e: boolean) { val="1" label="มี" dense - disable @update:model-value="selectRadio" /> @@ -205,7 +195,6 @@ function selectRadio(e: boolean) { outlined dense lazy-rules - readonly v-model="familyData.marryPrefixId" emit-value map-options @@ -228,7 +217,6 @@ function selectRadio(e: boolean) { outlined dense lazy-rules - readonly v-model="familyData.marryFirstName" :rules="[(val:string) => !!val || `${'กรุณากรอก ชื่อ'}`]" :label="`${'ชื่อ'}`" @@ -240,7 +228,6 @@ function selectRadio(e: boolean) { hide-bottom-space outlined dense - readonly lazy-rules v-model="familyData.marryLastName" :rules="[(val:string) => !!val || `${'กรุณากรอก นามสกุล'}`]" @@ -252,7 +239,6 @@ function selectRadio(e: boolean) { class="inputgreen" hide-bottom-space outlined - readonly dense lazy-rules v-model="familyData.marryOccupation" diff --git a/src/modules/05_placement/components/PersonalDetail/DetailMain.vue b/src/modules/05_placement/components/PersonalDetail/DetailMain.vue index 3cdb7a10f..a202b3b33 100644 --- a/src/modules/05_placement/components/PersonalDetail/DetailMain.vue +++ b/src/modules/05_placement/components/PersonalDetail/DetailMain.vue @@ -492,11 +492,14 @@ function checkInformation() { modalCheck.value = true; } +async function getAll() { + await Promise.all([fetchData(), changeTab("information"), fetchPerson()]); +} /** * ทำงานเมื่อมีการเรียกใช้ Components */ onMounted(async () => { - await Promise.all([fetchData(), changeTab("information"), fetchPerson()]); + getAll(); }); @@ -609,6 +612,7 @@ onMounted(async () => { :Ops="Ops" :Ops-filter="OpsFilter" :id-card="InformationData.idCard" + :get-all="getAll" /> diff --git a/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue b/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue index e0c0cb591..5c22cb8b4 100644 --- a/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue +++ b/src/modules/05_placement/components/PersonalDetail/DialogCheckInformation.vue @@ -11,6 +11,7 @@ import { AddressDataDefualt, FamilyDataDefualt, } from "@/modules/05_placement/interface/index/Main"; +import { useProfileDataStore } from "@/modules/05_placement/store"; import { defaultInformation } from "@/modules/05_placement/components/PersonalDetail/profileType"; import type { Information } from "@/modules/05_placement/components/PersonalDetail/profileType"; @@ -30,13 +31,25 @@ import FormFamilyPage from "@/modules/05_placement/components/PersonalDetail/Che const modal = defineModel("modal", { required: true }); const idCard = defineModel("idCard", { required: true }); + const $q = useQuasar(); const route = useRoute(); const router = useRouter(); const mixin = useCounterMixin(); -const { showLoader, hideLoader, messageError } = mixin; +const profileStore = useProfileDataStore(); +const { changeRetireText, changeBirth } = profileStore; +const { + showLoader, + hideLoader, + messageError, + dialogConfirm, + modalError, + success, +} = mixin; const store = useLinkageStore(); +const age = ref(true); //อายุ + const props = defineProps({ Ops: { type: Object as PropType, @@ -57,32 +70,13 @@ const props = defineProps({ type: Object as PropType, default: FamilyDataDefualt, }, + getAll: Function, }); const addressData = ref(props.AddressData); const familyData = ref(props.familyData); //ข้อมูลครอบครัว /** ตัวแปร ข้อมูลส่วนตัว */ -const formInformations = reactive({ - idCard: "", // เลข ปชช. - prefix: "", // คำนำหน้า - prefixId: "", // id คำนำหน้า - fullName: "", // ชื่อเต็ม - firstname: "", //ชื่อ - lastname: "", //นามสกุล - nationality: "", //สัญชาติ - race: "", //เชื้อชาติ - dateOfBirth: null, //วันเกิด - age: "", //อายุ - telephone: "", //เบอร์มือถือ - gender: "", //เพศ - genderId: "", //id เพศ - relationship: "", //สถานภาพ - relationshipId: "", //id สถานภาพ - bloodGroup: "", //กร๊ปเลือด - bloodGroupId: "", //id กรุ๊ปเลือด - religion: "", //ศาสนา - religionId: "", //id ศาสนา -}); +const formInformations = reactive(props.InformationData); //ที่อยู่ปัจบัน const currentAddress = reactive({ @@ -99,26 +93,6 @@ const registAddress = reactive({ provinceId: "", }); -/** ตัวแปร ข้อมูลครอบครัว */ -const formFamily = reactive({ - couple: "", - marryPrefix: "", - marryPrefixId: "", - marryFirstName: "", - marryLastName: "", - marryOccupation: "", - fatherPrefix: "", - fatherPrefixId: "", - fatherFirstName: "", - fatherLastName: "", - fatherOccupation: "", - motherPrefix: "", - motherPrefixId: "", - motherFirstName: "", - motherLastName: "", - motherOccupation: "", -}); - //ตัวเลือกข้อมูลที่อยู่ const OpsAddress = ref({ provinceOps: [], @@ -138,26 +112,7 @@ const OpsFilterAddress = ref({ function closeDialog() { modal.value = false; - - formInformations.idCard = ""; - formInformations.prefix = ""; - formInformations.prefixId = ""; - formInformations.fullName = ""; - formInformations.firstname = ""; - formInformations.lastname = ""; - formInformations.nationality = ""; - formInformations.race = ""; - formInformations.dateOfBirth = null; - formInformations.age = ""; - formInformations.telephone = ""; - formInformations.gender = ""; - formInformations.genderId = ""; - formInformations.relationship = ""; - formInformations.relationshipId = ""; - formInformations.bloodGroup = ""; - formInformations.bloodGroupId = ""; - formInformations.religion = ""; - formInformations.religionId = ""; + props.getAll?.(); } function onSubmit() { @@ -208,7 +163,7 @@ function onSubmit() { coupleLastName: familyData.value.marryLastName, coupleLastNameOld: "", coupleCareer: familyData.value.marryOccupation, - + fatherPrefix: familyData.value.fatherPrefixId, fatherFirstName: familyData.value.fatherFirstName, fatherLastName: familyData.value.fatherLastName, @@ -220,83 +175,205 @@ function onSubmit() { motherCareer: familyData.value.motherOccupation, }; - console.log(body); + dialogConfirm($q, async () => { + if (age.value == false) { + modalError($q, "พบข้อผิดพลาด", "วันเกิดไม่ถูกต้อง"); + return; + } else { + showLoader(); + await upDateInfomation(); + await upDateAddress(); + await upDateFamily(); + + success($q, "บันทึกข้อมูลสำเร็จ"); + closeDialog(); + await props.getAll?.(); + await changeBirth(formInformations.dateOfBirth ?? new Date()); + hideLoader(); + } + }); } const data = ref(null); /** ดึงข้อมูลรายละเอียด */ async function amiRequest() { const profile = await store.amiRequest($q, 5000, idCard.value, "001"); - if (profile) { - data.value = profile; - formInformations.idCard = idCard.value; - formInformations.prefix = data.value.titleName; - formInformations.prefixId = data.value.titleName; - formInformations.fullName = data.value.fullnameAndRank; - formInformations.firstname = data.value.firstName; - formInformations.lastname = data.value.lastname; - formInformations.nationality = data.value.nationalityDesc; - formInformations.race = props.InformationData.race; - formInformations.dateOfBirth = data.value.dateOfBirth; - formInformations.age = data.value.age; - formInformations.telephone = props.InformationData.telephone; - formInformations.gender = data.value.genderDesc; - formInformations.genderId = data.value.genderDesc; - formInformations.relationship = props.InformationData.relationship; - formInformations.relationshipId = props.InformationData.relationshipId; - formInformations.bloodGroup = props.InformationData.bloodGroup; - formInformations.bloodGroupId = props.InformationData.bloodGroupId; - formInformations.religion = props.InformationData.religionId; - formInformations.religionId = props.InformationData.religionId; + data.value = profile; + formInformations.idCard = idCard.value; + formInformations.prefix = data.value.titleName; + formInformations.prefixId = data.value.titleName; + formInformations.fullName = data.value.fullnameAndRank; + formInformations.firstname = data.value.firstName; + formInformations.lastname = data.value.lastname; + formInformations.nationality = data.value.nationalityDesc; + formInformations.race = props.InformationData.race; + formInformations.dateOfBirth = data.value.dateOfBirth; + formInformations.age = data.value.age; + formInformations.telephone = props.InformationData.telephone; + formInformations.gender = data.value.genderDesc; + formInformations.genderId = data.value.genderDesc; + formInformations.relationship = props.InformationData.relationship; + formInformations.relationshipId = props.InformationData.relationshipId; + formInformations.bloodGroup = props.InformationData.bloodGroup; + formInformations.bloodGroupId = props.InformationData.bloodGroupId; + formInformations.religion = props.InformationData.religionId; + formInformations.religionId = props.InformationData.religionId; - familyData.value.fatherFirstName = data.value.fatherName - familyData.value.motherFirstName = data.value.motherName + familyData.value.fatherFirstName = data.value.fatherName; + familyData.value.motherFirstName = data.value.motherName; - } + // data.value = { + // titleCode: 3, + // titleDesc: "นาย", + // titleName: "นาย", + // titleSex: 1, + // firstName: "สุพลชัย", + // middleName: "", + // lastName: "พูลสวัสดิ์", + // genderCode: 1, + // genderDesc: "ชาย", + // dateOfBirth: 25211228, + // nationalityCode: 99, + // nationalityDesc: "ไทย", + // ownerStatusDesc: "เจ้าบ้าน", + // statusOfPersonCode: 0, + // statusOfPersonDesc: "บุคคลนี้มีภูมิลำเนาอยู่ในบ้านนี้", + // dateOfMoveIn: 25580728, + // age: 45, - data.value = { - titleCode: 3, - titleDesc: "นาย", - titleName: "นาย", - titleSex: 1, - firstName: "สุพลชัย", - middleName: "", - lastName: "พูลสวัสดิ์", - genderCode: 1, - genderDesc: "ชาย", - dateOfBirth: 25211228, - nationalityCode: 99, - nationalityDesc: "ไทย", - ownerStatusDesc: "เจ้าบ้าน", - statusOfPersonCode: 0, - statusOfPersonDesc: "บุคคลนี้มีภูมิลำเนาอยู่ในบ้านนี้", - dateOfMoveIn: 25580728, - age: 45, + // fatherPersonalID: 3102100621479, + // fatherName: "บุญเชิด", + // fatherNationalityCode: 99, + // fatherNationalityDesc: "ไทย", - fatherPersonalID: 3102100621479, - fatherName: "บุญเชิด", - fatherNationalityCode: 99, - fatherNationalityDesc: "ไทย", + // motherPersonalID: 3102100621487, + // motherName: "พยอม", + // motherNationalityCode: 99, + // motherNationalityDesc: "ไทย", - motherPersonalID: 3102100621487, - motherName: "พยอม", - motherNationalityCode: 99, - motherNationalityDesc: "ไทย", + // fullnameAndRank: "นายสุพลชัย พูลสวัสดิ์", + // englishTitleDesc: "MR.", + // englishFirstName: "SUPHONCHAI", + // englishMiddleName: "", + // englishLastName: "PHOONSAWAT", + // }; +} - fullnameAndRank: "นายสุพลชัย พูลสวัสดิ์", - englishTitleDesc: "MR.", - englishFirstName: "SUPHONCHAI", - englishMiddleName: "", - englishLastName: "PHOONSAWAT", +/** + * อัพเดตข้อมูลส่วนตัว + */ +async function upDateInfomation() { + showLoader(); + const body: any = { + citizenId: formInformations.idCard, + prefix: formInformations.prefixId, + firstName: formInformations.firstname, + lastName: formInformations.lastname, + gender: formInformations.genderId, + nationality: formInformations.nationality, + race: formInformations.race, + religion: formInformations.religionId, + birthDate: formInformations.dateOfBirth, + bloodGroup: formInformations.bloodGroupId, + relationship: formInformations.relationshipId, + telephoneNumber: formInformations.telephone, }; + showLoader(); + await http + .put( + config.API.placementInformationId(route.params.personalId.toString()), + body + ) + .then(async () => {}) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => { + hideLoader(); + }); +} + +/** + * ฟังก์ชันบันทึกการแก้ไข + */ +async function upDateAddress() { + const body = { + registrationSame: addressData.value.registSame == "1", + registrationAddress: addressData.value.registAddress, + registrationSubDistrictId: registAddress.subDistrictId, + registrationDistrictId: registAddress.districtId, + registrationProvinceId: registAddress.provinceId, + registrationZipCode: registAddress.zipCode, + currentAddress: + addressData.value.registSame == "1" + ? addressData.value.registAddress + : addressData.value.currentAddress, + currentSubDistrictId: + addressData.value.registSame == "1" + ? registAddress.subDistrictId + : currentAddress.subDistrictId, + currentDistrictId: + addressData.value.registSame == "1" + ? registAddress.districtId + : currentAddress.districtId, + currentProvinceId: + addressData.value.registSame == "1" + ? registAddress.provinceId + : currentAddress.provinceId, + currentZipCode: + addressData.value.registSame == "1" + ? registAddress.zipCode + : currentAddress.zipCode, + }; + await http + .put( + config.API.placementAddressId(route.params.personalId.toString()), + body + ) + .then(async () => {}) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => {}); +} + +async function upDateFamily() { + const body = { + couple: familyData.value.couple == "1", + couplePrefix: familyData.value.marryPrefixId, + coupleFirstName: familyData.value.marryFirstName, + coupleLastName: familyData.value.marryLastName, + coupleLastNameOld: "", + coupleCareer: familyData.value.marryOccupation, + fatherPrefix: familyData.value.fatherPrefixId, + fatherFirstName: familyData.value.fatherFirstName, + fatherLastName: familyData.value.fatherLastName, + fatherCareer: familyData.value.fatherOccupation, + motherPrefix: familyData.value.motherPrefixId, + motherFirstName: familyData.value.motherFirstName, + motherLastName: familyData.value.motherLastName, + motherCareer: familyData.value.motherOccupation, + }; + await http + .put(config.API.placementFamilyId(route.params.personalId.toString()), body) + .then(async () => {}) + .catch((e) => { + messageError($q, e); + hideLoader(); + }) + .finally(() => {}); } /** เช็คค่า modal เมื่อเป็น true ใช้งาน ฟังชั่น */ watch( () => modal.value, async () => { - await amiRequest(); + if (modal.value) { + await amiRequest(); + } } ); @@ -315,6 +392,7 @@ watch( v-model:form-informations="formInformations" :Ops="props.Ops" :OpsFilter="props.OpsFilter" + v-model:age="age" />