From 4c78d4eab487c99a135d340f96575d9f1a803651 Mon Sep 17 00:00:00 2001 From: AnandaTon <125332905+anandaAiemvong@users.noreply.github.com> Date: Thu, 23 Mar 2023 17:06:56 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20api=20=E0=B8=88?= =?UTF-8?q?=E0=B8=B1=E0=B8=87=E0=B8=AB=E0=B8=A7=E0=B8=B1=E0=B8=94=20/?= =?UTF-8?q?=E0=B8=AD=E0=B8=B3=E0=B9=80=E0=B8=A0=E0=B8=AD=20=E0=B8=AB?= =?UTF-8?q?=E0=B8=99=E0=B9=89=E0=B8=B2=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/exam/api.metadata.ts | 8 +- .../components/Form/Profile/Information.vue | 74 +++++++++++++++---- src/modules/01_exam/interface/index/Main.ts | 10 ++- 3 files changed, 70 insertions(+), 22 deletions(-) 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 = {