InvoiceCreate.vue 2.22 KB
<template>
  <BasicModal
    v-bind="$attrs"
    @register="register"
    title="Invoice创建"
    width="500px"
    :bodyStyle="{ height: '300px' }"
    @ok="handleOk"
    @visible-change="handleShow"
  >
    <div>
      <div style="font-size: 15px">Invoice编号</div>
      <a-textarea v-model:value="Input1" placeholder="请输入" auto-size />
      <div style="margin: 16px 0"></div>
      <div>报关单(请上传PDF格式)</div
      ><a-space direction="vertical" style="width: 100%" size="large">
        <a-upload
          v-model:file-list="fileList"
          :beforeUpload="beforeUpload"
          list-type="picture"
          :max-count="1"
          :action="uploadUrl"
          @change="handleChange"
        >
          <a-button> 上传报关单 </a-button>
        </a-upload>
      </a-space>
      <div style="font-size: 15px">最后汇款日期</div>
      <a-textarea v-model:value="Input2" auto-size disabled /></div
  ></BasicModal>
</template>
<script lang="ts" setup>
  import { BasicModal, useModalInner } from '@/components/Modal';
  import { computed, ref } from 'vue';
  import type { UploadProps } from 'ant-design-vue';
  import { getRefundDate, getInvoice, createInvoice } from '@/api/project/invoice';

  const fileList = ref<UploadProps['fileList']>([]);

  const Input1 = ref('');
  const Input2 = ref();
  const uploadUrl = ref('http://47.104.8.35:8081/api/localStorage/upload_file_oss?name=');
  const bgUrl = ref();
  const orderIds = ref();

  const [register, { closeModal }] = useModalInner(async (data) => {
    const ids = data.data;
    const res = await getRefundDate({ orderIds: ids });
    Input2.value = res;
    orderIds.value = data.data;
  });
  // const title = ref('');
  async function handleOk() {
    await createInvoice({
      invoiceNo: Input1.value,
      bgUrl: bgUrl.value,
      backRefundDate: Input2.value,
      orderIds: orderIds.value,
    });
    closeModal();
  }
  function handleChange(info) {
    if (info.file.status == 'done') {
      bgUrl.value = info.file.response.data.fileUrl;
    }
  }
  function beforeUpload(info) {
    uploadUrl.value += info.name;
  }
  function handleShow(visible: boolean) {
    if (!visible) {
      Input1.value = '';
      fileList.value = [];
    }
  }
</script>