欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > vue post删除 兼容批量删除和单个删除

vue post删除 兼容批量删除和单个删除

2025/9/23 9:39:15 来源:https://blog.csdn.net/tanzongbiao/article/details/145307438  浏览:    关键词:vue post删除 兼容批量删除和单个删除

核心 

const idsTemp = row.personId ? [row.personId] : this.ids

完整代码

    // 删除handleDelete(row) {const idsTemp = row.personId ? [row.personId] : this.idsthis.$confirm('删除后无法恢复, 确定吗?', '提示', {confirmButtonText: '确定',cancelButtonText: '取消',type: 'warning'}).then(() => {this.loading = trueapi.deleteByIds(idsTemp).then(res => {this.loading = falseif (res.code !== 200) {this.$message.error(res.msg)return}this.$message.success(res.msg)this.getByPage()})}).catch(() => {this.msgError('删除已取消')this.loading = false})},
  // 删除deleteByIds(ids) {return request({url: `/${groupName}/deleteByIds`,method: 'post',data: { ids }})},
    /*** 删除** @param dto* @return*/@PostMapping("deleteByIds")@PreAuthorize("hasAuthority('sys:delete')")@ApiOperation("删除员工")@Log(title = "删除员工", businessType = BusinessType.DELETE)public Result<?> deleteByIds(@RequestBody IdsDto dto) {return service.deleteByIds(dto.getIds());}
    /*** 删除** @param ids* @return*/Result<?> deleteByIds(List<Long> ids);
    /*** 删除** @param ids* @return*/@Overridepublic Result<?> deleteByIds(List<Long> ids) {if (CollectionUtils.isEmpty(ids)) {return Result.fail("传入ids为空");}// 验证并删除String currentName = CurrentUserUtil.getCurrentUserInfo().getName() + "-删";int rows = 0;Person person;for(Long id: ids){// 查询数据person = mapper.selectById(id);if (ObjectUtils.isEmpty(person)) {return Result.fail("未查询到有效的数据信息");}// 记录删除人person.setUpdateBy(currentName);person.setUpdateTime(new Date());mapper.updateById(person);// 删除rows += mapper.deleteById(id);}return Result.toAjax(rows);}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com