ต่อ api จังหวัด /อำเภอ หน้า information

This commit is contained in:
AnandaTon 2023-03-23 17:06:56 +07:00
parent 3858259b56
commit 4c78d4eab4
3 changed files with 70 additions and 22 deletions

View file

@ -4,9 +4,9 @@ const prefix = `${env.API_URI}/prefix/`
const religion = `${env.API_URI}/religion/` const religion = `${env.API_URI}/religion/`
const relationship = `${env.API_URI}/relationship/` const relationship = `${env.API_URI}/relationship/`
const educationLevel = `${env.API_URI}/education-level/` const educationLevel = `${env.API_URI}/education-level/`
const province = `${env.API_URI}/province/`; const province = `${env.API_URI}/province/`
const district = `${env.API_URI}/district/`; const district = `${env.API_URI}/district/`
const subDistrict = `${env.API_URI}/sub-district/`; const subDistrict = `${env.API_URI}/sub-district/`
export default { export default {
countDashbordSubHistory: (type: number) => `${dashbord}${type}`, countDashbordSubHistory: (type: number) => `${dashbord}${type}`,
@ -17,5 +17,5 @@ export default {
educationLevel, educationLevel,
province, province,
listDistrict: (id: string) => `${district}${id}`, listDistrict: (id: string) => `${district}${id}`,
listSubDistrict: (id: string) => `${subDistrict}${id}`, listSubDistrict: (id: string) => `${subDistrict}${id}`
} }

View file

@ -140,7 +140,7 @@
:outlined="edit" :outlined="edit"
dense dense
lazy-rules lazy-rules
v-model="relationship" v-model="informaData.relationship"
emit-value emit-value
map-options map-options
option-label="name" option-label="name"
@ -183,7 +183,27 @@
/> />
</div> </div>
<div class="col-xs-6 col-sm-3 col-md-3"> <div class="col-xs-6 col-sm-3 col-md-3">
<q-input <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="`${'จังหวัด'}`"
@update:model-value="(value) => selectProvince(value)"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<!-- <q-input
:class="getClass(edit)" :class="getClass(edit)"
hide-bottom-space hide-bottom-space
:outlined="edit" :outlined="edit"
@ -194,27 +214,26 @@
v-model="informaData.cardid" v-model="informaData.cardid"
:rules="[(val) => !!val || `${'กรุณากรอก ออกให้ ณ อำเภอ'}`]" :rules="[(val) => !!val || `${'กรุณากรอก ออกให้ ณ อำเภอ'}`]"
label="ออกให้ ณ อำเภอ" label="ออกให้ ณ อำเภอ"
/> /> -->
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-select <q-select
hide-bottom-space hide-bottom-space
:class="getClass(edit)" :class="getClass(edit)"
:readonly="!edit" :readonly="!edit"
:borderless="!edit" :borderless="!edit"
:rules="[(val) => !!val || `${'กรุณาเลือก จังหวัด'}`]" :rules="[(val) => !!val || `${'กรุณากรอกอำเภอ'}`]"
:outlined="edit" :outlined="edit"
dense dense
lazy-rules lazy-rules
v-model="province" v-model="informaData.districtId"
emit-value emit-value
map-options map-options
option-label="name" option-label="name"
:options="provinceOptions" :options="districtOptions"
option-value="id" option-value="id"
:label="`${'จังหวัด'}`" :label="`${'ออกให้ ณ อำเภอ'}`"
/> />
</div> </div>
<div class="col-xs-6 col-sm-3 col-md-3"> <div class="col-xs-6 col-sm-3 col-md-3">
<datepicker <datepicker
v-model="informaData.cardIdDate" v-model="informaData.cardIdDate"
@ -357,11 +376,9 @@ import { useExamDataStore } from '@/modules/01_exam/store'
const mixin = useCounterMixin() const mixin = useCounterMixin()
const store = useExamDataStore() const store = useExamDataStore()
const { date2Thai, calAge } = mixin const { date2Thai, calAge } = mixin
const prefix = ref<string>()
const province = ref<string>()
const relationship = ref<string>()
const prefixOptions = ref<DataOption[]>([]) const prefixOptions = ref<DataOption[]>([])
const relationshipOptions = ref<DataOption[]>([]) const relationshipOptions = ref<DataOption[]>([])
const districtOptions = ref<DataOption[]>([])
const edit = ref<boolean>(false) const edit = ref<boolean>(false)
const informaData = ref<Information>(defaultInformation) const informaData = ref<Information>(defaultInformation)
@ -417,11 +434,19 @@ onMounted(async () => {
await fetchprefix() await fetchprefix()
await fetchrelationship() await fetchrelationship()
await fetchProvince() await fetchProvince()
await fetchDistrict(informaData.value.provinceId)
}) })
const fetchData = () => { const fetchData = () => {
prefix.value = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c' informaData.value.prefix = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c'
relationship.value = '02fbc0e3-1da0-45b5-90da-783d344b5896' informaData.value.relationship = '02fbc0e3-1da0-45b5-90da-783d344b5896'
province.value = '02fbc0e3-1da0-45b5-90da-783d344b5896' informaData.value.provinceId = '02fbc0e3-1da0-45b5-90da-783d344b5896'
informaData.value.districtId = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c'
}
const selectProvince = (e: string) => {
informaData.value.districtId = ''
myform.value.resetValidation()
fetchDistrict(e)
} }
const saveData = async () => { const saveData = async () => {
@ -450,6 +475,25 @@ const changeBtn = async () => {
}) })
} }
const fetchDistrict = async (id: string) => {
// loader.value = true;
await http
.get(config.API.listDistrict(id))
.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() })
})
districtOptions.value = option
})
.catch((e: any) => {})
.finally(() => {
// loader.value = false;
})
}
const fetchProvince = async () => { const fetchProvince = async () => {
// loader.value = true; // loader.value = true;
await http await http

View file

@ -28,8 +28,11 @@ interface Information {
tel: string tel: string
phone: string phone: string
email: string email: string
province: string
provinceId: string provinceId: string
districtId: string
cardIdDate: Date cardIdDate: Date
relationship: string
statusId: string statusId: string
knowledge: string knowledge: string
} }
@ -227,10 +230,11 @@ const defaultInformation: Information = {
tel: '0914569982', tel: '0914569982',
phone: '0914569982', phone: '0914569982',
email: 'kittapath@frappet.com', email: 'kittapath@frappet.com',
provinceId: 'กรุงเทพ', province: 'กรุงเทพ',
cardIdDate: new Date('2000-01-10'), cardIdDate: new Date('2000-01-10'),
statusId: 'โสด', relationship: 'โสด',
knowledge: 'excel, word, photoshop' knowledge: 'excel, word, photoshop',
district: 'บางพลัด'
} }
const defaultFamily: Family = { const defaultFamily: Family = {