ReUploadBgUrl.vue
1.61 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
<template>
<BasicModal
v-bind="$attrs"
@register="register"
title="更新报关单"
width="500px"
:bodyStyle="{ height: '240px' }"
@ok="handleOk"
>
<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>
</BasicModal>
</template>
<script lang="ts" setup>
import { BasicModal, useModalInner } from '@/components/Modal';
import { ref } from 'vue';
import type { UploadProps } from 'ant-design-vue';
import { reUploadBgUrl } from '@/api/project/invoice';
import { useMessage } from '/@/hooks/web/useMessage';
const fileList = ref<UploadProps['fileList']>([]);
const { createMessage } = useMessage();
const { error } = createMessage;
const id = ref();
const uploadUrl = ref('http://47.104.8.35:8081/api/localStorage/upload_file_oss?name=');
const bgUrl = ref();
const [register, { closeModal }] = useModalInner(async (data) => {
id.value = data.data.id;
});
function handleChange(info) {
if (info.file.status == 'done') {
bgUrl.value = info.file.response.data.fileUrl;
}
}
function beforeUpload(info) {
uploadUrl.value += info.name;
}
async function handleOk() {
console.log(bgUrl.value, '5656bgUrl.value', uploadUrl.value);
reUploadBgUrl({ id: id.value, bgUrl: bgUrl.value });
closeModal();
}
</script>