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

master
sjl 5 years ago
parent 0c938e5ef0
commit 508eb1ebf5

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

@ -157,9 +157,7 @@ public class ProductController {
/** /**
* *
*/ */
@DeleteMapping("/{prodId}") public ResponseEntity<Void> delete(Long prodId) {
@PreAuthorize("@pms.hasPermission('prod:prod:delete')")
public ResponseEntity<Void> delete(@PathVariable("prodId") Long prodId) {
Product dbProduct = productService.getProductByProdId(prodId); Product dbProduct = productService.getProductByProdId(prodId);
if (!Objects.equals(dbProduct.getShopId(), SecurityUtils.getSysUser().getShopId())) { if (!Objects.equals(dbProduct.getShopId(), SecurityUtils.getSysUser().getShopId())) {
throw new YamiShopBindException("无法获取非本店铺商品信息"); throw new YamiShopBindException("无法获取非本店铺商品信息");
@ -182,6 +180,17 @@ public class ProductController {
return ResponseEntity.ok().build(); 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();
}
/** /**
* *

Loading…
Cancel
Save