赞
踩
首先前端页面
前端代码:
function doDel(obj) { layer.confirm('确定要删除选中数据吗?', { skin: 'layui-layer-admin', shade: .1 }, function (i) { layer.close(i); var loadIndex = layer.load(2); console.log(obj.ids) $.post('/zcmdmooc/mdmoocRemindAdmin/hrManageDelete', { id: obj ? obj.id : '', ids: obj.ids ? obj.ids.join(',') : '' }, function (res) { layer.close(loadIndex); if (res.code === 0) { layer.msg(res.msg, {icon: 1}); insTb.reload({page: {curr: 1}}); } else { layer.msg(res.msg, {icon: 2}); } }, 'json'); }); }
后端根据删除的id是否批量做判断
/** * 删除项目列表 */ @PostMapping("/hrManageDelete") @ResponseBody public BaseResultData hrManageDelete(HttpServletRequest request,HrManage hrManage){ try { if (StringUtil.isNotEmpty( request.getParameter( "ids" ) )){ //获取前端的ids字符串 String srcstring = request.getParameter( "ids" ) ; //存入string数组 String stringarray[] = srcstring.split(","); //将string[]数组中的每一个元素存入list数组 List<String> list = new ArrayList<>( ); for (String s : stringarray) { list.add( s ); } for (int i = 0; i < list.size(); i++) { hrManage.setId( Integer.valueOf( list.get( i ) )); EntityWrapper wrapper = new EntityWrapper( ); wrapper.where( "id={0}",hrManage.getId() ); HrManage manage = hrManageService.selectOne( wrapper ); manage.setCreateDate( new Date( ) ); manage.setDeleteFlag( 1 ); hrManageService.updateById( manage ); } }else { hrManage.setCreateDate( new Date( ) ); hrManage.setDeleteFlag( 1 ); hrManageService.updateById( hrManage ); } return BaseResultData.SUCCESS(hrManage); }catch (Exception ex) { ex.printStackTrace(); return BaseResultData.ERROR(500,""); } }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。