企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## HTML ``` <form class="navbar-form form-inline" method="post" action="{:U('Admin/order/export_order')}" name="search-form2" id="search-form2"> <!--各种input值--> <input type="hidden" name="order_by" value="order_id"> <input type="text" size="30" name="keywords" class="qsbox" placeholder="搜索相关数据..."> <input type="button" onclick="ajax_get_table('search-form2',1)" class="btn" value="搜索"> </form> <div id="flexigrid" cellpadding="0" cellspacing="0" border="0"> //这里填充数据 </div> ``` ## JS ``` <script type="text/javascript"> $(document).ready(function(){ ajax_get_table('search-form2',1); //ajax 抓取页面 function ajax_get_table(tab,page){ cur_page = page; //当前页面 保存为全局变量 $.ajax({ type : "POST", url:"/index.php/Admin/order/ajaxindex/p/"+page,//+tab, data : $('#'+tab).serialize(),// 你的formid success: function(data){ $("#flexigrid").html(''); $("#flexigrid").append(data); // 表格行点击选中切换 $('#flexigrid > table>tbody >tr').click(function(){ $(this).toggleClass('trSelected'); }); } }); } }) </script> ``` ## PHP 有点儿,仅供参考 ``` /* *Ajax首页 */ public function ajaxindex(){ $orderLogic = new OrderLogic(); $timegap = I('timegap'); if($timegap){ $gap = explode('-', $timegap); $begin = strtotime($gap[0]); $end = strtotime($gap[1]); }else{ //@new 新后台UI参数 $begin = strtotime(I('add_time_begin')); $end = strtotime(I('add_time_end')); } // 搜索条件 $condition = array(); $keyType = I("keytype"); $keywords = I('keywords','','trim'); $consignee = ($keyType && $keyType == 'consignee') ? $keywords : I('consignee','','trim'); $consignee ? $condition['consignee'] = trim($consignee) : false; if($begin && $end){ $condition['add_time'] = array('between',"$begin,$end"); } $condition['order_prom_type'] = array('lt',5); $order_sn = ($keyType && $keyType == 'order_sn') ? $keywords : I('order_sn') ; $order_sn ? $condition['order_sn'] = trim($order_sn) : false; I('order_status') != '' ? $condition['order_status'] = I('order_status') : false; I('pay_status') != '' ? $condition['pay_status'] = I('pay_status') : false; I('pay_code') != '' ? $condition['pay_code'] = I('pay_code') : false; I('shipping_status') != '' ? $condition['shipping_status'] = I('shipping_status') : false; I('user_id') ? $condition['user_id'] = trim(I('user_id')) : false; $sort_order = I('order_by','DESC').' '.I('sort'); $count = M('order')->where($condition)->count(); $Page = new AjaxPage($count,20); $show = $Page->show(); //获取订单列表 $orderList = $orderLogic->getOrderList($condition,$sort_order,$Page->firstRow,$Page->listRows); $this->assign('orderList',$orderList); $this->assign('page',$show);// 赋值分页输出 $this->assign('pager',$Page); return $this->fetch(); } ```