updateFile.vue 1.26 KB
<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>