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>

jquery代码

  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);
        });
        $("#btnExcel").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);
            url = "<?php echo "/".$url_module."/".$url_model;?>/excelExportByIds/" + ids;
            $.getJSON(url, '', function (response) {
                window.open(response.urlFile);

            });
        });
    }

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

    function check() {
        $.jBox.close(true);
        getDataList(pageIndex, pageSize);
    }

 

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 modifydatetime='".date("Y-m-d G:i:s")."',verified='".$_POST["tcheckstatus"]."', tcheckname='".$_POST["tcheckname"]."',tcheckdate='".$_POST["tcheckdate"]."',reason='".$_POST["reason"]."' where id in ($ids)";
            if("审核通过"==$_POST["tcheckstatus"])
                $sql = "update companys set modifydatetime='".date("Y-m-d G:i:s")."',isLock='Y',verified='".$_POST["tcheckstatus"]."', tcheckname='".$_POST["tcheckname"]."',tcheckdate='".$_POST["tcheckdate"]."',reason='".$_POST["reason"]."' where id in ($ids)";
            $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" http-equiv="X-UA-Compatible" content="IE=edge"/>
    <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="reason"/>
                        <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 () {
        $("input[name='reason']").val('同意');
    });

    function Save(type) {
        if ("审核拒绝" == type && $('input[name=reason]').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=reason]').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>

 

posted on 2015-08-20 20:33  勤奋者努力着  阅读(340)  评论(0编辑  收藏  举报

导航