mirror of
https://gitee.com/gz-yami/mall4j.git
synced 2026-03-22 09:17:16 +08:00
修复【商品批量删除失败】的bug
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品状态
|
||||
|
||||
Reference in New Issue
Block a user