ต่อ api บุคคลที่สามารถติดต่อได้
This commit is contained in:
parent
57d80e33cb
commit
468f27f74b
6 changed files with 254 additions and 183 deletions
|
|
@ -1,146 +1,167 @@
|
|||
<!-- card บุคคลที่สามารถติดต่อได้ -->
|
||||
<template>
|
||||
<HeaderTop
|
||||
v-model:edit="edit"
|
||||
header="บุคคลที่สามารถติดต่อได้"
|
||||
icon="mdi-account-circle"
|
||||
:addData="true"
|
||||
:editOnly="false"
|
||||
:editData="false"
|
||||
/>
|
||||
<q-form ref="myform">
|
||||
<div class="row col-12 items-center q-col-gutter-x-sm q-col-gutter-y-xs">
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<q-select
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="prefixId"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
:options="prefixOptions"
|
||||
option-value="id"
|
||||
:label="`${'คำนำหน้า'}`"
|
||||
@update:model-value="(value) => selectPrefix()"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-3">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="firstname"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก ชื่อ'}`]"
|
||||
:label="`${'ชื่อ'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-3">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="lastname"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก นามสกุล'}`]"
|
||||
:label="`${'นามสกุล'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-4">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="relations"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกความสัมพันธ์'}`]"
|
||||
:label="`${'เกี่ยวข้องเป็น'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-4">
|
||||
<q-input
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
:counter="status == 'register' || status == 'rejectRegister' ? true : false"
|
||||
lazy-rules
|
||||
type="tel"
|
||||
mask="##########"
|
||||
maxlength="10"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="tel"
|
||||
:label="`${'โทรศัพท์'}`"
|
||||
:rules="[
|
||||
(val) => val.length == 10 || `${'กรุณากรอก โทรศัพท์'}`,
|
||||
(val) => /^[0-9]*$/.test(val) || `${'กรุณากรอกข้อมูลโทรศัพท์ให้ถูกต้อง'}`
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
<HeaderTop
|
||||
v-model:edit="edit"
|
||||
header="บุคคลที่สามารถติดต่อได้"
|
||||
icon="mdi-account-circle"
|
||||
:addData="true"
|
||||
:editOnly="false"
|
||||
:editData="false"
|
||||
/>
|
||||
<q-form ref="myform">
|
||||
<div class="row col-12 items-center q-col-gutter-x-sm q-col-gutter-y-xs">
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<q-select
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
:rules="[(val) => !!val || `${'กรุณาเลือก คำนำหน้า'}`]"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
v-model="defaultContact.contactprefixId"
|
||||
emit-value
|
||||
map-options
|
||||
option-label="name"
|
||||
:options="prefixOptions"
|
||||
option-value="id"
|
||||
:label="`${'คำนำหน้า'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-3">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultContact.contactfirstname"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก ชื่อ'}`]"
|
||||
:label="`${'ชื่อ'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-3">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultContact.contactlastname"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอก นามสกุล'}`]"
|
||||
:label="`${'นามสกุล'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-4">
|
||||
<q-input
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
lazy-rules
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultContact.contactrelations"
|
||||
:rules="[(val) => !!val || `${'กรุณากรอกความสัมพันธ์'}`]"
|
||||
:label="`${'เกี่ยวข้องเป็น'}`"
|
||||
/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-4">
|
||||
<q-input
|
||||
:outlined="status == 'register' || status == 'rejectRegister'"
|
||||
dense
|
||||
:counter="status == 'register' || status == 'rejectRegister' ? true : false"
|
||||
lazy-rules
|
||||
type="tel"
|
||||
mask="##########"
|
||||
maxlength="10"
|
||||
:class="getClass(status == 'register' || status == 'rejectRegister')"
|
||||
:readonly="!(status == 'register' || status == 'rejectRegister')"
|
||||
:borderless="!(status == 'register' || status == 'rejectRegister')"
|
||||
v-model="defaultContact.contacttel"
|
||||
:label="`${'โทรศัพท์'}`"
|
||||
:rules="[
|
||||
(val) => val.length == 10 || `${'กรุณากรอก โทรศัพท์'}`,
|
||||
(val) => /^[0-9]*$/.test(val) || `${'กรุณากรอกข้อมูลโทรศัพท์ให้ถูกต้อง'}`
|
||||
]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</q-form>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { ref, onMounted, watch, PropType } from 'vue'
|
||||
import http from '@/plugins/http'
|
||||
import config from '@/app.config'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useDataStore } from '@/stores/data'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useQuasar } from 'quasar'
|
||||
import type { Occupation } from '@/modules/01_exam/interface/index/Main'
|
||||
import { defaultOccupation, changeData } from '@/modules/01_exam/interface/index/Main'
|
||||
import type { Contact } from '@/modules/01_exam/interface/index/Main'
|
||||
import { defaultContact, changeData } from '@/modules/01_exam/interface/index/Main'
|
||||
import HeaderTop from '@/components/top.vue'
|
||||
import { DataOption } from '../../interface/index/Main'
|
||||
|
||||
const props = defineProps({
|
||||
status: {
|
||||
status: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
form: {
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
prefixOptions: {
|
||||
type: Array as PropType<DataOption[]>,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['update:form'])
|
||||
|
||||
const $q = useQuasar()
|
||||
const dataStore = useDataStore()
|
||||
const { loaderPage } = dataStore
|
||||
const mixin = useCounterMixin()
|
||||
const { messageError } = mixin
|
||||
const edit = ref<boolean>(true)
|
||||
const myform = ref<any>({})
|
||||
|
||||
const prefixId = ref<string>('')
|
||||
const prefixOptions = ref<any>({})
|
||||
const firstname = ref<string>('')
|
||||
const lastname = ref<string>('')
|
||||
const relations = ref<string>('')
|
||||
const tel = ref<string>('')
|
||||
|
||||
const route = useRoute()
|
||||
const examId = ref<string>(route.params.id.toString())
|
||||
const positionId = ref<string>(route.params.positionId.toString())
|
||||
|
||||
watch(myform, async (count: any, prevCount: any) => {
|
||||
emit('update:form', count)
|
||||
emit('update:form', count)
|
||||
})
|
||||
|
||||
watch(defaultOccupation, async (count: Occupation, prevCount: Occupation) => {
|
||||
await changeData('occupation', count)
|
||||
watch(defaultContact, async (count: Contact, prevCount: Contact) => {
|
||||
await changeData('contact', count)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchData()
|
||||
await fetchData()
|
||||
})
|
||||
|
||||
const fetchData = async () => {
|
||||
loaderPage(true)
|
||||
loaderPage(true)
|
||||
await http
|
||||
.get(config.API.candidateContact(examId.value, positionId.value))
|
||||
.then((res) => {
|
||||
const data = res.data.result
|
||||
if (data != null) {
|
||||
defaultContact.value.contactprefixId = data.contactPrefixId
|
||||
defaultContact.value.contactfirstname = data.contactFirstname
|
||||
defaultContact.value.contactlastname = data.contactLastname
|
||||
defaultContact.value.contactrelations = data.contactRelations
|
||||
defaultContact.value.contacttel = data.contactTel
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
// messageError($q, e)
|
||||
})
|
||||
.finally(() => {
|
||||
loaderPage(false)
|
||||
})
|
||||
}
|
||||
|
||||
const getClass = (val: boolean) => {
|
||||
|
|
@ -150,4 +171,3 @@ const getClass = (val: boolean) => {
|
|||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -41,13 +41,13 @@
|
|||
|
||||
<q-separator class="q-my-lg bg-gray" size="5px" />
|
||||
<div class="q-px-sm">
|
||||
<Contact :status="status" />
|
||||
<Contact :status="status" :prefixOptions="prefixOptions" v-model:form="formContact" />
|
||||
</div>
|
||||
|
||||
<q-separator class="q-my-lg bg-gray" size="5px" />
|
||||
<div class="q-px-sm">
|
||||
<!-- <div class="q-px-sm">
|
||||
<Document :status="status" />
|
||||
</div>
|
||||
</div> -->
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
|
|
@ -86,13 +86,18 @@ const props = defineProps({
|
|||
formOccupation: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
formContact: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
const emit = defineEmits([
|
||||
'update:formInformation',
|
||||
'update:formAddress',
|
||||
'update:formEducation',
|
||||
'update:formOccupation'
|
||||
'update:formOccupation',
|
||||
'update:formContact'
|
||||
])
|
||||
|
||||
const $q = useQuasar()
|
||||
|
|
@ -108,6 +113,7 @@ const formInformation = ref<any>({})
|
|||
const formAddress = ref<any>({})
|
||||
const formEducation = ref<any>({})
|
||||
const formOccupation = ref<any>({})
|
||||
const formContact = ref<any>({})
|
||||
|
||||
watch(formInformation, async (count: Object, prevCount: Object) => {
|
||||
emit('update:formInformation', count)
|
||||
|
|
@ -125,6 +131,10 @@ watch(formOccupation, async (count: Object, prevCount: Object) => {
|
|||
emit('update:formOccupation', count)
|
||||
})
|
||||
|
||||
watch(formContact, async (count: Object, prevCount: Object) => {
|
||||
emit('update:formContact', count)
|
||||
})
|
||||
|
||||
onMounted(async () => {
|
||||
await fetchPerson()
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue