รวมข้อมูลสมัคึรสอบไว้หน้าเดียว

This commit is contained in:
Kittapath 2023-03-28 14:51:48 +07:00
parent a95c2fcbb4
commit 05d19419e7
11 changed files with 341 additions and 285 deletions

View file

@ -0,0 +1,399 @@
<!-- card อาช -->
<template>
<q-card flat bordered class="col-12 q-px-lg q-py-md q-mt-md">
<HeaderTop
v-model:edit="edit"
header="อาชีพ"
icon="mdi-briefcase"
:save="saveData"
:addData="true"
:editOnly="false"
:cancel="cancelData"
:editData="status == 'register' || status == 'rejectRegister'"
:disable="statusEdit"
/>
<!-- :changeBtn="changeBtn" -->
<q-form ref="myform">
<div class="row col-12 items-center q-col-gutter-x-xs q-col-gutter-y-xs">
<div class="col-12 row">
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.official"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:disable="
occupationData.status !== 'official' ||
!(status == 'register' || status == 'rejectRegister')
"
>
<template v-slot:before>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="official"
label="ข้าราชการกรุงเทพมหานคร ตำแหน่ง"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
</template>
</q-input>
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.personnel"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:disable="
occupationData.status !== 'personnel' ||
!(status == 'register' || status == 'rejectRegister')
"
>
<template v-slot:before>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="personnel"
label="บุคลากรกรุงเทพมหานคร ตำแหน่ง"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
</template>
</q-input>
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.officialsOther"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:disable="
occupationData.status !== 'officialsOther' ||
!(status == 'register' || status == 'rejectRegister')
"
>
<template v-slot:before>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="officialsOther"
label="ข้าราชการประเภทอื่น ตำแหน่ง"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
</template>
</q-input>
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.employee"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:disable="
occupationData.status !== 'employee' ||
!(status == 'register' || status == 'rejectRegister')
"
>
<template v-slot:before>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="employee"
label="ลูกจ้าง/พนักงานราชการของส่วนราชการอื่น ตำแหน่ง"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
</template>
</q-input>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="studying"
label="กำลังศึกษาต่อ"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.other"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:disable="
occupationData.status !== 'other' ||
!(status == 'register' || status == 'rejectRegister')
"
>
<template v-slot:before>
<q-radio
v-model="occupationData.status"
checked-icon="task_alt"
unchecked-icon="panorama_fish_eye"
val="other"
label="อื่นๆ"
dense
:disable="!(status == 'register' || status == 'rejectRegister')"
size="md"
style="font-size: 14px; color: black"
/>
</template>
</q-input>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
:outlined="status == 'register' || status == 'rejectRegister'"
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.company"
:rules="[(val) => !!val || `${'กรุณากรอก สำนัก/บริษัท'}`]"
:label="`${'สำนัก/บริษัท'}`"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
:outlined="status == 'register' || status == 'rejectRegister'"
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.department"
:rules="[(val) => !!val || `${'กรุณากรอก กอง/ฝ่าย'}`]"
:label="`${'กอง/ฝ่าย'}`"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
:outlined="status == 'register' || status == 'rejectRegister'"
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.email"
:rules="[(val) => !!val || `${'กรุณากรอก E-mail address'}`]"
:label="`${'E-mail address'}`"
/>
</div>
<div class="col-xs-6 col-sm-3 col-md-3">
<q-input
:class="getClass(status == 'register' || status == 'rejectRegister')"
hide-bottom-space
:outlined="status == 'register' || status == 'rejectRegister'"
dense
lazy-rules
type="textarea"
autogrow
:readonly="!(status == 'register' || status == 'rejectRegister')"
:borderless="!(status == 'register' || status == 'rejectRegister')"
v-model="occupationData.tel"
:rules="[(val) => !!val || `${'กรุณากรอก โทรศัพท์'}`]"
:label="`${'โทรศัพท์'}`"
/>
</div>
</div>
</q-form>
</q-card>
<!-- <q-dialog :model-value="modalConsend" persistent>
<q-card style="min-width: 800px">
<Conference :ok="consendOk" :close="consenClose" />
</q-card>
</q-dialog> -->
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useQuasar } from 'quasar'
import { useCounterMixin } from '@/stores/mixin'
import http from '@/plugins/http'
import config from '@/app.config'
import { useExamDataStore } from '@/modules/01_exam/store'
import type { Occupation } from '@/modules/01_exam/interface/index/Main'
import { defaultOccupation } from '@/modules/01_exam/interface/index/Main'
import HeaderTop from '@/components/top.vue'
import Conference from '@/modules/01_exam/components/Conference.vue'
const props = defineProps({
statusEdit: {
type: Boolean,
required: true
},
notiNoEdit: {
type: Function,
default: () => console.log('not function')
},
status: {
type: String,
required: true
}
})
const $q = useQuasar()
const mixin = useCounterMixin()
const store = useExamDataStore()
const { success } = mixin
const edit = ref<boolean>(true)
const occupationData = ref<Occupation>(defaultOccupation)
const myform = ref<any>()
// const modalConsend = ref<boolean>(false)
const loader = ref<boolean>(false)
const candidateId = ref<string>('2223ba53-2fb2-470b-8dc1-27e5471b0331')
const emit = defineEmits(['update:statusEdit'])
onMounted(async () => {
await fetchData()
})
const fetchData = async () => {
loader.value = true
await http
.get(config.API.candidateOccupation(candidateId.value))
.then((res) => {
const data = res.data.result
occupationData.value.status = data.occupationType
occupationData.value.company = data.occupationCompany
occupationData.value.department = data.occupationDepartment
occupationData.value.email = data.occupationEmail
occupationData.value.tel = data.occupationTelephone
occupationData.value.official =
data.occupationType == 'official' ? data.occupationPosition : null
occupationData.value.personnel =
data.occupationType == 'personnel' ? data.occupationPosition : null
occupationData.value.officialsOther =
data.occupationType == 'officialsOther' ? data.occupationPosition : null
occupationData.value.employee =
data.occupationType == 'employee' ? data.occupationPosition : null
occupationData.value.other = data.occupationType == 'other' ? data.occupationPosition : null
})
.catch(() => {})
.finally(() => {
loader.value = false
})
}
const saveData = async () => {
await myform.value.validate().then(async (suc: boolean) => {
if (suc) {
// if (store.consend == true) {
const type = ref<string | null>('')
if (occupationData.value.status == 'official') type.value = occupationData.value.official
if (occupationData.value.status == 'personnel') type.value = occupationData.value.personnel
if (occupationData.value.status == 'officialsOther')
type.value = occupationData.value.officialsOther
if (occupationData.value.status == 'employee') type.value = occupationData.value.employee
if (occupationData.value.status == 'other') type.value = occupationData.value.other
loader.value = true
await http
.post(config.API.candidateOccupation(candidateId.value), {
occupationType: occupationData.value.status,
occupationCompany: occupationData.value.company,
occupationDepartment: occupationData.value.department,
occupationEmail: occupationData.value.email,
occupationTelephone: occupationData.value.tel,
occupationPosition: type.value
})
.then(() => {
success($q, 'บันทึกข้อมูลอาชีพสำเร็จ')
// edit.value = false
emit('update:statusEdit', false)
})
.catch(() => {
// modalError.value = true
// modalErrorTittle.value = ''
// modalErrorDetail.value = e.response.data.message
// statusCode.value = e.response.data.status
})
.finally(async () => {
loader.value = false
await fetchData()
})
// } else {
// 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 consenClose = () => {
// modalConsend.value = false
// }
// const consendOk = () => {
// modalConsend.value = false
// store.consend = true
// saveData()
// }
const cancelData = () => {}
const getClass = (val: boolean) => {
return {
'full-width inputgreen cursor-pointer': val,
'full-width cursor-pointer': !val
}
}
</script>