解决方案:放弃使用this.$refs.upload.submit(); 获取选择文件,使用FormData上传
<el-upload
ref="upload"
name="attachment"
:limit="1"
action=""
:auto-upload="false"
:on-exceed="onExceed"
:on-change="onChange"
:on-remove="onRemove">
<el-link :underline="false" type="primary">选择文件</el-link>
</el-upload>
onExceed(files, fileList) {
this.$message.error('只能上传一个文件')
},
onChange(file, fileList) {
this.launchDialogForm.attachment = file.raw
},
onRemove(file, fileList) {
this.launchDialogForm.attachment =null
}
var formData =new FormData()
formData.append('tradeNumber',this.launchDialogForm.tradeNumber)
formData.append('attachment',this.launchDialogForm.attachment)
createWorksheet(formData).then(response => {
console.log(response)
})
export function createWorksheet(params) {
return request({
url:'/wo/create',
method:'post',
data: params
})
}
后台:
@PostMapping("/create")
public ResponseResult createWorksheet(
@RequestParam(value ="attachment",required =false) MultipartFile attachment,
WorksheetParam param
) {
return ResponseResult.success();
}
网友评论