refactor code
This commit is contained in:
parent
d2c352de17
commit
92fc21033d
50 changed files with 652 additions and 2170 deletions
|
|
@ -44,9 +44,9 @@
|
|||
import { onMounted, ref } from 'vue'
|
||||
import { useQuasar } from 'quasar'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { useDataStore } from '@/stores/data'
|
||||
import http from '@/plugins/http'
|
||||
import config from '@/app.config'
|
||||
import Profile from '@/modules/01_exam/components/Form/Profile.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import {
|
||||
defaultInformation,
|
||||
|
|
@ -54,6 +54,7 @@ import {
|
|||
defaultAddress,
|
||||
defaultFamily
|
||||
} from '@/modules/01_exam/interface/index/Main'
|
||||
import Profile from '@/modules/01_exam/components/Form/Profile.vue'
|
||||
|
||||
const props = defineProps({
|
||||
fetchStep: {
|
||||
|
|
@ -68,8 +69,9 @@ const props = defineProps({
|
|||
|
||||
const $q = useQuasar()
|
||||
const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง
|
||||
const { modalConfirm, modalError, success, dateToISO } = mixin
|
||||
const loader = ref<boolean>(false)
|
||||
const { modalConfirm, modalError, success, dateToISO, messageError } = mixin
|
||||
const dataStore = useDataStore()
|
||||
const { loaderPage } = dataStore
|
||||
const statusEdit = ref<boolean>(false)
|
||||
const acceptTermOfUse = ref<boolean>(false)
|
||||
const route = useRoute()
|
||||
|
|
@ -82,9 +84,6 @@ const formOccupation = ref<any>({})
|
|||
const saveAuto = ref<boolean>(false)
|
||||
|
||||
onMounted(async () => {
|
||||
// if (props.status !== 'register') {
|
||||
// acceptTermOfUse.value = true
|
||||
// }
|
||||
await fetchStatus()
|
||||
})
|
||||
|
||||
|
|
@ -103,31 +102,30 @@ const okModalConfirm = () => {
|
|||
}
|
||||
|
||||
const fetchStatus = async () => {
|
||||
loader.value = true
|
||||
loaderPage(true)
|
||||
await http
|
||||
.get(config.API.candidateCard(examId.value, positionId.value))
|
||||
.then((res) => {
|
||||
acceptTermOfUse.value = true
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
acceptTermOfUse.value = false
|
||||
})
|
||||
.finally(() => {
|
||||
loader.value = false
|
||||
loaderPage(false)
|
||||
})
|
||||
}
|
||||
|
||||
const saveForm = async () => {
|
||||
loader.value = true
|
||||
loaderPage(true)
|
||||
await http
|
||||
.get(config.API.candidateRegister(examId.value, positionId.value))
|
||||
.then(() => {
|
||||
// success($q, 'สมัครสอบสำเร็จสำเร็จ')
|
||||
.then(() => {})
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.catch(() => {})
|
||||
.finally(async () => {
|
||||
await props.fetchStep()
|
||||
loader.value = false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -156,7 +154,7 @@ const saveData = async () => {
|
|||
type.value = defaultOccupation.value.employee
|
||||
if (defaultOccupation.value.status == 'other')
|
||||
type.value = defaultOccupation.value.other
|
||||
loader.value = true
|
||||
loaderPage(true)
|
||||
await http
|
||||
.post(config.API.candidateId(examId.value, positionId.value), {
|
||||
prefixId: defaultInformation.value.prefixId,
|
||||
|
|
@ -227,14 +225,10 @@ const saveData = async () => {
|
|||
success($q, 'บันทึกข้อมูลส่วนตัวสำเร็จ')
|
||||
if (saveAuto.value) await saveForm()
|
||||
})
|
||||
.catch(() => {
|
||||
// modalError.value = true
|
||||
// modalErrorTittle.value = 'ไม่สามารถบันทึกข้อมูลร่างได้'
|
||||
// modalErrorDetail.value = e.response.data.message
|
||||
// statusCode.value = e.response.data.status
|
||||
.catch((e) => {
|
||||
messageError($q, e)
|
||||
})
|
||||
.finally(async () => {
|
||||
loader.value = false
|
||||
await props.fetchStep()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue