1.解决方法:要处理一下请求参数,按下面的写法处理参数就行。
// 监听switch开关状态的改变
stateChange(warehouserInfo) {
var params = new URLSearchParams();
params.append('id', warehouserInfo.id);
params.append('whStatus', warehouserInfo.whStatus)
this.$http
.post('/warehouse/updateStatus', params)
.then((res) => {
if (res.data.code == 200) {
this.$message.success('更新数据状态成功');
} else {
warehouserInfo.whStatus = !warehouserInfo.whStatus;
this.$message.error('更新数据状态失败!');
}
})
.catch(function (error) {
console.log(error);
});
},
2.后端
@PostMapping("/updateStatus")
public CommonResult updateStatus(Integer id, Integer whStatus){
Boolean result = warehouseService.updateStatus(id,whStatus);
if (result){
return CommonResult.success(result);
}else {
return CommonResult.failed();
}
}