378 lines
12 KiB
Vue
378 lines
12 KiB
Vue
<!-- card ข้อมูลส่วนตัว -->
|
|
<template>
|
|
<q-card flat bordered class="col-12 q-px-lg q-py-md">
|
|
<HeaderTop v-model:edit="edit" header="ข้อมูลส่วนตัว" icon="mdi-account" :save="saveData" />
|
|
<q-form ref="myform" class="col-12">
|
|
<div class="row col-12 items-center q-col-gutter-x-sm q-col-gutter-y-sm">
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-select
|
|
hide-bottom-space
|
|
:class="getClass(edit)"
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
v-model="informaData.prefixId"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
:options="prefixOptions"
|
|
option-value="id"
|
|
:label="`${'คำนำหน้า'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.firstname"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก ชื่อ'}`]"
|
|
:label="`${'ชื่อ'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.lastname"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก นามสกุล'}`]"
|
|
:label="`${'นามสกุล'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.nationality"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก สัญชาติ'}`]"
|
|
:label="`${'สัญชาติ'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<datepicker
|
|
v-model="informaData.birthDate"
|
|
:locale="'th'"
|
|
autoApply
|
|
:enableTimePicker="false"
|
|
week-start="0"
|
|
:max-date="new Date()"
|
|
>
|
|
<template #year="{ year }">
|
|
{{ year + 543 }}
|
|
</template>
|
|
<template #year-overlay-value="{ value }">
|
|
{{ parseInt(value + 543) }}
|
|
</template>
|
|
<template #trigger>
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
:model-value="date2Thai(informaData.birthDate)"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี เกิด'}`]"
|
|
:label="`${'วัน/เดือน/ปี เกิด'}`"
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
|
|
</q-icon>
|
|
</template>
|
|
</q-input>
|
|
</template>
|
|
</datepicker>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
dense
|
|
lazy-rules
|
|
readonly
|
|
borderless
|
|
:style="!edit ? '' : 'padding:0 12px;'"
|
|
:model-value="calAge(informaData.birthDate)"
|
|
:label="`${'อายุ'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-select
|
|
hide-bottom-space
|
|
:class="getClass(edit)"
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือก สถานภาพ'}`]"
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
v-model="informaData.statusId"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
:options="statusOptions"
|
|
option-value="id"
|
|
:label="`${'สถานภาพ'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.email"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก E-mail address'}`]"
|
|
label="E-mail address"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.cardid"
|
|
maxlength="13"
|
|
:rules="[
|
|
(val) => !!val || `${'กรุณากรอก เลขบัตรประจำตัวประชาชน'}`,
|
|
(val) => val.length >= 13 || `${'กรุณากรอกเลขบัตรประจำตัวประชาชนให้ครบ'}`
|
|
]"
|
|
label="เลขบัตรประจำตัวประชาชน"
|
|
mask="#############"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.cardid"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก ออกให้ ณ อำเภอ'}`]"
|
|
label="ออกให้ ณ อำเภอ"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-select
|
|
hide-bottom-space
|
|
:class="getClass(edit)"
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือก จังหวัด'}`]"
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
v-model="informaData.provinceId"
|
|
emit-value
|
|
map-options
|
|
option-label="name"
|
|
:options="provinceOptions"
|
|
option-value="id"
|
|
:label="`${'จังหวัด'}`"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<datepicker
|
|
v-model="informaData.cardIdDate"
|
|
:locale="'th'"
|
|
autoApply
|
|
:enableTimePicker="false"
|
|
week-start="0"
|
|
:max-date="new Date()"
|
|
>
|
|
<template #year="{ year }">
|
|
{{ year + 543 }}
|
|
</template>
|
|
<template #year-overlay-value="{ value }">
|
|
{{ parseInt(value + 543) }}
|
|
</template>
|
|
<template #trigger>
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
:model-value="date2Thai(informaData.cardIdDate)"
|
|
:rules="[(val) => !!val || `${'กรุณาเลือก วัน/เดือน/ปี'}`]"
|
|
:label="`${'วัน/เดือน/ปี'}`"
|
|
>
|
|
<template v-slot:prepend>
|
|
<q-icon name="event" class="cursor-pointer" style="color: var(--q-primary)">
|
|
</q-icon>
|
|
</template>
|
|
</q-input>
|
|
</template>
|
|
</datepicker>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
type="tel"
|
|
:class="getClass(edit)"
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.tel"
|
|
:rules="[
|
|
(val) => !!val || `${'กรุณากรอก โทรศัพท์'}`,
|
|
(val) => val.length >= 9 || `${'กรุณากรอกข้อมูลโทรศัพท์ให้ครบ'}`
|
|
]"
|
|
:label="`${'โทรศัพท์'}`"
|
|
mask="#########"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-6 col-sm-3 col-md-3">
|
|
<q-input
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
type="tel"
|
|
:class="getClass(edit)"
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.phone"
|
|
:rules="[
|
|
(val) => !!val || `${'กรุณากรอก โทรศัพท์มือถือ'}`,
|
|
(val) => val.length >= 10 || `${'กรุณากรอกข้อมูลโทรศัพท์มือถือให้ครบ'}`
|
|
]"
|
|
:label="`${'โทรศัพท์มือถือ'}`"
|
|
mask="##########"
|
|
/>
|
|
</div>
|
|
<div class="col-xs-12 col-sm-12 col-md-12">
|
|
<q-input
|
|
:class="getClass(edit)"
|
|
hide-bottom-space
|
|
:outlined="edit"
|
|
dense
|
|
lazy-rules
|
|
:readonly="!edit"
|
|
:borderless="!edit"
|
|
v-model="informaData.knowledge"
|
|
:rules="[(val) => !!val || `${'กรุณากรอก ความรู้ความสามารถพิเศษ'}`]"
|
|
label="ความรู้ความสามารถพิเศษ"
|
|
type="textarea"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</q-form>
|
|
</q-card>
|
|
</template>
|
|
<script setup lang="ts">
|
|
import { ref, onMounted } from 'vue'
|
|
import { useCounterMixin } from '@/stores/mixin'
|
|
import type { PropType } from 'vue'
|
|
import type { Information, DataOption } from '@/modules/01_exam/interface/index/Main'
|
|
import { defaultInformation } from '@/modules/01_exam/interface/index/Main'
|
|
import HeaderTop from '@/components/top.vue'
|
|
import http from '@/plugins/http'
|
|
import config from '@/app.config'
|
|
|
|
const mixin = useCounterMixin()
|
|
const { date2Thai, calAge } = mixin
|
|
|
|
const edit = ref<boolean>(false)
|
|
const informaData = ref<Information>(defaultInformation)
|
|
const provinceOptions = ref<DataOption[]>([])
|
|
const myform = ref<any>()
|
|
|
|
const props = defineProps({
|
|
prefixOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
},
|
|
genderOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
},
|
|
bloodOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
},
|
|
statusOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
},
|
|
religionOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
},
|
|
provinceOptions: {
|
|
type: Array as PropType<DataOption[]>,
|
|
required: true
|
|
}
|
|
})
|
|
|
|
onMounted(() => {
|
|
// console.log(props);
|
|
fetchProvince()
|
|
})
|
|
|
|
const saveData = async () => {
|
|
await myform.value.validate().then(async (success: boolean) => {
|
|
if (success) {
|
|
} else {
|
|
}
|
|
})
|
|
}
|
|
|
|
const fetchProvince = async () => {
|
|
// loader.value = true;
|
|
await http
|
|
.get(config.API.province)
|
|
.then((res) => {
|
|
const data = res.data.result
|
|
let option: DataOption[] = []
|
|
// console.log(data);
|
|
data.map((r: any) => {
|
|
option.push({ id: r.id.toString(), name: r.name.toString() })
|
|
})
|
|
provinceOptions.value = option
|
|
})
|
|
.catch((e: any) => {})
|
|
.finally(() => {
|
|
// loader.value = false;
|
|
})
|
|
}
|
|
|
|
const getClass = (val: boolean) => {
|
|
return {
|
|
'full-width inputgreen cursor-pointer': val,
|
|
'full-width cursor-pointer': !val
|
|
}
|
|
}
|
|
</script>
|