核心
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);}