• EasyUi---searchbox 条件查询


    前台UI参考代码:

    <script type="text/javascript" charset="utf-8"> $(function(){ /***************************邮箱列表*********************************/ $('#single_process_table').datagrid({ url:'./user/sGetProcess.php', border:false, fitColumns:false, singleSelect:true, pagination:true, pageSize:10, pageList:[10,15,20,25,100], columns:[[ {field:'id',title:'序号'}, {field:'name',title:'审批人'}, {field:'department',title:'审批人所在部门',200}, {field:'title',title:'流程主题',200}, {field:'hi_number',title:'申请单编号'}, {field:'used_time',title:'节点审批耗时'}, {field:'detail',title:'邮箱状态'}, {field:'page_url',title:'网址'} ]], onLoadError: function(){ $.messager.alert('提示','没有符合条件的搜索结果!'); } }); /***************************查询邮箱*********************************/ $('#single_search_process_box').searchbox({ searcher:function(value,name){ //当value为空的时候,搜索所有邮箱 $('#single_process_table').datagrid('load', { search_name: name, search_value: value }); }, menu:'#single_search_process_menu', prompt:'Please Input Value' }); }); </script> <div class="it_model_top" style="height:auto;auto;padding:5px;border-bottom:1px solid #B4B4B4;"> <span style="margin-left: 10px;margin-right:10px;"> <input id="single_search_process_box" style="250px;height:26px"></input> <div id="single_search_process_menu" fit="true"> <div data-options="name:'name'">审批人</div> <div data-options="name:'title'">流程主题</div> <div data-options="name:'hi_number'">申请单编号</div> <div data-options="name:'detail'">邮箱状态</div> </div> </span> | <span>更新时间:<?php echo getUpdateTime();?></span> </div> <table id="single_process_table"></table> <?php function getUpdateTime(){ require_once '../../class/c_mysql.class.php'; $db = new c_mysql(); $sql = "select system_time from running_remind limit 1"; $db->connect(); $db->query($sql); $db->close(); $row = $db->fetch_row(); $time = $row[0]; return $time; } ?>

    后台参考代码:

    <?php //构造json对象,因为javascript处理类型为json require_once '../../class/c_mysql.class.php'; if(isset($_POST['page']) && isset($_POST['rows']) && !isset($_POST['search_value']) && !isset($_POST['search_name'])){ $page = $_POST['page']; $rows = $_POST['rows']; $limit_begain = ($page - 1) * $rows; $sql = "select name,department,title,hi_number,used_time,detail,page_url from running_remind order by `id` asc limit $limit_begain,$rows"; $sql_count = "select count(*) from running_remind"; //获取json格式数据 get_json($sql,$sql_count); } if(isset($_REQUEST['search_name']) && isset($_REQUEST['search_value']) && isset($_REQUEST['page']) && isset($_REQUEST['rows'])){ $page = $_POST['page']; $rows = $_POST['rows']; $limit_begain = ($page - 1) * $rows; $search_name = $_POST['search_name']; $search_vaule = $_POST['search_value']; if($search_vaule == ''){ $sql = "select name,department,title,hi_number,used_time,detail,page_url from running_remind order by `id` asc limit $limit_begain,$rows"; $sql_count = "select count(*) from running_remind"; }elseif($search_name == 'hi_number'){ $sql = "select name,department,title,hi_number,used_time,detail,page_url from running_remind where $search_name = '$search_vaule' order by `used_time` desc limit $limit_begain,$rows"; $sql_count = "select count(*) from running_remind where $search_name = '$search_vaule'"; }else{ $sql = "select name,department,title,hi_number,used_time,detail,page_url from running_remind where $search_name like '%$search_vaule%' order by `used_time` desc limit $limit_begain,$rows"; $sql_count = "select count(*) from running_remind where $search_name like '%$search_vaule%'"; } //获取json格式数据 get_json($sql,$sql_count); } function get_json($sql,$sql_count){ $db = new c_mysql(); $db->connect(); $db->query($sql); $db->close(); $count = 1; while($row = $db->fetch_array()){ $row['id'] = $count; $row['used_time'] = number_format($row['used_time'] / 3600,2,'.','').'小时'; $row['page_url'] = "<a target='_blank' href='$row[page_url]'>进入网址</a>"; $row['department'] = explode('-',$row['department']); $row['department'] = $row['department'][0]; $grid_data[] = $row; $count++; } //计算总数 $db->connect(); $db->query($sql_count); $db->close(); $row = $db->fetch_row(); $total = $row[0]; //合并json $json = new json_data(); $json->total = $total; $json->rows = $grid_data; echo json_encode($json); } class json_data{ public $total = 10; public $rows = array(); } ?>

  • 相关阅读:
    windows 下的 Apache SSL证书配置
    javascript xml字符串转为json对象
    php 服务端允许跨域访问
    前端自动化构建工具 gulp 学习笔记 一、
    mysql使用select语句导出表数据时,报error 1290解决方法
    批量操作系统服务的脚本(windows关闭服务脚本)
    Dism++备份还原系统
    Win10开启蓝屏信息记录及文件查看位置的方法
    MySql 8.0服务端安装后,用navicat12连接时报2059错误_解决
    软件测试之细节功能测试_注意点
  • 原文地址:https://www.cnblogs.com/huangf714/p/5864370.html
Copyright © 2020-2023  润新知