ต่อ api ประวัติการศึกษา
This commit is contained in:
parent
8d2b93b6a3
commit
0760ae1981
9 changed files with 357 additions and 222 deletions
|
|
@ -48,7 +48,7 @@
|
|||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="prefixRelation"
|
||||
v-model="familyData.prefixIdC"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
|
|
@ -126,7 +126,7 @@
|
|||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="prefixDad"
|
||||
v-model="familyData.prefixIdM"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
|
|
@ -204,7 +204,7 @@
|
|||
:outlined="edit"
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="prefixMom"
|
||||
v-model="familyData.prefixIdF"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
|
|
@ -281,6 +281,7 @@
|
|||
<script setup lang="ts">
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import type { PropType } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
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'
|
||||
|
|
@ -290,12 +291,10 @@ import { useExamDataStore } from '@/modules/01_exam/store'
|
|||
import http from '@/plugins/http'
|
||||
import config from '@/app.config'
|
||||
|
||||
const $q = useQuasar()
|
||||
const mixin = useCounterMixin()
|
||||
const store = useExamDataStore()
|
||||
const { date2Thai, calAge } = mixin
|
||||
const prefixRelation = ref<string>()
|
||||
const prefixMom = ref<string>()
|
||||
const prefixDad = ref<string>()
|
||||
const { date2Thai, calAge, success } = mixin
|
||||
const prefixDadOptions = ref<DataOption[]>([])
|
||||
const prefixMomOptions = ref<DataOption[]>([])
|
||||
const prefixRelationOptions = ref<DataOption[]>([])
|
||||
|
|
@ -304,6 +303,8 @@ const myform = ref<any>()
|
|||
const familyData = ref<Family>(defaultFamily)
|
||||
const statusOptions = ref<DataOption[]>([])
|
||||
const modalConsend = ref<boolean>(false)
|
||||
const candidateId = ref<string>('2223ba53-2fb2-470b-8dc1-27e5471b0331')
|
||||
const loader = ref<boolean>(false)
|
||||
|
||||
// const prefixOptions = ref<any>([
|
||||
// { id: "1", name: "นาย" },
|
||||
|
|
@ -338,10 +339,33 @@ onMounted(async () => {
|
|||
await fetchprefixDad()
|
||||
await 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 fetchData = async () => {
|
||||
loader.value = true
|
||||
await http
|
||||
.get(config.API.candidateFamily(candidateId.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result
|
||||
familyData.value.prefixIdC = data.marryPrefixId
|
||||
familyData.value.firstnameC = data.marryFirstName
|
||||
familyData.value.lastnameC = data.marryLastName
|
||||
familyData.value.occupationC = data.marryOccupation
|
||||
familyData.value.nationalityC = data.marryNationality
|
||||
familyData.value.prefixIdM = data.fatherPrefixId
|
||||
familyData.value.firstnameM = data.fatherFirstName
|
||||
familyData.value.lastnameM = data.fatherLastName
|
||||
familyData.value.occupationM = data.fatherOccupation
|
||||
familyData.value.nationalityM = data.fatherNationality
|
||||
familyData.value.prefixIdF = data.motherPrefixId
|
||||
familyData.value.firstnameF = data.motherFirstName
|
||||
familyData.value.lastnameF = data.motherLastName
|
||||
familyData.value.occupationF = data.motherOccupation
|
||||
familyData.value.nationalityF = data.motherNationality
|
||||
familyData.value.same = data.marry == true ? '1' : data.marry == false ? '0' : null
|
||||
})
|
||||
.catch((e: any) => {})
|
||||
.finally(() => {
|
||||
loader.value = false
|
||||
})
|
||||
}
|
||||
|
||||
const fetchprefixMom = async () => {
|
||||
|
|
@ -399,31 +423,63 @@ const fetchprefixRelation = async () => {
|
|||
}
|
||||
|
||||
const saveData = async () => {
|
||||
if (store.consend == true) {
|
||||
edit.value = false
|
||||
emit('update:statusEdit', false)
|
||||
} else {
|
||||
modalConsend.value = true
|
||||
}
|
||||
}
|
||||
|
||||
const changeBtn = async () => {
|
||||
await myform.value.validate().then(async (success: boolean) => {
|
||||
if (success) {
|
||||
if (edit.value == true) {
|
||||
if (props.statusEdit === true) {
|
||||
edit.value = false
|
||||
props.notiNoEdit()
|
||||
} else {
|
||||
emit('update:statusEdit', true)
|
||||
}
|
||||
if (store.consend == true) {
|
||||
loader.value = true
|
||||
await http
|
||||
.post(config.API.candidateFamily(candidateId.value), {
|
||||
marryPrefixId: familyData.value.prefixIdC,
|
||||
marryFirstName: familyData.value.firstnameC,
|
||||
marryLastName: familyData.value.lastnameC,
|
||||
marryOccupation: familyData.value.occupationC,
|
||||
marryNationality: familyData.value.nationalityC,
|
||||
fatherPrefixId: familyData.value.prefixIdM,
|
||||
fatherFirstName: familyData.value.firstnameM,
|
||||
fatherLastName: familyData.value.lastnameM,
|
||||
fatherOccupation: familyData.value.occupationM,
|
||||
fatherNationality: familyData.value.nationalityM,
|
||||
motherPrefixId: familyData.value.prefixIdF,
|
||||
motherFirstName: familyData.value.firstnameF,
|
||||
motherLastName: familyData.value.lastnameF,
|
||||
motherOccupation: familyData.value.occupationF,
|
||||
motherNationality: familyData.value.nationalityF,
|
||||
marry: familyData.value.same == '1' ? true : familyData.value.same == '0' ? false : null
|
||||
})
|
||||
.then((res) => {
|
||||
success($q, 'บันทึกข้อมูลครอบครัวสำเร็จ')
|
||||
edit.value = false
|
||||
emit('update:statusEdit', false)
|
||||
})
|
||||
.catch((e) => {
|
||||
// modalError.value = true
|
||||
// modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้'
|
||||
// modalErrorDetail.value = e.response.data.message
|
||||
// statusCode.value = e.response.data.status
|
||||
})
|
||||
.finally(async () => {
|
||||
await fetchData()
|
||||
})
|
||||
} else {
|
||||
emit('update:statusEdit', false)
|
||||
modalConsend.value = true
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changeBtn = async () => {
|
||||
if (edit.value == true) {
|
||||
if (props.statusEdit === true) {
|
||||
edit.value = false
|
||||
props.notiNoEdit()
|
||||
} else {
|
||||
emit('update:statusEdit', true)
|
||||
}
|
||||
} else {
|
||||
emit('update:statusEdit', false)
|
||||
}
|
||||
}
|
||||
|
||||
const selectRadio = (e: boolean, i: any) => {
|
||||
if (!e) {
|
||||
familyData.value.prefixIdC = ''
|
||||
|
|
@ -437,7 +493,7 @@ const consenClose = () => {
|
|||
modalConsend.value = false
|
||||
}
|
||||
|
||||
const consendOk = () => {
|
||||
const consendOk = async () => {
|
||||
modalConsend.value = false
|
||||
store.consend = true
|
||||
saveData()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue