批量提交
Posted zeevy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了批量提交相关的知识,希望对你有一定的参考价值。
前台代码:
1 <a class="approve" onclick="deleteListProgram()">批量审核</a> 2 <thead> 3 <tr> 4 <th style="width: 20px;"><input type="checkbox" lay-skin="primary" class="checkAllProgram" lay-filter="checkboxProgram" /></th> 5 </tr> 6 </thead> 7 <tbody> 8 <c:forEach items="${list}" var="fcHydrantDetail" varStatus="status"> 9 <tr target="slt_uid" rel="${fcHydrantDetail.id}" > 10 <td><input type="checkbox" lay-skin="primary" lay-filter="checkboxProgram" /></td> 11 </tr> 12 </c:forEach> 13 </tbody> 14 <script type="text/javascript"> 15 //一键全选 16 form.on(‘checkbox(checkboxProgram)‘, function(data) { 17 if ($(data.elem).hasClass("checkAllProgram")) { 18 if (data.elem.checked) { 19 $(data.elem).parents(‘table:first‘).find(‘tbody‘).find(‘input[type="checkbox"]‘).prop("checked", true); 20 } else { 21 $(data.elem).parents(‘table:first‘).find(‘tbody‘).find(‘input[type="checkbox"]‘).prop("checked", false); 22 } 23 form.render(‘checkbox‘); 24 } 25 }); 26 //批量提交,将选中的数据的id用逗号分隔拼接 27 function deleteListProgram() { 28 var ids = ""; 29 $(‘.frog-table‘, NavTab.getCurrentPanel()).find(‘tbody input[type="checkbox"]‘).each(function() { 30 if ($(this).prop("checked")) { 31 var id = $(this).parents(‘tr:first‘).attr("rel"); 32 if (ids == "") { 33 ids = id; 34 } else { 35 ids += "," + id; 36 } 37 } 38 }); 39 if (ids == "") { 40 Dialog.warn("未选中一条以上的数据"); 41 return; 42 } 43 layer.confirm(‘确定批量审核选中的数据?‘, function(index) { 44 var loadingIndex = Dialog.load(); 45 $.post("${ctx}/fcHydrantDetail/approve", {id: ids}, function(msg) { 46 layer.close(index); 47 try { 48 var result = JSON.parse(msg); 49 Ajax.ajaxDone(result); 50 if (result.statusCode == 200) { 51 NavTab.reloadWithPagination(result.navTabId); 52 } 53 } catch (e) { 54 console.log(msg); 55 Dialog.error(e.message); 56 } finally { 57 layer.close(loadingIndex); 58 } 59 }); 60 }); 61 } 62 </script>
后台代码:
@RequestMapping(value = "/approve") public @ResponseBody String approve(String id) { ... }
以上是关于批量提交的主要内容,如果未能解决你的问题,请参考以下文章