InvoiceCreate.vue
2.67 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<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';
import { useMessage } from '/@/hooks/web/useMessage';
const fileList = ref<UploadProps['fileList']>([]);
const { createMessage } = useMessage();
const { error } = createMessage;
const Input1 = ref('');
const Input2 = ref();
const uploadUrl = ref('http://47.104.8.35:80/api/localStorage/upload_file_oss?name=');
const bgUrl = ref();
const orderIds = ref();
const emit = defineEmits(['success']);
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('');
const isDisabled = ref(false);
async function handleOk() {
if (isDisabled.value) {
error('请勿连续点击生成按钮,需要等待三秒再点击生成');
return;
}
isDisabled.value = true;
setTimeout(() => {
isDisabled.value = false;
}, 3000);
await createInvoice({
invoiceNo: Input1.value,
bgUrl: bgUrl.value,
backRefundDate: Input2.value,
orderIds: orderIds.value,
});
emit('success');
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>