diff --git a/src/api/exam/api.metadata.ts b/src/api/exam/api.metadata.ts index 780d9f2..b76e483 100644 --- a/src/api/exam/api.metadata.ts +++ b/src/api/exam/api.metadata.ts @@ -4,9 +4,9 @@ const prefix = `${env.API_URI}/prefix/` const religion = `${env.API_URI}/religion/` const relationship = `${env.API_URI}/relationship/` const educationLevel = `${env.API_URI}/education-level/` -const province = `${env.API_URI}/province/`; -const district = `${env.API_URI}/district/`; -const subDistrict = `${env.API_URI}/sub-district/`; +const province = `${env.API_URI}/province/` +const district = `${env.API_URI}/district/` +const subDistrict = `${env.API_URI}/sub-district/` export default { countDashbordSubHistory: (type: number) => `${dashbord}${type}`, @@ -17,5 +17,5 @@ export default { educationLevel, province, listDistrict: (id: string) => `${district}${id}`, - listSubDistrict: (id: string) => `${subDistrict}${id}`, + listSubDistrict: (id: string) => `${subDistrict}${id}` } diff --git a/src/modules/01_exam/components/Form/Profile/Information.vue b/src/modules/01_exam/components/Form/Profile/Information.vue index f2becca..4ab50b7 100644 --- a/src/modules/01_exam/components/Form/Profile/Information.vue +++ b/src/modules/01_exam/components/Form/Profile/Information.vue @@ -140,7 +140,7 @@ :outlined="edit" dense lazy-rules - v-model="relationship" + v-model="informaData.relationship" emit-value map-options option-label="name" @@ -183,7 +183,27 @@ />
- +
+
+
+
() -const province = ref() -const relationship = ref() const prefixOptions = ref([]) const relationshipOptions = ref([]) +const districtOptions = ref([]) const edit = ref(false) const informaData = ref(defaultInformation) @@ -417,11 +434,19 @@ onMounted(async () => { await fetchprefix() await fetchrelationship() await fetchProvince() + await fetchDistrict(informaData.value.provinceId) }) const fetchData = () => { - prefix.value = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c' - relationship.value = '02fbc0e3-1da0-45b5-90da-783d344b5896' - province.value = '02fbc0e3-1da0-45b5-90da-783d344b5896' + informaData.value.prefix = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c' + informaData.value.relationship = '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 () => { @@ -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 () => { // loader.value = true; await http diff --git a/src/modules/01_exam/interface/index/Main.ts b/src/modules/01_exam/interface/index/Main.ts index 0c17658..324ff22 100644 --- a/src/modules/01_exam/interface/index/Main.ts +++ b/src/modules/01_exam/interface/index/Main.ts @@ -28,8 +28,11 @@ interface Information { tel: string phone: string email: string + province: string provinceId: string + districtId: string cardIdDate: Date + relationship: string statusId: string knowledge: string } @@ -227,10 +230,11 @@ const defaultInformation: Information = { tel: '0914569982', phone: '0914569982', email: 'kittapath@frappet.com', - provinceId: 'กรุงเทพ', + province: 'กรุงเทพ', cardIdDate: new Date('2000-01-10'), - statusId: 'โสด', - knowledge: 'excel, word, photoshop' + relationship: 'โสด', + knowledge: 'excel, word, photoshop', + district: 'บางพลัด' } const defaultFamily: Family = {