前提是必须要post请求,get经测试不行
后端入参直接用@requestBody去接
@PostMapping
@ApiOperationSupport(order = 4)
@ApiOperation(value = "新增", notes = "传入exhibitionAreaRelicsRelation")
@PreAuth("hasPermission('exhibitionAreaRelicsRelation:create')")
public R save(@Valid @RequestBody List<ExhibitionAreaRelicsRelationVO> list) {
for (int i = 0; i < list.size(); i++) {
exhibitionAreaRelicsRelationService.save(list.get(i));
}
return R.success("添加成功");
}
前端,直接将数组丢进去即可 addSub(list)
rowSaveSub(row, loading, done) {
var list = []
for (let index = 0; index < this.selectionChangeaddList.length; index++) {
row = {
...row,
exhibitionAreaId: this.exhibitionAreaId,
relicsId: this.selectionChangeaddList[index].relicsId
}
list.push(row)
}
addSub(list).then(
() => {
loading()
this.onLoadSub(this.pageSub)
this.$message({
type: 'success',
message: '操作成功!'
})
},
error => {
done()
window.console.log(error)
}
)
},
export const add = row => {
return request({
url: '/api/area/relics/relation',
method: 'post',
data: row
})
}
因篇幅问题不能全部显示,请点此查看更多更全内容