updateFile.vue
1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<template>
<el-dialog v-model="showDialog" destroy-on-close title="上传发票" width="600">
<el-form-item label="上传发票">
<file-upload v-model="form.url" :file-type="fileType" limit="1" />
</el-form-item>
<div style="text-align: center;">
<el-button style="width: 160px" type="" @click="showDialog=false">取消</el-button>
<el-button style="width: 160px" type="primary" @click="handelSubmit">确定</el-button>
</div>
</el-dialog>
</template>
<script setup>
import { getCurrentInstance, ref } from 'vue'
import { uploadFile } from '@/api/exam/payment'
const emit = defineEmits(['updateFile'])
const form = ref({})
const showDialog = ref(false)
const fileType = ref(['jpg', 'jpeg', 'png'])
const { proxy } = getCurrentInstance()
function open(row) {
showDialog.value = true
form.value = {
id: row.id,
url: row.fileUrl ? JSON.parse(row.fileUrl) : ''
}
}
async function handelSubmit() {
if (!form.value.url) {
proxy.$modal.msgError('请上传发票')
return
}
await uploadFile({
id: form.value.id,
url: JSON.stringify(form.value.url)
})
emit('updateFile')
proxy.$modal.msgSuccess('操作成功')
showDialog.value = false
}
defineExpose({
open
})
</script>
<style lang="scss" scoped>
</style>