修复【商品批量删除失败】的bug

This commit is contained in:
sjl
2021-02-03 09:53:44 +08:00
parent 0c938e5ef0
commit 508eb1ebf5
2 changed files with 25 additions and 6 deletions

View File

@@ -107,8 +107,12 @@ export default {
query: { prodId: id }
})
},
// 删除
// 删除和批量删除
deleteHandle (id) {
let prodIds = this.getSeleProdIds()
if (id) {
prodIds.push(id)
}
this.$confirm(`确定进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -116,9 +120,9 @@ export default {
})
.then(() => {
this.$http({
url: this.$http.adornUrl(`/prod/prod/${id}`),
url: this.$http.adornUrl(`/prod/prod`),
method: 'delete',
data: this.$http.adornData({})
data: this.$http.adornData(prodIds, false)
}).then(({ data }) => {
this.$message({
message: '操作成功',
@@ -139,6 +143,12 @@ export default {
// 多选变化
selectionChange (val) {
this.dataListSelections = val
},
// 获取选中的商品Id列表
getSeleProdIds () {
return this.dataListSelections.map(item => {
return item.prodId
})
}
}
}

View File

@@ -157,9 +157,7 @@ public class ProductController {
/**
* 删除
*/
@DeleteMapping("/{prodId}")
@PreAuthorize("@pms.hasPermission('prod:prod:delete')")
public ResponseEntity<Void> delete(@PathVariable("prodId") Long prodId) {
public ResponseEntity<Void> delete(Long prodId) {
Product dbProduct = productService.getProductByProdId(prodId);
if (!Objects.equals(dbProduct.getShopId(), SecurityUtils.getSysUser().getShopId())) {
throw new YamiShopBindException("无法获取非本店铺商品信息");
@@ -182,6 +180,17 @@ public class ProductController {
return ResponseEntity.ok().build();
}
/**
* 批量删除
*/
@DeleteMapping
@PreAuthorize("@pms.hasPermission('prod:prod:delete')")
public ResponseEntity<Void> batchDelete(@RequestBody Long[] prodIds) {
for (Long prodId : prodIds) {
delete(prodId);
}
return ResponseEntity.ok().build();
}
/**
* 更新商品状态