jquery checkbox用于批量审批

html

<div class="table-operate ue-clear">
    <a id="btnExcelExport" class="excel">导出</a>
    <a id="btnCheck" style="width:70px;" class="excel">批量审核</a>
</div>
<div class="table-box">
    <table>
        <thead>
        <tr>
            <th class="num"><input type="checkbox" id="all"/></th>
            <th class="node">公司名称</th>
            <th class="name">公司类型</th>
            <th class="name">营业执照号</th>
            <th class="name" style="width: 165px;">安全许可证号</th>
            <th class="name">组织机构代码</th>
            <th class="name">注册资金(万元)</th>
            <th class="operate">操作</th>
        </tr>
        </thead>
        <tbody id="rowTemplate">
        </tbody>
    </table>
</div>

ajax传值

 $().ready(function () {
        checkboxchange();
    });
 function checkboxchange() {
        $("#all").live("click", function () {
            if ($(this).attr("checked")) {
                $(":checkbox.item").attr("checked", "checked");
            } else {
                $(":checkbox.item").removeAttr("checked");
            }
        });
        $("#btnCheck").live("click", function () {
            if (0 == $(":checkbox.item:checked").length) {
                alert("请先选择!");
                return;
            }
            var ids = "";
            $(":checkbox.item:checked").each(function () {
                ids += "_" + $(this).attr("name");
            });
            ids = ids.substr(1, ids.length);
            var url = "<?php echo "/".$url_module."/".$url_model;?>/batchcheck/" + ids;
            callJbox(url);
        });
    }

    function callJbox(url) {
        $.jBox("iframe:" + url, {
            title: "批量审核",
            width: 800,
            height: 320,
            iframeScrolling: ‘no‘,
            buttons: {‘关闭‘: true}
        });
    }

    function check() {
        $.jBox.close(true);
        getDataList(pageIndex, pageSize);
    }
 function getDataList(index, size) {
        var iDisplayStart = size * index;
        index += 1;
        $.ajax({
            url: "<?php echo "/".$url_module."/".$url_model;?>/page",
            type: "Post",
            data: {
                sEcho: index,
                iDisplayLength: size,
                iDisplayStart: iDisplayStart,
                token: ‘<?php echo isset($token)?$token:"";?>‘,
                name: $("#tName").val()
            },
            success: function (res) {
                var r = $.parseJSON(res);
                if (r != null && r.ret == 0) {
                    $("#rowTemplate tr").remove();//移除所有的数据行
                    var myc = 0;
                    $.each(r.aaData, function (i, t) {
                        myc += 1;
                        var mytr = "<tr>";
                        if (t.companyname == null) {
                            t.companyname = "";
                        }
                        if (t.companytypename == null) {
                            t.companytypename = "";
                        }
                        if (t.businesslicensecode == null) {
                            t.businesslicensecode = "";
                        }
                        if (t.safetylicensecode == null) {
                            t.safetylicensecode = "";
                        }
                        if (t.organizationcode == null) {
                            t.organizationcode = "";
                        }
                        if (t.regcapital == null) {
                            t.regcapital = "";
                        }
                        if (myc % 2 == 0) {
                            mytr = "<tr style=‘background-color: rgb(239, 246, 250);‘>";
                        }
                        mytr += "<td class=‘num‘><input type=‘checkbox‘ class=‘item‘ name=‘" + t.id + "‘/></td>";
                        <?php if("浏览组"==$session["accounttype"]):?>
                        mytr += "<td class=‘node‘>" +
                        "<a href=\"<?php echo "/".$url_module."/".$url_model;?>/view/" + t.id + "\">" + t.companyname + "</a>" +
                        "</td>";
                        <?php else:?>
                        mytr += "<td class=‘node‘>" +
                        "<a href=\"<?php echo "/".$url_module."/".$url_model;?>/check/" + t.id + "\">" + t.companyname + "</a>" +
                        "</td>";
                        <?php endif;?>
                        mytr += "<td class=‘name‘>" + t.companytype + "</td>" +
                        "<td class=‘name‘>" + t.businesslicensecode + "</td>" +
                        "<td class=‘name‘>" + t.safetylicensecode + "</td>" +
                        "<td class=‘name‘>" + t.organizationcode + "</td>" +
                        "<td class=‘name‘>" + t.regcapital + "</td>";
                        <?php if("浏览组"==$session["accounttype"]):?>
                        mytr += "<td class=‘operate‘>" +
                        "<a href=\"<?php echo "/".$url_module."/".$url_model;?>/view/" + t.id + "\">明细</a>" +
                        "</td></tr>";
                        <?php else:?>
                        mytr += "<td class=‘operate‘>" +
                        "<a href=\"<?php echo "/".$url_module."/".$url_model;?>/check/" + t.id + "\">审核</a>" +
                        "</td></tr>";
                        <?php endif;?>
                        $("#rowTemplate").append(mytr);  //将返回的数据追加到表格
                    });
                    $(".pagination").pagination(r.iTotalRecords, {
                        callback: PageCallback,
                        items_per_page: size,
                        display_msg: true,
                        setPageNo: true,
                        current_page: index - 1
                    });
                }
                else {
                    alert(r.msg);

                }
            }
        });
    }

