us-tax-form-upload-comp.js 1.43 KB
/**
 * 组件描述:上传美国税务表格
 */
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.fileName = file.name;
					this.iobsKey = res;
					console.log("res:",res);
				})
				.catch(err => {
					this.loading = false;
				});
		}
	},
	mounted() {},
	created() {
		this.initData();
	},
	watch: {}
};