css
<form>
<Input type="text" value="" v-model="companyname" placeholder="请输入公司名称"
style="width: 250px"></Input>
<Input type="text" value="" v-model="debtMoney" placeholder="请输入债权本金"
style="width: 150px"></Input>
<Input type="text" value="" v-model="debtTimes" placeholder="请输入债权笔数"
style="width: 150px"></Input>
<a style="margin-left: 10px;margin-right: 10px;"
href="https://lsdkmanager.oss-cn-hangzhou.aliyuncs.com/lsdkzcb/资产包评估数据模板20190830.xls">下载模版</a>
<input type="file" id="inputId" @change="getFile($event)">
<Button type="primary" @click="submitfile($event)">提交</Button>
</form>
js
submitfile(){
console.log('上传数据')
const self = this;
event.preventDefault();//取消默认行为
//创建 formData 对象
let formData = new FormData();
// 向 formData 对象中添加文件
formData.append('file', self.file);
formData.append('lenderCompanyName', self.companyname)
formData.append('debtPrincipal', self.debtMoney)
formData.append('debtNumber', self.debtTimes) self.uploadFileRequest('/authapi/base_AssetPackaging/uploadAssetPackage', formData).then(respond => {
console.log('提交文件返回')
console.log(respond)
if (respond.data.code == '1111') {
self.$Message.success(respond.data.msg);
self.companyname = ''
self.debtMoney = ''
self.debtTimes = ''
self.file = ''
document.getElementById("inputId").value = null;
self.setInitPage(1);
} else {
self.$Message.error(respond.data.msg);
}
}
)
},
getFile(event) {
// console.log('拿到文件');
this.file = event.target.files[0];
},
网友评论