柏杨
authored
|
1
2
3
4
5
6
7
8
|
<template>
<BasicModal
v-bind="$attrs"
@register="register"
title="Invoice创建"
width="500px"
:bodyStyle="{ height: '300px' }"
@ok="handleOk"
|
|
9
|
@visible-change="handleShow"
|
柏杨
authored
|
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
|
>
<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';
|
柏杨
authored
|
36
|
import { getRefundDate, getInvoice, createInvoice } from '@/api/project/invoice';
|
|
37
|
import { useMessage } from '/@/hooks/web/useMessage';
|
柏杨
authored
|
38
39
|
const fileList = ref<UploadProps['fileList']>([]);
|
|
40
41
|
const { createMessage } = useMessage();
const { error } = createMessage;
|
柏杨
authored
|
42
43
|
const Input1 = ref('');
const Input2 = ref();
|
|
44
|
const uploadUrl = ref('http://47.104.8.35:80/api/localStorage/upload_file_oss?name=');
|
柏杨
authored
|
45
46
|
const bgUrl = ref();
const orderIds = ref();
|
|
47
|
const emit = defineEmits(['success']);
|
柏杨
authored
|
48
49
|
const [register, { closeModal }] = useModalInner(async (data) => {
|
柏杨
authored
|
50
51
52
|
const ids = data.data;
const res = await getRefundDate({ orderIds: ids });
Input2.value = res;
|
柏杨
authored
|
53
54
55
|
orderIds.value = data.data;
});
// const title = ref('');
|
|
56
|
const isDisabled = ref(false);
|
柏杨
authored
|
57
|
async function handleOk() {
|
|
58
59
60
61
62
63
64
65
|
if (isDisabled.value) {
error('请勿连续点击生成按钮,需要等待三秒再点击生成');
return;
}
isDisabled.value = true;
setTimeout(() => {
isDisabled.value = false;
}, 3000);
|
柏杨
authored
|
66
|
await createInvoice({
|
柏杨
authored
|
67
68
69
70
71
|
invoiceNo: Input1.value,
bgUrl: bgUrl.value,
backRefundDate: Input2.value,
orderIds: orderIds.value,
});
|
|
72
|
emit('success');
|
柏杨
authored
|
73
74
75
76
|
closeModal();
}
function handleChange(info) {
if (info.file.status == 'done') {
|
柏杨
authored
|
77
|
bgUrl.value = info.file.response.data.fileUrl;
|
柏杨
authored
|
78
79
80
81
82
|
}
}
function beforeUpload(info) {
uploadUrl.value += info.name;
}
|
|
83
84
85
86
87
88
|
function handleShow(visible: boolean) {
if (!visible) {
Input1.value = '';
fileList.value = [];
}
}
|
柏杨
authored
|
89
|
</script>
|