标签:
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>
标签:
原文地址:http://www.cnblogs.com/lqw4/p/4746203.html