diff --git a/src/api/exam/api.metadata.ts b/src/api/exam/api.metadata.ts index 5255dea..8f35838 100644 --- a/src/api/exam/api.metadata.ts +++ b/src/api/exam/api.metadata.ts @@ -1,7 +1,15 @@ import env from '../index' const dashbord = `${env.API_URI}/dashbord/` +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/` export default { countDashbordSubHistory: (type: number) => `${dashbord}${type}`, - countDashbordHistory: `${dashbord}` + countDashbordHistory: `${dashbord}`, + prefix, + religion, + relationship, + educationLevel } diff --git a/src/modules/01_exam/components/Form/Education.vue b/src/modules/01_exam/components/Form/Education.vue index 4765502..ef0f20f 100644 --- a/src/modules/01_exam/components/Form/Education.vue +++ b/src/modules/01_exam/components/Form/Education.vue @@ -67,14 +67,14 @@ lazy-rules :readonly="!edit" :borderless="!edit" - v-model="qualificationId" + v-model="educationLevel" :rules="[(val) => !!val || `${'กรุณาเลือกวุฒิที่ได้รับ'}`]" :label="`${'วุฒิที่ได้รับ'}`" @update:modelValue="clickEditRow" emit-value map-options option-label="name" - :options="qualificationOptions" + :options="educationLevelOptions" option-value="id" /> @@ -220,9 +220,10 @@ const store = useExamDataStore() const { examData, changeExamColumns } = store const loader = ref(false) const id = ref() +const educationLevel = ref() const qualification = ref() const qualificationId = ref() -const qualificationOptions = ref([]) +const educationLevelOptions = ref([]) const major = ref() const scores = ref() const name = ref() @@ -333,8 +334,27 @@ watch(edit, (count: boolean, prevCount: boolean) => { onMounted(async () => { // await fetchData() // await fetchQualification() + fetcheducationLevel() }) +const fetcheducationLevel = async () => { + // loader.value = true; + await http + .get(config.API.educationLevel) + .then((res) => { + const data = res.data.result + let option: DataOption[] = [] + data.map((r: DataOption) => { + option.push({ id: r.id.toString(), name: r.name.toString() }) + }) + educationLevelOptions.value = option + }) + .catch((e) => {}) + .finally(() => { + // loader.value = false; + }) +} + const fetchQualification = async () => { // loader.value = true; // await http diff --git a/src/modules/01_exam/components/Form/Profile/Family.vue b/src/modules/01_exam/components/Form/Profile/Family.vue index 82395ad..aa7a401 100644 --- a/src/modules/01_exam/components/Form/Profile/Family.vue +++ b/src/modules/01_exam/components/Form/Profile/Family.vue @@ -48,11 +48,11 @@ :outlined="edit" dense lazy-rules - v-model="familyData.prefixIdC" + v-model="prefixRelation" emit-value map-options option-label="name" - :options="prefixOptions" + :options="prefixRelationOptions" option-value="id" :label="`${'คำนำหน้า'}`" /> @@ -126,11 +126,11 @@ :outlined="edit" dense lazy-rules - v-model="familyData.prefixIdM" + v-model="prefixDad" emit-value map-options option-label="name" - :options="prefixOptions" + :options="prefixDadOptions" option-value="id" :label="`${'คำนำหน้า'}`" /> @@ -204,11 +204,11 @@ :outlined="edit" dense lazy-rules - v-model="familyData.prefixIdF" + v-model="prefixMom" emit-value map-options option-label="name" - :options="prefixOptions" + :options="prefixMomOptions" option-value="id" :label="`${'คำนำหน้า'}`" /> @@ -280,10 +280,17 @@ import { useCounterMixin } from '@/stores/mixin' import type { Family, DataOption } from '@/modules/01_exam/interface/index/Main' import { defaultFamily } 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 prefixRelation = ref() +const prefixMom = ref() +const prefixDad = ref() +const prefixDadOptions = ref([]) +const prefixMomOptions = ref([]) +const prefixRelationOptions = ref([]) const edit = ref(false) const myform = ref() const familyData = ref(defaultFamily) @@ -316,7 +323,71 @@ const props = defineProps({ const emit = defineEmits(['update:statusEdit']) -onMounted(() => {}) +onMounted(() => { + fetchData() + fetchprefixMom() + fetchprefixDad() + fetchprefixRelation() +}) +const fetchData = () => { + prefixRelation.value = 'e4e6a4f8-39c6-467f-bd84-7650d105fc4c' + prefixDad.value = '02fbc0e3-1da0-45b5-90da-783d344b5896' + prefixMom.value = '362405f7-9ca2-4f3a-b5ac-08b56c24555d' +} + +const fetchprefixMom = async () => { + // loader.value = true; + await http + .get(config.API.prefix) + .then((res) => { + const data = res.data.result + let option: DataOption[] = [] + data.map((r: DataOption) => { + option.push({ id: r.id.toString(), name: r.name.toString() }) + }) + prefixMomOptions.value = option + }) + .catch((e) => {}) + .finally(() => { + // loader.value = false; + }) +} + +const fetchprefixDad = async () => { + // loader.value = true; + await http + .get(config.API.prefix) + .then((res) => { + const data = res.data.result + let option: DataOption[] = [] + data.map((r: DataOption) => { + option.push({ id: r.id.toString(), name: r.name.toString() }) + }) + prefixDadOptions.value = option + }) + .catch((e) => {}) + .finally(() => { + // loader.value = false; + }) +} + +const fetchprefixRelation = async () => { + // loader.value = true; + await http + .get(config.API.prefix) + .then((res) => { + const data = res.data.result + let option: DataOption[] = [] + data.map((r: DataOption) => { + option.push({ id: r.id.toString(), name: r.name.toString() }) + }) + prefixRelationOptions.value = option + }) + .catch((e) => {}) + .finally(() => { + // loader.value = false; + }) +} const saveData = async () => { await myform.value.validate().then(async (success: boolean) => { diff --git a/src/modules/01_exam/components/Form/Profile/Information.vue b/src/modules/01_exam/components/Form/Profile/Information.vue index 1495c13..3aa1bd7 100644 --- a/src/modules/01_exam/components/Form/Profile/Information.vue +++ b/src/modules/01_exam/components/Form/Profile/Information.vue @@ -135,11 +135,11 @@ :outlined="edit" dense lazy-rules - v-model="informaData.statusId" + v-model="relationship" emit-value map-options option-label="name" - :options="statusOptions" + :options="relationshipOptions" option-value="id" :label="`${'สถานภาพ'}`" /> @@ -340,8 +340,10 @@ import type { file } from '@babel/types' const mixin = useCounterMixin() const { date2Thai, calAge } = mixin const prefix = ref() +const relationship = ref() const prefixOptions = ref([]) +const relationshipOptions = ref([]) const edit = ref(false) const informaData = ref(defaultInformation) @@ -394,6 +396,7 @@ const emit = defineEmits(['update:statusEdit']) onMounted(() => { // fetchProvince() fetchprefix() + fetchrelationship() }) const saveData = async () => { @@ -452,6 +455,24 @@ const fetchprefix = async () => { // loader.value = false; }) } + +const fetchrelationship = async () => { + // loader.value = true; + await http + .get(config.API.relationship) + .then((res) => { + const data = res.data.result + let option: DataOption[] = [] + data.map((r: DataOption) => { + option.push({ id: r.id.toString(), name: r.name.toString() }) + }) + relationshipOptions.value = option + }) + .catch((e) => {}) + .finally(() => { + // loader.value = false; + }) +} const savePic = () => { disabledPic.value = false }