uploadInvoice.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <template>
  2. <Dialog title="上传发票" v-model="dialogVisible">
  3. <UploadFile
  4. v-model="itemData.fileUrl"
  5. :file-type="['pdf']"
  6. :limit="1"
  7. :drag="true"
  8. class="min-w-80px"
  9. />
  10. <template #footer>
  11. <el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
  12. <el-button @click="handleClose">取 消</el-button>
  13. </template>
  14. </Dialog>
  15. </template>
  16. <script setup lang="ts">
  17. defineOptions({ name: 'UploadInvoice'})
  18. import { ref } from 'vue'
  19. import { InvoiceApi } from '@/api/menduner/system/invoice'
  20. const emit = defineEmits(['refresh'])
  21. const message = useMessage() // 消息弹窗
  22. const dialogVisible = ref(false)
  23. const formLoading = ref(false)
  24. const itemData = ref({
  25. id: '',
  26. fileUrl: ''
  27. })
  28. /** 打开弹窗 */
  29. const open = async (id: string) => {
  30. dialogVisible.value = true
  31. itemData.value.id = id
  32. }
  33. const handleClose = () => {
  34. dialogVisible.value = false
  35. itemData.value = {
  36. id: '',
  37. fileUrl: ''
  38. }
  39. }
  40. const submitForm = () => {
  41. if (!itemData.value.fileUrl) return message.warning('请上传发票')
  42. InvoiceApi.uploadInvoice(itemData.value)
  43. message.success('上传成功')
  44. handleClose()
  45. emit('refresh')
  46. }
  47. defineExpose({ open }) // 提供 open 方法,用于打开弹窗
  48. </script>