php代码

public function batchcheck($ids=""){
		if ($ids === "") {
			$result[$this->success] = 1;
			$result["msg"] = ‘batchcheck error:no ids!‘;
			echo $this->_ReturnMsg($result);
			exit();
		};
		if ($this->input->server(‘REQUEST_METHOD‘) == ‘GET‘){
			$data[‘ids‘] = $ids;
			$data = $this->_getGlobalData($data);
			$this->load->view($this->url_module.‘/‘.$this->url_model.‘/databatchcheck.php‘,$this->_beforeMethod($data));
		}
		else if ($this->input->server(‘REQUEST_METHOD‘) == ‘POST‘){
			$datainfo = $this->_getRequestModel();
			$ids = $_POST["ids"];
			$ids = str_replace("_",",",$ids);
			$sql = "update companys set verified=‘".$_POST["tcheckstatus"]."‘, tcheckname=‘".$_POST["tcheckname"]."‘,tcheckdate=‘".$_POST["tcheckdate"]."‘,reason=‘".$_POST["reason"]."‘ where id in ($ids)";
			log_message("info","zqq--".$sql);
			$result = $this->mydb->execSql($sql);
			if(1==$result["ret"]){
				echo $this->_ReturnMsg($result);
				return;
			}
			$this->setLogs("批量审核",$datainfo);
			echo $this->_ReturnMsg($result);
		}
		else redirect($this->url_module.‘/‘.$this->url_model);

	}

弹窗代码

<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <link rel="stylesheet" href="/css/base.css"/>
    <link rel="stylesheet" href="/css/info-mgt.css"/>
    <link rel="stylesheet" href="/css/WdatePicker.css"/>
    <link rel="stylesheet" href="/css/info-reg.css"/>
    <link type="text/css" rel="stylesheet" href="/js/jBox/Skins/blue/jbox.css"/>
    <style type="text/css">
        a {
            text-decoration: none;
            cursor: pointer;
            color: #2c7bbc;
        }
    </style>
    <title>WMS</title>

</head>
<body>
<div class="title">
    <h2>批量审核</h2>
</div>
<form class="formAjax">
    <div class="main">
        <table style="border:none;">
            <tr>
                <td>
                    <p class="short-input ue-clear">
                        <label>审核人</label>
                        <input type="text" name="tcheckname"
                               value="<?php echo isset($session["fullName"]) ? $session["fullName"] : ""; ?>"/>
                    </p>
                </td>
            </tr>
            <tr>
                <td>
                    <p class="short-input ue-clear">
                        <label>审核日期</label>
                        <input type="text" name="tcheckdate" readonly="readonly" value="<?php echo date("Y-m-d"); ?>"/>
                    </p>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <p class="long-input ue-clear">
                        <label>备注</label>
                        <input type="text" name="remarks"/>
                        <input type="hidden" name="tcheckstatus"/>
                        <input type="hidden" name="ids" value="<?php echo isset($ids) ? $ids : ""; ?>"/>
                    </p>
                </td>
            </tr>
        </table>
    </div>
</form>
<div class="btn ue-clear">
    <a href="javascript:Save(‘审核通过‘);" class="confirm">审核通过</a>
    <a href="javascript:Save(‘审核拒绝‘);" class="confirm">审核拒绝</a>
