InvoiceUpload.vue 1.63 KB
<template>
  <BasicModal
    v-bind="$attrs"
    @register="register"
    title="发票上传"
    width="500px"
    :bodyStyle="{ height: '200px' }"
    @ok="handleOk"
    ><a-upload-dragger
      v-model:fileList="fileList"
      name="file"
      :multiple="true"
      action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
      @change="handleChange"
      @drop="handleDrop"
    >
      <p class="ant-upload-drag-icon">
        <inbox-outlined></inbox-outlined>
      </p>
      <p class="ant-upload-text">点击或将文件拖拽到这里上传</p>
    </a-upload-dragger>
  </BasicModal>
</template>
<script lang="ts" setup>
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { computed, ref } from 'vue';
  import type { UploadProps, UploadChangeParam } from 'ant-design-vue';
  import { InboxOutlined } from '@ant-design/icons-vue';
  import { message } from 'ant-design-vue';

  const handleChange = (info: UploadChangeParam) => {
    const status = info.file.status;
    if (status !== 'uploading') {
      console.log(info.file, info.fileList);
    }
    if (status === 'done') {
      message.success(`${info.file.name} file uploaded successfully.`);
    } else if (status === 'error') {
      message.error(`${info.file.name} file upload failed.`);
    }
  };
  function handleDrop(e: DragEvent) {
    console.log(e);
  }
  const fileList = ref<UploadProps['fileList']>([]);

  const Input1 = ref('');
  const Input2 = ref('123');

  const [register, { closeModal }] = useModalInner(async (data) => {
    title.value = data.title;
  });
  const title = ref('');
  async function handleOk() {
    closeModal();
  }
</script>