ขออัปเดตข้อมูลจากกรมการปกครอง

This commit is contained in:
setthawutttty 2024-10-11 15:42:38 +07:00
parent 189347832c
commit c49d222a3f
10 changed files with 2155 additions and 14 deletions

View file

@ -0,0 +1,364 @@
<script setup lang="ts">
import { type PropType, watch } from "vue";
import { useQuasar } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import { useCounterMixin } from "@/stores/mixin";
import { useProfileDataStore } from "@/modules/04_registryPerson/stores/profile";
import type { RequestObject } from "@/modules/04_registryPerson/interface/request/Profile";
const formInformations = defineModel<RequestObject>("formInformations", {
required: true,
});
const age = defineModel<string | null>("age", {
required: true,
});
const $q = useQuasar();
const storeProfile = useProfileDataStore();
const { filterSelector, calculateAge } = storeProfile;
const { date2Thai, messageError, dialogMessageNotify } = useCounterMixin();
const props = defineProps({
Ops: {
type: Object as PropType<any>,
},
OpsFilter: {
type: Object as PropType<any>,
},
});
const dataLabel = {
citizenId: "เลขประจำตัวประชาชน",
name: "ชื่อ - สกุล",
birthDate: "วัน/เดือน/ปีเกิด",
age: "อายุ",
gender: "เพศ",
relationship: "สถานภาพ",
nationality: "สัญชาติ",
ethnicity: "เชื้อชาติ",
religion: "ศาสนา",
bloodGroup: "หมู่เลือด",
phone: "เบอร์โทร",
prefix: "คำนำหน้าชื่อ",
rank: "ยศ",
firstName: "ชื่อ",
lastName: "นามสกุล",
};
/**
* function เชคเลขประจำตวประชาชนช
* @param citizenId เลขประจำตวประชาชน
*/
function changeCardID(citizenId: string | number | null) {
if (citizenId != null && typeof citizenId == "string") {
if (citizenId.length == 13 && citizenId) {
http
.put(config.API.profileNewCitizenId(citizenId), {
citizenId: citizenId,
})
.then(() => {})
.catch((err) => {
if (err.response.data.status === 500) {
dialogMessageNotify($q, err.response.data.message);
} else {
messageError($q, err);
}
});
}
}
}
/**
* function เชคอายไมเก 18
*/
function calculateMaxDate() {
const today = new Date();
today.setFullYear(today.getFullYear() - 18);
return today;
}
/**
* การเปลยนแปลงของวนเกดเมอมการเปลยนแปลงจะคำนวนอายใหม
*/
watch(
() => formInformations.value.birthDate,
(v) => {
if (v) {
age.value = calculateAge(v);
}
}
);
</script>
<template>
<div class="row col-12 q-col-gutter-x-xs q-col-gutter-y-xs">
<div class="col-12 text-tooltip text-weight-medium">อมลสวนต</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
readonly
lazy-rules
hide-bottom-space
maxlength="13"
mask="#############"
v-model="formInformations.citizenId"
class="inputgreen"
:label="dataLabel.citizenId"
:rules="[
(val: string) => !!val || `${'กรุณากรอก เลขประจำตัวประชาชน'}`,
(val: string) =>
val.length >= 13 ||
`${'กรุณากรอกเลขประจำตัวประชาชนให้ครบ'}`,
]"
@update:model-value="changeCardID"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
use-input
lazy-rules
emit-value
map-options
hide-bottom-space
input-debounce="0"
option-label="name"
option-value="name"
v-model="formInformations.prefix"
class="inputgreen"
:options="props.Ops.prefixOps"
:label="dataLabel.prefix"
:rules="[(val: string) => !!val || `${'กรุณาเลือก คำนำหน้าชื่อ'}`]"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'prefixOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
clearable
use-input
lazy-rules
emit-value
map-options
hide-bottom-space
input-debounce="0"
option-label="name"
option-value="name"
v-model="formInformations.rank"
class="inputgreen"
:options="props.Ops.rankOps"
:label="dataLabel.rank"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'rankOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="formInformations.firstName"
class="inputgreen"
:label="dataLabel.firstName"
:rules="[(val: string) => !!val || `${'กรุณากรอก ชื่อ'}`]"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
v-model="formInformations.lastName"
class="inputgreen"
:label="dataLabel.lastName"
:rules="[(val: string) => !!val || `${'กรุณากรอก นามสกุล'}`]"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<datepicker
autoApply
:max-date="calculateMaxDate()"
borderless
:enableTimePicker="false"
week-start="0"
menu-class-name="modalfix"
v-model="formInformations.birthDate"
:locale="'th'"
>
<template #year="{ year }">
{{ year + 543 }}
</template>
<template #year-overlay-value="{ value }">
{{ parseInt(value + 543) }}
</template>
<template #trigger>
<q-input
for="inputDatereceive"
ref="dateReceivedRef"
outlined
dense
hide-bottom-space
class="inputgreen"
:model-value="
formInformations.birthDate
? date2Thai(formInformations.birthDate)
: null
"
:label="dataLabel.birthDate"
:rules="[
(val:string) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`,
]"
>
<template v-slot:prepend>
<q-icon name="event" class="cursor-pointer" color="primary">
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
readonly
v-model="age"
:label="dataLabel.age"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
use-input
clearable
lazy-rules
emit-value
map-options
hide-bottom-space
input-debounce="0"
option-label="name"
option-value="name"
v-model="formInformations.gender"
class="inputgreen"
:options="props.Ops.genderOps"
:label="dataLabel.gender"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'genderOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
use-input
clearable
lazy-rules
emit-value
map-options
hide-bottom-space
option-value="name"
option-label="name"
input-debounce="0"
class="inputgreen"
v-model="formInformations.relationship"
:options="props.Ops.statusOps"
:label="dataLabel.relationship"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'statusOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
v-model="formInformations.nationality"
:label="dataLabel.nationality"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
class="inputgreen"
v-model="formInformations.ethnicity"
:label="dataLabel.ethnicity"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
use-input
clearable
lazy-rules
emit-value
map-options
hide-bottom-space
option-value="name"
option-label="name"
input-debounce="0"
v-model="formInformations.religion"
class="inputgreen"
:options="props.Ops.religionOps"
:label="dataLabel.religion"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'religionOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-select
dense
outlined
use-input
clearable
lazy-rules
emit-value
map-options
hide-bottom-space
option-value="name"
option-label="name"
input-debounce="0"
v-model="formInformations.bloodGroup"
class="inputgreen"
:options="props.Ops.bloodOps"
:label="dataLabel.bloodGroup"
@filter="(inputValue: string,
doneFn: Function) => filterSelector(inputValue, doneFn, 'bloodOps'
)"
/>
</div>
<div class="col-xs-6 col-sm-6 col-md-3">
<q-input
dense
outlined
lazy-rules
hide-bottom-space
mask="##########"
class="inputgreen"
v-model="formInformations.phone"
:label="dataLabel.phone"
/>
</div>
</div>
</template>