ปรับ ตรวจสอบข้อมูลกับกรมการปกครอง

This commit is contained in:
setthawutttty 2024-10-10 13:24:26 +07:00
parent adcb1f034f
commit 189347832c
5 changed files with 204 additions and 159 deletions

View file

@ -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<boolean>("modal", { required: true });
const idCard = defineModel<string>("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<boolean>(true); //
const props = defineProps({
Ops: {
type: Object as PropType<any>,
@ -57,32 +70,13 @@ const props = defineProps({
type: Object as PropType<Family>,
default: FamilyDataDefualt,
},
getAll: Function,
});
const addressData = ref<AddressType>(props.AddressData);
const familyData = ref<Family>(props.familyData); //
/** ตัวแปร ข้อมูลส่วนตัว */
const formInformations = reactive<Information>({
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<Information>(props.InformationData);
//
const currentAddress = reactive<AddressData>({
@ -99,26 +93,6 @@ const registAddress = reactive<AddressData>({
provinceId: "",
});
/** ตัวแปร ข้อมูลครอบครัว */
const formFamily = reactive<Family>({
couple: "",
marryPrefix: "",
marryPrefixId: "",
marryFirstName: "",
marryLastName: "",
marryOccupation: "",
fatherPrefix: "",
fatherPrefixId: "",
fatherFirstName: "",
fatherLastName: "",
fatherOccupation: "",
motherPrefix: "",
motherPrefixId: "",
motherFirstName: "",
motherLastName: "",
motherOccupation: "",
});
//
const OpsAddress = ref<AddressOps>({
provinceOps: [],
@ -138,26 +112,7 @@ const OpsFilterAddress = ref<AddressOps>({
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<any>(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();
}
}
);
</script>
@ -315,6 +392,7 @@ watch(
v-model:form-informations="formInformations"
:Ops="props.Ops"
:OpsFilter="props.OpsFilter"
v-model:age="age"
/>
</div>
<div class="col-12">