570 lines
25 KiB
HTML
570 lines
25 KiB
HTML
|
<!doctype html>
|
|||
|
<html lang="en">
|
|||
|
<head>
|
|||
|
<base href="/case/">
|
|||
|
<meta charset="utf-8">
|
|||
|
<meta name="renderer" content="webkit">
|
|||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|||
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
|||
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
|||
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<div class="layui-anim layui-anim-fadein">
|
|||
|
<div class="layui-row">
|
|||
|
<div class="layui-col-md12">
|
|||
|
<div class="layui-card">
|
|||
|
<div class="layui-card-body">
|
|||
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
|||
|
<div class="layui-inline">
|
|||
|
<input type="hidden" id="startTimeA">
|
|||
|
<input type="text" style="cursor:pointer;" id="startTime" class="layui-input search-item" placeholder="开始时间" readonly>
|
|||
|
</div>
|
|||
|
<div class="layui-inline">
|
|||
|
<input type="hidden" id="endTimeA">
|
|||
|
<input type="text" id="endTime" style="cursor:pointer;" class="layui-input search-item" placeholder="结束时间" readonly>
|
|||
|
</div>
|
|||
|
<button type="button" id="search" style="margin-left: 15px;" class="layui-btn layui-btn-sm">
|
|||
|
<i class="fa fa-lg fa-search"></i> 搜索
|
|||
|
</button>
|
|||
|
<button type="button" id="selectYear" class="layui-btn layui-btn-sm">
|
|||
|
<i class="fa fa-lg fa-calendar-o"></i> 统计本年
|
|||
|
</button>
|
|||
|
<button type="button" id="selectMonth" class="layui-btn layui-btn-sm">
|
|||
|
<i class="fa fa-lg fa-calendar"></i> 统计本月
|
|||
|
</button>
|
|||
|
<button type="button" id="excel" class="layui-btn layui-btn-sm">
|
|||
|
<i class="fa fa-lg fa-download"></i> 导出Excel
|
|||
|
</button>
|
|||
|
</div>
|
|||
|
<div id="headerToolBarBox" style="padding-bottom: 10px"></div>
|
|||
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
|||
|
<script type="text/html" id="headerToolBar">
|
|||
|
<div style="text-align: center;width:100% !important;font-size: 17px">
|
|||
|
<input id="areaParentId" type="hidden" value="{{d.areaParentId}}"/>
|
|||
|
<input id="areaId" type="hidden" value="{{d.areaId}}"/>
|
|||
|
<h2 style="cursor:pointer;" class="{{d.areaId == '110889' ? '' : 'callback'}}">{{d.areaId == '110889' ? '' : '<i class="fa fa-lg fa-reply-all "></i>'}}<u >{{d.areaName}}</u> {{d.title}}</h2>
|
|||
|
</div>
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
|||
|
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
|
|||
|
<script>
|
|||
|
layui.config({
|
|||
|
base: 'assets/layuiadmin/'
|
|||
|
}).extend({
|
|||
|
index: 'lib/index',
|
|||
|
excel: 'layui_exts/excel',
|
|||
|
}).use(['index', 'table', 'laydate', 'common', 'laytpl', 'excel'], function() {
|
|||
|
var $ = layui.$;
|
|||
|
var $win = $(window);
|
|||
|
var table = layui.table;
|
|||
|
var admin = layui.admin;
|
|||
|
var laytpl = layui.laytpl;
|
|||
|
var laydate = layui.laydate;
|
|||
|
var common = layui.common;
|
|||
|
var excel = layui.excel;
|
|||
|
console.log(excel);
|
|||
|
var resizeTimeout = null;
|
|||
|
var tableUrl = 'api/casestatistics/list';
|
|||
|
|
|||
|
/**
|
|||
|
* 导出接口数据
|
|||
|
*/
|
|||
|
function exportApiDemo(url, requestData) {
|
|||
|
var timestart = Date.now()
|
|||
|
$.ajax({
|
|||
|
url: url,
|
|||
|
dataType: 'json',
|
|||
|
data: requestData,
|
|||
|
success: function (res) {
|
|||
|
var list = res.itemList;
|
|||
|
/**
|
|||
|
* v:单元格的值
|
|||
|
* t:单元格的类型 'b'布尔值、'n'数字、'e'错误、's'字符串、'd'日期
|
|||
|
* s:单元格的样式
|
|||
|
*/
|
|||
|
var data = [
|
|||
|
{
|
|||
|
areaName: {
|
|||
|
v: res.areaName + " " + res.title,
|
|||
|
s: {
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
vertical: 'center'
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true,
|
|||
|
sz: 20,
|
|||
|
color: {
|
|||
|
rgb: "FF0187FA"
|
|||
|
}
|
|||
|
},
|
|||
|
// fill: {
|
|||
|
// bgColor: {
|
|||
|
// indexed: 64
|
|||
|
// },
|
|||
|
// fgColor: {
|
|||
|
// rgb: "FFF"
|
|||
|
// }
|
|||
|
// }
|
|||
|
}
|
|||
|
}, reportNumber: '', processesNumber: '', eventNumber: '', overtimeNumber: '', notOvertimeNumber: '', completeNumber: '', notCompleteNumber: '', overtimeProportionNumber: ''
|
|||
|
},// 被合并的列数据也需要填充上
|
|||
|
{
|
|||
|
areaName: {
|
|||
|
v:'地区',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
reportNumber: {
|
|||
|
v:'上报数',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
}, processesNumber: {
|
|||
|
v:'处理数',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
}, eventNumber: {
|
|||
|
v:'事件量',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
},overtimeNumber: {
|
|||
|
v:'超时量',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
}, notOvertimeNumber: {
|
|||
|
v:'未超时量',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
}, completeNumber: {
|
|||
|
v:'完成量',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
},notCompleteNumber: {
|
|||
|
v:'未完成量',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
}, overtimeProportionNumber: {
|
|||
|
v:'超时占比',
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
},
|
|||
|
font: {
|
|||
|
bold:true
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
}
|
|||
|
];
|
|||
|
for(var i = 0 ; i < list.length; i++) {
|
|||
|
var rowData = list[i];
|
|||
|
data.push(
|
|||
|
{
|
|||
|
areaName:{
|
|||
|
v:rowData.areaName,
|
|||
|
t:"s",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
reportNumber: {
|
|||
|
v:rowData.reportNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
processesNumber: {
|
|||
|
v:rowData.processesNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
eventNumber: {
|
|||
|
v:rowData.eventNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
overtimeNumber: {
|
|||
|
v:rowData.overtimeNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
notOvertimeNumber: {
|
|||
|
v:rowData.notOvertimeNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
completeNumber: {
|
|||
|
v:rowData.completeNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
notCompleteNumber: {
|
|||
|
v:rowData.notCompleteNumber,
|
|||
|
t:"n",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
overtimeProportionNumber: {
|
|||
|
v:rowData.overtimeProportionNumber + "%",
|
|||
|
t:"s",
|
|||
|
s:{
|
|||
|
alignment: {
|
|||
|
horizontal: 'center',
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
}
|
|||
|
);
|
|||
|
}
|
|||
|
// 列合并
|
|||
|
var mergeConf = excel.makeMergeConfig([
|
|||
|
['A1', 'I1']
|
|||
|
])
|
|||
|
// A列宽 200, 默认给80
|
|||
|
var colConf = excel.makeColConfig({
|
|||
|
'A': 150,
|
|||
|
}, 140);
|
|||
|
// 每一行的行高, 默认给20
|
|||
|
var rowConf = excel.makeRowConfig({
|
|||
|
1: 30,
|
|||
|
}, 20)
|
|||
|
excel.exportExcel({
|
|||
|
sheet1: data
|
|||
|
}, res.areaName + " " + res.title + '.xlsx', 'xlsx', {
|
|||
|
extend: {
|
|||
|
sheet1: {
|
|||
|
'!merges': mergeConf
|
|||
|
, '!cols': colConf
|
|||
|
, '!rows': rowConf
|
|||
|
}
|
|||
|
}
|
|||
|
})
|
|||
|
var timeend = Date.now()
|
|||
|
var spent = (timeend - timestart) / 1000
|
|||
|
layer.msg('导出耗时 :' + spent + ' s')
|
|||
|
}
|
|||
|
, error: function () {
|
|||
|
layer.alert('获取数据失败, 请检查网络');
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
// 初始化表格
|
|||
|
function initTable() {
|
|||
|
table.render({
|
|||
|
elem: '#dataTable',
|
|||
|
id: 'dataTable',
|
|||
|
url: top.restAjax.path(tableUrl, []),
|
|||
|
width: admin.screen() > 1 ? '100%' : '',
|
|||
|
height: $win.height() - 62,
|
|||
|
defaultToolbar: [],
|
|||
|
cols: [
|
|||
|
[
|
|||
|
{field: 'areaName', width: 180, title: '地区', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
if(row["subList"] == true) {
|
|||
|
return '<button type="button" id="month" class="layui-btn layui-btn-sm" lay-event="areaNameEvent">' +
|
|||
|
rowData + ' <i class="fa fa-lg fa-sign-in"></i>' +
|
|||
|
'</button> ';
|
|||
|
}else{
|
|||
|
return '<button type="button" id="month" class="layui-btn layui-btn-sm">' +
|
|||
|
rowData + ' ' +
|
|||
|
'</button> ';
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'reportNumber', width: 120, title: '上报数', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'processesNumber', width: 120, title: '处理数', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'eventNumber', width: 120, title: '事件量', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'overtimeNumber', width: 120, title: '超时量', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'notOvertimeNumber', width: 120, title: '未超时量', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'completeNumber', width: 120, title: '完成量', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'notCompleteNumber', width: 120, title: '未完成量', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},
|
|||
|
{field: 'overtimeProportionNumber', width: 120, title: '超时占比', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData = row[this.field];
|
|||
|
return rowData + "%";
|
|||
|
}
|
|||
|
},
|
|||
|
/*{field: 'cz', width: 120, title: '操作', align:'center',
|
|||
|
templet: function(row) {
|
|||
|
var rowData =
|
|||
|
'<div class="layui-btn-group">'+
|
|||
|
'<button type="button" class="layui-btn layui-btn-sm" lay-event="excelEvent">导出Excel</button>'+
|
|||
|
'</div>'
|
|||
|
return rowData;
|
|||
|
}
|
|||
|
},*/
|
|||
|
]
|
|||
|
],
|
|||
|
parseData: function(data) {
|
|||
|
/**
|
|||
|
* 重置父区域内容
|
|||
|
* */
|
|||
|
laytpl(document.getElementById('headerToolBar').innerHTML).render(data, function(html) {
|
|||
|
document.getElementById('headerToolBarBox').innerHTML = html;
|
|||
|
});
|
|||
|
return {
|
|||
|
'code': 0,
|
|||
|
'data': data.itemList
|
|||
|
};
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
// 重载表格
|
|||
|
function reloadTable() {
|
|||
|
table.reload('dataTable', {
|
|||
|
url: top.restAjax.path(tableUrl, []),
|
|||
|
where: {
|
|||
|
startTime: $('#startTime').val(),
|
|||
|
endTime: $('#endTime').val(),
|
|||
|
areaId:$("#areaId").val(),
|
|||
|
selectYear:$("#selectYear").hasClass("layui-btn-normal"),
|
|||
|
selectMonth:$("#selectMonth").hasClass("layui-btn-normal")
|
|||
|
},
|
|||
|
height: $win.height() - 62,
|
|||
|
});
|
|||
|
refreshTree();
|
|||
|
}
|
|||
|
$(document).on("click","#excel", function() {
|
|||
|
var requestData = {
|
|||
|
startTime: $('#startTime').val(),
|
|||
|
endTime: $('#endTime').val(),
|
|||
|
areaId:$("#areaId").val(),
|
|||
|
selectYear:$("#selectYear").hasClass("layui-btn-normal"),
|
|||
|
selectMonth:$("#selectMonth").hasClass("layui-btn-normal")
|
|||
|
}
|
|||
|
exportApiDemo(tableUrl, requestData);
|
|||
|
});
|
|||
|
$(document).on("click","#selectYear", function() {
|
|||
|
if(!$(this).hasClass("layui-btn-normal")) {
|
|||
|
$("#selectMonth").removeClass("layui-btn-normal");
|
|||
|
$('#startTime').val("");
|
|||
|
$('#endTime').val("");
|
|||
|
}
|
|||
|
$(this).toggleClass("layui-btn-normal");
|
|||
|
reloadTable();
|
|||
|
});
|
|||
|
$(document).on("click","#selectMonth", function() {
|
|||
|
if(!$(this).hasClass("layui-btn-normal")) {
|
|||
|
$("#selectYear").removeClass("layui-btn-normal");
|
|||
|
$('#startTime').val("");
|
|||
|
$('#endTime').val("");
|
|||
|
}
|
|||
|
$(this).toggleClass("layui-btn-normal");
|
|||
|
reloadTable();
|
|||
|
});
|
|||
|
|
|||
|
$(document).on("click",".callback", function() {
|
|||
|
$("#areaId").val($("#areaParentId").val());
|
|||
|
reloadTable();
|
|||
|
});
|
|||
|
|
|||
|
table.on('tool(dataTable)', function(obj) {
|
|||
|
var layEvent = obj.event;
|
|||
|
var data = obj.data;
|
|||
|
if(layEvent === 'areaNameEvent') {
|
|||
|
$("#areaId").val(data.areaId);
|
|||
|
reloadTable();
|
|||
|
}
|
|||
|
});
|
|||
|
// 初始化日期
|
|||
|
function initDate() {
|
|||
|
// 日期选择
|
|||
|
laydate.render({
|
|||
|
elem: '#startTime',
|
|||
|
type: 'month',
|
|||
|
format: 'yyyy年MM月',
|
|||
|
max: 0 ,
|
|||
|
done: function(value, date, endDate){
|
|||
|
$("#startTimeA").val(date.year + "-" + date.month);
|
|||
|
if($("#endTimeA").val()) {
|
|||
|
var endTimeArr = $("#endTimeA").val().split("-");
|
|||
|
var start = new Date(date.year, date.month);
|
|||
|
var end = new Date(endTimeArr[0], endTimeArr[1]);
|
|||
|
if (start > end) {
|
|||
|
layer.msg("开始时间错误");
|
|||
|
setTimeout(function () {
|
|||
|
$("#startTime").val("");
|
|||
|
$("#startTimeA").val("");
|
|||
|
}, 20);
|
|||
|
return false;
|
|||
|
}else {
|
|||
|
$("#selectYear").removeClass("layui-btn-normal");
|
|||
|
$("#selectMonth").removeClass("layui-btn-normal");
|
|||
|
}
|
|||
|
}else {
|
|||
|
$("#selectYear").removeClass("layui-btn-normal");
|
|||
|
$("#selectMonth").removeClass("layui-btn-normal");
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
laydate.render({
|
|||
|
elem: '#endTime',
|
|||
|
type: 'month',
|
|||
|
format: 'yyyy年MM月',
|
|||
|
max: 0,
|
|||
|
done: function(value, date, endDate){
|
|||
|
$("#endTimeA").val(date.year + "-" + date.month);
|
|||
|
if($("#startTimeA").val()) {
|
|||
|
var endTimeArr = $("#startTimeA").val().split("-");
|
|||
|
var start = new Date(endTimeArr[0], endTimeArr[1]);
|
|||
|
var end = new Date(date.year, date.month);
|
|||
|
if (start > end) {
|
|||
|
layer.msg("结束时间错误");
|
|||
|
setTimeout(function () {
|
|||
|
$("#endTime").val("");
|
|||
|
$("#endTimeA").val("");
|
|||
|
}, 20);
|
|||
|
return false;
|
|||
|
}else {
|
|||
|
$("#selectYear").removeClass("layui-btn-normal");
|
|||
|
$("#selectMonth").removeClass("layui-btn-normal");
|
|||
|
}
|
|||
|
}else {
|
|||
|
$("#selectYear").removeClass("layui-btn-normal");
|
|||
|
$("#selectMonth").removeClass("layui-btn-normal");
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
initTable();
|
|||
|
initDate();
|
|||
|
|
|||
|
// 事件 - 页面变化
|
|||
|
$win.on('resize', function() {
|
|||
|
clearTimeout(resizeTimeout);
|
|||
|
resizeTimeout = setTimeout(function() {
|
|||
|
reloadTable();
|
|||
|
}, 500);
|
|||
|
});
|
|||
|
|
|||
|
// 事件 - 搜索
|
|||
|
$(document).on('click', '#search', function() {
|
|||
|
reloadTable(1);
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</body>
|
|||
|
</html>
|