แสดงไฟล์หลักฐารชำระเงิน

This commit is contained in:
Kittapath 2023-04-09 03:01:04 +07:00
parent fd1b08461a
commit f03c8a8f10
3 changed files with 61 additions and 37 deletions

View file

@ -30,7 +30,7 @@
color="gray"
type="file"
flat
:factory="fileUpload"
:factory="uploadData"
ref="uploader"
class="full-width"
text-color="dark"
@ -119,7 +119,7 @@
round
color="blue"
icon="mdi-download-outline"
@click="downloadData(file.id)"
@click="downloadData(file.detail)"
>
<q-tooltip>ดาวนโหลด</q-tooltip>
</q-btn>
@ -147,7 +147,7 @@ import HeaderTop from '@/components/top.vue'
import http from '@/plugins/http'
import config from '@/app.config'
import { useRoute } from 'vue-router'
import type { uploadType } from '@/modules/01_exam/interface/index/Main'
import type { UploadType } from '@/modules/01_exam/interface/index/Main'
const props = defineProps({
status: {
@ -163,7 +163,7 @@ const loader = ref<boolean>(false)
const edit = ref<boolean>(props.status == 'register' || props.status == 'rejectRegister')
const name = ref<string>('')
const fileDataUpload = ref<File>()
const files = ref<uploadType[]>([
const files = ref<UploadType[]>([
// {
// key: 1,
// name: '',
@ -187,13 +187,13 @@ 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 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
@ -228,10 +228,10 @@ const deleteData = async (id: string) => {
})
}
const uploadData = async () => {
const uploadData = async (file: any) => {
loader.value = true
const formData = new FormData()
formData.append('FileData', fileDataUpload.value)
formData.append('', file[0])
await http
.put(config.API.candidateUpload(examId.value, positionId.value), formData)
.then((res) => {
@ -248,16 +248,7 @@ const uploadData = async () => {
})
}
const downloadData = async (id: string) => {
loader.value = true
await http
.get(config.API.candidateDownload(id))
.then((res) => {
const data = res
})
.catch(() => {})
.finally(() => {
loader.value = false
})
const downloadData = async (path: string) => {
window.open(path)
}
</script>