From c3688918bf57e49cfbbf048e322abd15e3f939c0 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Sun, 9 Apr 2023 04:21:22 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=95=E0=B9=88=E0=B8=AD=20api=20=E0=B8=9B?= =?UTF-8?q?=E0=B8=8F=E0=B8=B4=E0=B9=80=E0=B8=AA=E0=B8=98=E0=B8=88=E0=B9=88?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/exam/api.candidate.ts | 2 + src/modules/01_exam/components/ExamForm.vue | 4 +- .../01_exam/components/ExamPayment.vue | 67 ++++----------- .../01_exam/components/Form/Document.vue | 32 ++------ .../01_exam/components/Form/Information.vue | 82 +++++++++++++++++-- src/modules/01_exam/views/ExamDetail.vue | 36 +++++--- 6 files changed, 126 insertions(+), 97 deletions(-) diff --git a/src/api/exam/api.candidate.ts b/src/api/exam/api.candidate.ts index c7a562f..b3b8f8c 100644 --- a/src/api/exam/api.candidate.ts +++ b/src/api/exam/api.candidate.ts @@ -21,6 +21,8 @@ export default { `${candidate}register/${examId}/${positionId}`, candidatePayment: (examId: string, positionId: string) => `${candidate}payment-image/${examId}/${positionId}`, + candidateProfile: (examId: string, positionId: string) => + `${candidate}profile-image/${examId}/${positionId}`, candidateStatus: (examId: string, positionId: string) => `${candidate}status/${examId}/${positionId}`, candidateUpload: (examId: string, positionId: string) => diff --git a/src/modules/01_exam/components/ExamForm.vue b/src/modules/01_exam/components/ExamForm.vue index 420ec4b..f92277f 100644 --- a/src/modules/01_exam/components/ExamForm.vue +++ b/src/modules/01_exam/components/ExamForm.vue @@ -109,7 +109,9 @@ const fetchStatus = async () => { .then((res) => { acceptTermOfUse.value = true }) - .catch(() => {}) + .catch(() => { + acceptTermOfUse.value = false + }) .finally(() => { loader.value = false }) diff --git a/src/modules/01_exam/components/ExamPayment.vue b/src/modules/01_exam/components/ExamPayment.vue index 87bad8d..98bba22 100644 --- a/src/modules/01_exam/components/ExamPayment.vue +++ b/src/modules/01_exam/components/ExamPayment.vue @@ -4,7 +4,7 @@
เลือกวีธีการชำระเงิน
- + @@ -12,19 +12,13 @@ ชำระเงินค่าสมัครสอบผ่านสำนัก/หน่วยงาน - - - + +
+
  • {{ rejectMessage }}
  • +
    +
    @@ -50,19 +44,6 @@
    - -
    ยอดสุทธิ (บาท) : {{ fee }} @@ -75,8 +56,7 @@
    -
    - - + @@ -136,19 +106,13 @@ ชำระเงินค่าสมัครสอบผ่านธนาคารกรุงไทย - - - + +
    +
  • {{ rejectMessage }}
  • +
    +
    @@ -284,7 +248,7 @@ const props = defineProps({ const $q = useQuasar() const mixin = useCounterMixin() //เรียกฟังก์ชันกลาง const { success, modalError } = mixin -const rejectMessage = ref('กรุณาจ่ายเงินให้ครบตามจำนวน') +const rejectMessage = ref('') const img = ref('') const fileData = ref() const loader = ref(false) @@ -330,7 +294,8 @@ const fetchData = async () => { .get(config.API.candidatePayment(examId.value, positionId.value)) .then((res) => { const data = res.data.result - img.value = data + img.value = data.paymentImg + rejectMessage.value = data.rejectDetail }) .catch(() => {}) .finally(async () => { diff --git a/src/modules/01_exam/components/Form/Document.vue b/src/modules/01_exam/components/Form/Document.vue index 54c36aa..b76ffc2 100644 --- a/src/modules/01_exam/components/Form/Document.vue +++ b/src/modules/01_exam/components/Form/Document.vue @@ -100,7 +100,7 @@
    - + @@ -162,21 +162,7 @@ const uploader = ref() const loader = ref(false) const edit = ref(props.status == 'register' || props.status == 'rejectRegister') const name = ref('') -const fileDataUpload = ref() -const files = ref([ - // { - // key: 1, - // name: 'เอกสารข้อมูลการเปลี่ยนชื่อ', - // status: 'อัปโหลดเสร็จสิ้น', - // sizeLabel: '176MB' - // }, - // { - // key: 2, - // name: 'เอกสารข้อมูลการสมรส', - // status: 'อัปโหลดเสร็จสิ้น', - // sizeLabel: '89MB' - // } -]) +const files = ref([]) const emit = defineEmits(['update:loader']) onMounted(async () => { @@ -187,14 +173,6 @@ const fileAdd = async (file: any) => { name.value = file[0].name } -// const fileUpload = async (file: any) => { -// // fileDataUpload.value = file[0] -// const blob = file.slice(0, file.size, file[0].type) -// const newFile = new File([blob], name.value, { type: file[0].type }) -// fileDataUpload.value = newFile -// await uploadData() -// } - const getData = async () => { loader.value = true await http @@ -230,8 +208,12 @@ const deleteData = async (id: string) => { const uploadData = async (file: any) => { loader.value = true + const blob = file.slice(0, file[0].size) + const newFile = new File(blob, name.value, { + type: file[0].type + }) const formData = new FormData() - formData.append('', file[0]) + formData.append('', newFile) await http .put(config.API.candidateUpload(examId.value, positionId.value), formData) .then((res) => { diff --git a/src/modules/01_exam/components/Form/Information.vue b/src/modules/01_exam/components/Form/Information.vue index d84a381..0f05c63 100644 --- a/src/modules/01_exam/components/Form/Information.vue +++ b/src/modules/01_exam/components/Form/Information.vue @@ -311,17 +311,38 @@
    - +
    -
    - + + + +
    + บันทึกรูป
    @@ -352,6 +373,7 @@ import { defaultInformation, changeData } from '@/modules/01_exam/interface/inde import HeaderTop from '@/components/top.vue' import { useRoute } from 'vue-router' import keycloak from '@/plugins/keycloak' +import { useQuasar } from 'quasar' const props = defineProps({ prefixOptions: { @@ -376,8 +398,9 @@ const props = defineProps({ } }) +const $q = useQuasar() const mixin = useCounterMixin() -const { date2Thai, calAge } = mixin +const { date2Thai, calAge, modalError, success } = mixin const districtOptions = ref([]) const route = useRoute() const examId = ref(route.params.id.toString()) @@ -387,6 +410,9 @@ const myform = ref({}) const disabledPic = ref(false) const fileData = ref() const loader = ref(false) +const img = ref('') +const fileProfile = ref([]) +const fileDataUpload = ref() const emit = defineEmits(['update:form']) @@ -400,6 +426,7 @@ watch(defaultInformation, async (count: Information, prevCount: Information) => onMounted(async () => { await fetchData() + await fetchImgData() if (defaultInformation.value.provinceId != null) await fetchDistrict(defaultInformation.value.provinceId) }) @@ -440,6 +467,47 @@ const fetchData = async () => { }) } +const fetchImgData = async () => { + loader.value = true + await http + .get(config.API.candidateProfile(examId.value, positionId.value)) + .then((res) => { + const data = res.data.result + img.value = data + }) + .catch(() => {}) + .finally(async () => { + loader.value = false + }) +} + +const clickProfile = async () => { + if (fileProfile.value.length > 0) { + const blob = fileProfile.value.slice(0, fileProfile.value[0].size) + const newFile = new File(blob, fileProfile.value[0].name, { + type: fileProfile.value[0].type + }) + fileDataUpload.value = newFile + const formData = new FormData() + formData.append('', fileDataUpload.value) + loader.value = true + await http + .put(config.API.candidateProfile(examId.value, positionId.value), formData) + .then(() => { + success($q, 'ส่งหลักฐานชำระเงินสำเร็จ') + }) + .catch(() => {}) + .finally(async () => { + loader.value = false + await fetchData() + await fetchImgData() + fileProfile.value = [] + }) + } else { + modalError($q, 'ไม่สามารถอัพโหลดไฟล์ได้', 'กรุณาเลือกไฟล์ที่ต้องการอัพโหลด') + } +} + const selectProvince = (val: string) => { defaultInformation.value.districtId = '' myform.value.resetValidation() @@ -468,10 +536,6 @@ const savePic = () => { disabledPic.value = false } -const pickFile = () => { - disabledPic.value = true -} - const getClass = (val: boolean) => { return { 'full-width inputgreen cursor-pointer': val, diff --git a/src/modules/01_exam/views/ExamDetail.vue b/src/modules/01_exam/views/ExamDetail.vue index d69dbaf..bae6e8d 100644 --- a/src/modules/01_exam/views/ExamDetail.vue +++ b/src/modules/01_exam/views/ExamDetail.vue @@ -23,6 +23,14 @@ :icon="stepRaw >= 2 ? (stepRaw == 2 ? 'mdi-pencil' : 'mdi-check-bold') : 'mdi-account'" > + +
    +
  • {{ rejectMessage }}
  • +
    +
    @@ -85,6 +93,7 @@ const loader = ref(false) const status = ref('register') const modalConsend = ref(false) const stepPayment = ref(true) +const rejectMessage = ref('') onMounted(async () => { // stepRaw.value = 3 @@ -143,36 +152,41 @@ const fetchStep = async () => { .get(config.API.candidateStatus(examId.value, positionId.value)) .then((res) => { const data = res.data.result - status.value = data - if (data == 'register') { + rejectMessage.value = data.rejectDetail + status.value = data.status + if (status.value == 'register') { stepRaw.value = 2 step.value = 2 - } else if (data == 'checkRegister') { + } else if (status.value == 'checkRegister') { stepRaw.value = 3 step.value = 3 - } else if (data == 'payment') { + } else if (status.value == 'payment') { stepRaw.value = 3 step.value = 3 - } else if (data == 'rejectRegister') { + } else if (status.value == 'rejectRegister') { stepRaw.value = 2 step.value = 2 - } else if (data == 'checkPayment') { + } else if (status.value == 'checkPayment') { stepRaw.value = 4 step.value = 4 - } else if (data == 'rejectPayment') { + } else if (status.value == 'rejectPayment') { stepRaw.value = 3 step.value = 3 - } else if (data == 'checkSeat') { + } else if (status.value == 'checkSeat') { stepRaw.value = 4 step.value = 4 - } else if (data == 'checkPoint') { + } else if (status.value == 'checkPoint') { stepRaw.value = 4 step.value = 4 - } else if (data == 'done') { + } else if (status.value == 'done') { stepRaw.value = 4 step.value = 4 } - if (stepPayment.value == false && data != 'register' && data != 'rejectRegister') { + if ( + stepPayment.value == false && + status.value != 'register' && + status.value != 'rejectRegister' + ) { stepRaw.value = 4 step.value = 4 }