us-tax-form-upload-comp.js
1.64 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
90
91
92
93
/**
* 组件描述:上传美国税务表格
*/
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: "",
file: null,
iobsKey: "",
loading: false,
selected: false
};
},
components: {},
computed: {
locale() {
return this.$i18n.locale || "tc";
}
},
methods: {
initData() {
this.file = null;
this.iobsKey = "";
this.loading = false;
this.selected = false;
},
onOverLayHandler() {
console.log("onOverLayHandler");
this.$emit("close");
},
toDownLoadTaxForm() {
window.open("https://www.irs.gov/");
},
onUploadHandler() {
let file = this.file;
if (!file) return;
if (this.loading) return;
this.loading = true;
let myFormData = new FormData();
myFormData.append("file", file);
formdata({
url: api.uploadFileIobs,
myFormData: myFormData,
sid: true
})
.then(res => {
if (res && res.content) {
this.loading = false;
this.iobsKey = res.content;
this.$emit("uploadsuccess");
this.$emit("submit", this.iobsKey);
} else {
this.loading = false;
this.$emit("uploaderr");
}
})
.catch(err => {
this.loading = false;
this.$emit("uploaderr");
});
},
selectImgs() {
let _this = this;
let file = this.$refs.file.files[0];
this.file = file;
this.selected = true;
},
},
mounted() {},
created() {
this.initData();
},
watch: {}
};