UI展示:
数据库:
前台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:'审批人所在部门',width:200},
{field:'title',title:'流程主题',width: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;width:auto;padding:5px;border-bottom:1px solid #B4B4B4;">
<span style="margin-left: 10px;margin-right:10px;">
<input id="single_search_process_box" style="width: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;
}
?>
后台参考代码:
sGetProcess.php
<?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();
}
?>