us-tax-form-upload-comp.js
1.43 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
/**
* 组件描述:上传美国税务表格
*/
import api from "@/api/api";
import {
formdata
} from '@/api/fetch-api.js'
import { Loading } from 'vant';
export default {
props: {
// 是否显示组件
// 1、顯示事故類型;2、顯示時間
// 是否显示组件
visible: {
type: Boolean,
default: false
}
},
data() {
return {
fileName: "",
iobsKey: "",
loading: false
};
},
components: {},
computed: {
locale() {
return this.$i18n.locale || "tc";
}
},
methods: {
initData() {},
onOverLayHandler() {
console.log("onOverLayHandler");
this.$emit("close");
},
toDownLoadTaxForm() {
window.open("https://www.irs.gov/");
},
onUploadHandler() {},
onSubmitHandler() {
if(!this.iobsKey) return;
this.$emit("submit", {
iobsKey: this.iobsKey
});
},
selectImgs() {
let _this = this;
this.iobsKey = "";
let file = this.$refs.file.files[0];
let item = {
name: file.name,
size: file.size,
file: file
};
// 转base64
this.loading = true;
let myFormData = new FormData();
myFormData.append("file", file);
formdata({ url: api.uploadFileIobs, myFormData: myFormData, sid: true })
.then(res => {
this.loading = false;
this.iobsKey = res;
this.$emit("uploadsuccess");
})
.catch(err => {
this.loading = false;
this.$emit("uploaderr");
});
}
},
mounted() {},
created() {
this.initData();
},
watch: {}
};