全选和复选 批量操作 弹框

全选和复选  批量操作 弹框

 

优美弹框提示,比alert好看多了

<link href="static/sweetalert/sweetalert.css" rel="stylesheet" />
    <script src='static/sweetalert/sweetalert.min.js'></script>

$(function(){
        var msg = "${pd.msg}";
        sweetAlert("当前操作:"+msg);
    });

http://layer.layui.com/

http://www.layui.com/doc/modules/layer.html#btnAlign

 

需要引入layer弹框插件

<script type="text/javascript" src="static/js/layer.js"></script>
<link rel="stylesheet" href="static/css/layui.css" media="all">
<script src='static/js/jquery-1.9.1.min.js'></script>
//全选框
<thead>
                <tr>
                    <th width="2%" align="center"><input id="quanxuan" type="checkbox" name="checkAll"
                                                         style="position:relative;opacity:100;"></th>
                    <th width="7%">编号</th>
                    <th width="7%">人姓名</th>
                </tr>
</thead>
//单选框
<c:when test="${not empty pageList}">
                        <c:forEach items="${pageList}" var="var" varStatus="vs">
                            <tr>
                                <td align="center"><input id="${var.id}"
                                                          value="${var.id}" name="subBox" type="checkbox"
                                                          style="position:relative;opacity:100;">
                                </td>
                                <td><a href="javascript:void(-1);" style="color: blue"
                                       onclick="toDetail('${var.call_loan_nid}','${var.user_id}','${var.repayment_id}')">${var.call_loan_nid}</a>
                                </td>
                                <td>${var.cont_id_card}</td><!-- 借款人身份证号-->
                                <td>${var.telephone}</td><!-- 手机号-->
                                <td>//鼠标悬停展示全部备注
                                        <a title='${var.remark}' style="cursor: pointer;">
                                                <c:if test="${fn:length(var.remark) >= 8 }">
                                                ${fn:substring(var.remark,0,8)}...
                                            </c:if>
                                            <c:if test="${fn:length(var.remark) < 8 }">
                                                ${var.remark}
                                            </c:if>
                                        </a>
                                </td>
                            </tr>
                        </c:forEach>
                    </c:when>
// 全选/复选   可以实现全选和反选,
$(function(){
    $("#quanxuan").click(function(){
        $('input[name="subBox"]').prop("checked", this.checked);
    });
     var $subBox = $("input[name='subBox']");
     $subBox
         .click(function () {
             $("#checkAll")
                 .prop(
                     "checked",
                     $subBox.length == $("input[name='subBox']:checked").length ? true
                         : false);
         });
});

//批量操作。并且将数组数据传到后台
function layerOpen(){
//实现将数组数据遍历传递到后台
     var arrChk = $("input[name='subBox']:checked");
     var fenpais = new Array();
     (arrChk).each(function () { //each() 遍历函数
         fenpais.push(this.id)
     });
     console.log(fenpais);
    layer.confirm(
            '请选择以下审核结果:',
            {
                title:"审核",
                btn: ['审核通过', '审核拒绝', '取消'], //可以无限个按钮
                btnAlign: 'c'
                  ,btn3: function(index, layero){
                    layer.closeAll();
                  }
            },
            function(index, layero){
              window.location="blackName/checkStatusList.do?status="+'1'+"&ids="+fenpais;
              
            },
            function(index){
               window.location="blackName/checkStatusList.do?status="+'2'+"&ids="+fenpais;
            });
}

//后台controller层接受页面批量遍历的数组数据
@RequestMapping(value="/checkStatusList")
    public void checkStatusList(Page page, HttpServletRequest request,@RequestParam("ids")String[] ids){
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("ids", ids);
        blackListServiceImpl.updateStatusList(map);
    }
    
    
 //分派
        $("#fenpai").click(function () {
            var arrChk = $("input[name='subBox']:checked");
            var fenpais = new Array();
            (arrChk).each(function () { //each() 遍历函数
                fenpais.push(this.id)
            });
            if (arrChk.length != 0) {
                openDialog({
                    title: "批量操作",
                    url: "taskdetails/plliangfenpailist?fpId=" + fenpais,
                    callBack: function () {
                        window.location.reload();
                    }
                });
            } else if (fenpais.length == 0) {
                layer.msg('勾选任务', {
                    icon: 5,
                    time: 2000
                })
            }
        });
 /* 打开窗口 */弹框
    function openDialog(options) {
        var defaultOptions = {
            title: "",
            url: "",
            callBack: function () {
            }
        };
        options = $.extend(defaultOptions, options);
        layer.open({
            title: options.title,
            fixed: false,
            type: 2,
            content: options.url,
            area: ['800px', '600px'],
            end: options.callBack
        });
    }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值