//请求
export function addcountorderitem(data) { return request({ url: '/countoder/oderitem/add', method: 'post', data: data, headers: { 'Content-Type': 'multipart/form-data' }//有文件上传时 必须加此参数 }) }
//把数据封装成 formdatavar form = document.getElementById("editform"); const formdata = new FormData(form);
const formdata = new FormData(form); formdata.append("countItemId", this.editdata.countItemId);
//把文件对象装入formdata
formdata.append("files", this.updloadimage[index].file);
formdata.append("files", this.updloadimage[index].file);
addcountorderitem(formdata).then((res) => { if (res.code == "200") { showToast("添加成功!"); this.onRefresh(); } });
服务端接口 @PostMapping("/add") public AjaxResult add( WmsCountItem wmsCountItem,@RequestParam(value = "files") MultipartFile[] files) { return toAjax(wmsCountItemService.insertWmsCountItem(wmsCountItem,files)); }