</div>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/WdatePicker.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
    });

    function Save(type) {
        if ("审核拒绝" == type && $(‘input[name=remarks]‘).val() == "") {
            alert(‘请备注拒绝理由或明细!‘);
            return;
        }
        $("input[name=tcheckstatus]").val(type);

        var url = "<?php echo "/".$url_module."/".$url_model?>/batchcheck/<?php echo isset($ids)?$ids:"";?>";
        if ("审核拒绝" == type && $(‘input[name=remarks]‘).val() != "") {
            var r = confirm("是否确认审核拒绝?");
            if (r == false) {
                return;
            }
        }
        $.ajax({
            type: "Post",
            url: url,
            data: $("form.formAjax").serialize(),
            success: function (res) {
                var r = $.parseJSON(res);
                if (r.ret == 0) {
                    alert("审核成功");
                    window.parent.check();
                }
                else {
                    alert(r.msg);
                }
            }
        });
    }
</script>
</body>
</html>
时间: 2024-08-10 02:10:00

jquery checkbox用于批量审批的相关文章

jquery checkbox的相关操作——全选、反选、获得所有选中的checkbox

jquery checkbox的相关操作——全选.反选.获得所有选中的checkbox 1.全选 $("#btn1").click(function(){ $("input[name='checkbox']").attr("checked","true"); }) 2.取消全选(全不选) $("#btn2").click(function(){ $("input[name='checkbox']&

jquery checkbox勾选/取消勾选的诡异问题

<form> 你爱好的运动是?<input type="checkbox" id="CheckedAll" />全选/全不选<br /> <input type="checkbox" name="items" value="足球" />足球 <input type="checkbox" name="items" v

jquery checkbox反复调用attr(&#39;checked&#39;, true/false)只有第一次生效

/** * 全选 */ function checkAll() { $("input[name=ids]").attr("checked", true); } /** * 全不选 */ function uncheckAll() { $("input[name=ids]").attr("checked", false); } 问题描述: 初始状态复选框没有全选, 点击全选按钮调用checkAll方法, 实现了全选, 然后点击全

jquery checkbox获取多个选项

http://www.jb51.net/article/27186.htm http://www.cnblogs.com/libingql/archive/2011/11/07/2238663.html http://wangyj0898.blog.51cto.com/1519857/404615 jquery checkbox获取多个选项,布布扣,bubuko.com

jQuery --checkbox全选和取消全选简洁高效的解决办法

最近在公司做了一个小项目,其中有一个全选和取消全选的这么一个模块,搞了半天找不到一种最佳的解决方案!后来通过各种努力找到了一种简洁高效的解决办法,这里想和大家分享一下.有问题的话,还望各路大神指导一二. html代码如下: <fieldset data-role="controlgroup">  <label><input type="checkbox" name="boxes" id="select_al

JQuery Checkbox的change事件

JQuery   Checkbox的change事件 参考 http://blog.csdn.net/hbhgjiangkun/article/details/8126981 $(function(){    $("#ischange").change(function() {        alert("checked");    });}); 上面的代码没作用修改为下面即可$(function(){ if ($.browser.msie) {  $('input

jquery checkbox 全选 不要用attr要用 prop

最近的项目要用到checkbox全选功能,然而使用 attr时总是出现第二次点击时checkbox不变化.后来搜索后,发现在jquery1.6以后已经不用attr处理布尔值的属性了. 查看文档发现 properties就是浏览器用来记录当前值的东西.正常情况下,properties反映它们相应的attributes(如果存在的话).但这并不是boolean attriubutes的情况.当用户点击一个checkbox元素或选中一个select元素的一个option时,boolean proper

jquery checkbox全选,全不选,反选方法,jquery checkbox全选只能操作一次

jquery checkbox全选,全不选,反选方法, jquery checkbox全选只能操作一次, jquery checkbox全选只有第一次成功 Js代码  下载 /** * 全选 * 对于Jquey1.7.2+版本,使用attr会造成只能操作一次. * 对于HTML元素本身就带有的固有属性,在处理时,使用prop方法. * 对于HTML元素我们自己自定义的DOM属性,在处理时,使用attr方法. * @param checkName */ function checkAll(chec

jquery checkbox勾选取消勾选的诡异问题

jquery checkbox勾选/取消勾选的诡异问题jquery checkbox勾选/取消勾选的诡异问题 <form>        你爱好的运动是?<input type="checkbox" id="CheckedAll" />全选/全不选<br />        <input type="checkbox" name="items" value="足球"