赞
踩
- <!-- 添加 批量删除工具栏 -->
- <script type="text/html" id="addbar"> // addbar 绑定在table.render渲染表格元素时 使用 toolbar:"#addbar" 进行绑定
- <div class="layui-btn-container">
- <a class="layui-btn layui-icon layui-icon-add-1" lay-event="add"></a>
- <a class="layui-btn layui-icon layui-icon-subtraction" lay-event="dels"></a>
- </div>
- </script>
// 添加 批量删除工具栏 table.on('toolbar(commFilter)',function (obj){ // commFilter 代表的是定义的表格的lay-filter属性 var ename = obj.event; if(ename === 'add'){ $("#addOrEditForm")[0].reset(); layui.$('#uploadView').removeClass('layui-hide').find('img').attr('src', "images/7e303b15f-b709-4401-a84f-9cf709098fba.png"); var imageUrl = document.getElementById("imgname").src; document.getElementById("imgname_input").value = imageUrl; layui.form.render(); layer.open({ type:1, title:['添加用户','padding-left:5px'], content:layui.$("#cm"), area:['590px','450px'], offset:'10px', maxmin:true, // 最大化最小化 fixed:false, // 是否固定 resize:true, // 允许拉伸 anim:4, shade:false }) }else{ var checkStatus = table.checkStatus('comm'); // 此处绑定表格的id console.log(checkStatus); var data1 = checkStatus.data; var ids = "" if(data1.length > 0){ for(var i in data1){ ids += data1[i].id + ','; } layer.confirm('确定删除用户吗?',{icon:3,title:"提示信息"},function (index){ $.ajax({ type:"post", url:"comm/deleAll", data:{ids:ids}, success:function (res) { layer.closeAll(); table.reload("comm"); } }) }) }else{ layer.msg("请选择需要删除的用户") } } })
- @RequestMapping("/deleAll")
- public Result deleteAll( String ids){
- String[] ids1 = ids.split(",");
- ArrayList<Integer> list = new ArrayList<>();
- for (String id : ids1) {
- int id1 = Integer.parseInt(id);
- list.add(id1);
- }
- System.out.println(list);
- Result deleteIds = commManagerService.deleteAll(list);
- return deleteIds;
- }
- @Override 实现类
- public Result deleteAll(ArrayList<Integer> list) {
- int i = commManagerMapper.deleteAll(list);
- return new Result(0,"删除成功",i);
- }
- <delete id="deleteAll" parameterType="java.util.List">
- delete from comm_manager where id in
- <foreach collection="list" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </delete>
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。