fix โหลด ใบแจ้งชำระเงิน

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-01-31 14:41:52 +07:00
parent 424808fab0
commit 014e23bac1
2 changed files with 28 additions and 23 deletions

View file

@ -43,5 +43,7 @@ export default {
candidate, candidate,
candidateBill: (examId: string, positionId: string) => `${candidate}bill/${examId}/${positionId}`, candidateBill: (examId: string, positionId: string) => `${candidate}bill/${examId}/${positionId}`,
candidateReport: (candidateId: string) => `${env.API_URI_V2}/report/candidate/pdf/${candidateId}` candidateReport: (candidateId: string) => `${env.API_URI_V2}/report/candidate/pdf/${candidateId}`,
candidatePaymentExport: (examId: string) => `${candidate}period-exam/payment-export/${examId}`
} }

View file

@ -207,6 +207,7 @@ import { useDataStore } from '@/stores/data'
import http from '@/plugins/http' import http from '@/plugins/http'
import config from '@/app.config' import config from '@/app.config'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import genReport from '@/plugins/genreport'
const props = defineProps({ const props = defineProps({
fetchStep: { fetchStep: {
@ -232,6 +233,7 @@ const positionId = ref<string>(route.params.positionId.toString())
const bank = ref<any>([]) const bank = ref<any>([])
const fee = ref<number>() const fee = ref<number>()
const filePayment = ref<File[]>([]) const filePayment = ref<File[]>([])
const candidateId = ref<string>('')
onMounted(async () => { onMounted(async () => {
await fetchPaymentExam() await fetchPaymentExam()
@ -263,6 +265,7 @@ const fetchData = async () => {
const data = res.data.result const data = res.data.result
img.value = data.paymentImg img.value = data.paymentImg
rejectMessage.value = data.rejectDetail rejectMessage.value = data.rejectDetail
candidateId.value = data.candidateId
}) })
.catch((e) => { .catch((e) => {
messageError($q, e) messageError($q, e)
@ -273,25 +276,25 @@ const fetchData = async () => {
} }
const clickPayment = async () => { const clickPayment = async () => {
// if (img.value != null || img.value != '') { // if (img.value != null || img.value != '') {
// const formData = new FormData() // const formData = new FormData()
// formData.append('', filePayment.value[0]) // formData.append('', filePayment.value[0])
loaderPage(true) loaderPage(true)
await http await http
.post(config.API.candidatePayment(examId.value, positionId.value)) .post(config.API.candidatePayment(examId.value, positionId.value))
.then(() => { .then(() => {
success($q, 'ส่งหลักฐานชำระเงินสำเร็จ') success($q, 'ส่งหลักฐานชำระเงินสำเร็จ')
}) })
.catch((e) => { .catch((e) => {
messageError($q, e) messageError($q, e)
}) })
.finally(async () => { .finally(async () => {
filePayment.value = [] filePayment.value = []
await props.fetchStep() await props.fetchStep()
}) })
// } else { // } else {
// modalError($q, '', '') // modalError($q, '', '')
// } // }
} }
const uploadImage = async (file: any) => { const uploadImage = async (file: any) => {
@ -321,10 +324,10 @@ const uploadImage = async (file: any) => {
const downloadBillPayment = async () => { const downloadBillPayment = async () => {
loaderPage(true) loaderPage(true)
await http await http
.get(config.API.candidateBill(examId.value, positionId.value)) .get(config.API.candidatePaymentExport(candidateId.value))
.then((res) => { .then(async (res) => {
const data = res.data.result const data = res.data.result
window.open(data) await genReport(data, `พิมพ์ใบแจ้งการชำระเงิน`, 'pdf')
}) })
.catch((e) => { .catch((e) => {
messageError($q, e) messageError($q, e)