新增统计页面
This commit is contained in:
parent
387f7db472
commit
96725f41d4
@ -272,6 +272,7 @@ public class CountServiceImpl extends BaseService implements ICountService {
|
||||
// 返回结果
|
||||
Map<String, Object> result = getHashMap(4);
|
||||
result.put("year", year);
|
||||
result.put("areaList", areaDTOs);
|
||||
result.put("checkItemList", checkItemList);
|
||||
return new SuccessResultData<>(result);
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
<i class="fa fa-lg fa-print"></i> 打印
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-col-md3" id="tableBox"></div>
|
||||
<div class="layui-col-md6" id="tableBox"></div>
|
||||
<script id="tableBoxTemplate" type="text/html">
|
||||
<h2 id="title" style="line-height: 32px;">{{d.data.year}}各地区企业检查情况表</h2>
|
||||
<table class="layui-table" id="table">
|
||||
|
@ -9,27 +9,42 @@
|
||||
<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">
|
||||
<style>
|
||||
table th, td {text-align: center !important;}
|
||||
#title {text-align: center;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12">
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>地区</th>
|
||||
<th>计划数</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>昆都仑区</td>
|
||||
<td>20</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<script id="tableTemplate" type="text/html">
|
||||
</script>
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md12 button-group-box" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline">
|
||||
<input type="text" id="year" class="layui-input search-item" placeholder="年份" readonly>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
<button type="button" id="print" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-print"></i> 打印
|
||||
</button>
|
||||
</div>
|
||||
<div class="layui-col-md12" id="tableBox"></div>
|
||||
<script id="tableBoxTemplate" type="text/html">
|
||||
<h2 id="title" style="line-height: 32px;">{{d.data.year}}隐患上报详情表</h2>
|
||||
<table class="layui-table" id="table" id="table">
|
||||
<thead>
|
||||
<tr id="tHead"></tr>
|
||||
</thead>
|
||||
<tbody id="tBody"></tbody>
|
||||
</table>
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -43,20 +58,148 @@
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var laydate = layui.laydate;
|
||||
var laytpl = layui.laytpl;
|
||||
var common = layui.common;
|
||||
var resizeTimeout = null;
|
||||
|
||||
// 事件 - 页面变化
|
||||
$win.on('resize', function() {
|
||||
clearTimeout(resizeTimeout);
|
||||
resizeTimeout = setTimeout(function() {
|
||||
reloadTable();
|
||||
}, 500);
|
||||
});
|
||||
var today = common.formatDate('yyyy', new Date())
|
||||
|
||||
// 初始化日期
|
||||
function initDate() {
|
||||
// 日期选择
|
||||
laydate.render({
|
||||
elem: '#year',
|
||||
type: 'year',
|
||||
format: 'yyyy',
|
||||
trigger: 'click',
|
||||
value: today
|
||||
});
|
||||
}
|
||||
initDate();
|
||||
|
||||
// 动态表格
|
||||
function DynamicTable(data) {
|
||||
var maxColspan = 1;
|
||||
function initMaxColspan(data, level) {
|
||||
if(level > maxColspan) {
|
||||
maxColspan = level;
|
||||
}
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
// 处理成标准结构开始
|
||||
if(item.subCheckItem && item.subCheckItem.length > 0) {
|
||||
item.sub = item.subCheckItem;
|
||||
} else if(item.checkItemOptions && item.checkItemOptions.length > 0) {
|
||||
item.sub = item.checkItemOptions;
|
||||
}
|
||||
// 处理成标准结构结束
|
||||
if(item.sub) {
|
||||
initMaxColspan(item.sub, level + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
initMaxColspan(data, 1);
|
||||
|
||||
function getRowspan(data) {
|
||||
var rowSpan = 0;
|
||||
if(data.sub) {
|
||||
for(var i = 0, item; item = data.sub[i++];) {
|
||||
rowSpan += getRowspan(item);
|
||||
}
|
||||
}
|
||||
return rowSpan == 0 ? 1 : rowSpan;
|
||||
}
|
||||
|
||||
// 构建表格
|
||||
function buildTable(data, level, callback) {
|
||||
var trData = '';
|
||||
for(var i = 0, item; item = data[i++];) {
|
||||
// 设置行开始
|
||||
if(i > 1) {
|
||||
trData += '<tr>';
|
||||
}
|
||||
var colspan = 1;
|
||||
// 设置合并列
|
||||
if(!item.sub) {
|
||||
colspan = level < maxColspan ? (maxColspan - level + 1) : 1;
|
||||
}
|
||||
// 设置合并行
|
||||
var rowspan = getRowspan(item);
|
||||
trData += '<td rowSpan="'+ rowspan +'" colspan="'+ colspan +'">'+ item.name +'</td>';
|
||||
if(item.sub) {
|
||||
trData += buildTable(item.sub, level + 1, callback);
|
||||
} else {
|
||||
if(callback) {
|
||||
trData += callback(item);
|
||||
}
|
||||
}
|
||||
// 设置行结束
|
||||
if(i > 1) {
|
||||
trData += '</tr>'
|
||||
}
|
||||
}
|
||||
return trData;
|
||||
}
|
||||
|
||||
function initTHead(id, area) {
|
||||
var th = '<th colspan="'+ maxColspan +'">指标</th>';
|
||||
for(var i = 0, item; item = area[i++];) {
|
||||
th += '<th>'+ item.dictionaryName +'</th>';
|
||||
}
|
||||
document.getElementById(id).innerHTML = th;
|
||||
}
|
||||
function initTBody(id, callback) {
|
||||
var tableString = buildTable(data, 1, callback);
|
||||
document.getElementById(id).innerHTML = tableString;
|
||||
}
|
||||
this.initTHead = initTHead;
|
||||
this.initTBody = initTBody;
|
||||
}
|
||||
|
||||
function initTable() {
|
||||
|
||||
var loadLayerIndex;
|
||||
top.restAjax.get(top.restAjax.path('api/count/counthiddendangerreportdetail/{year}', [$('#year').val() ? $('#startTime').val() : today]), {}, null, function(code, data) {
|
||||
laytpl(document.getElementById('tableBoxTemplate').innerHTML).render(data, function(html) {
|
||||
document.getElementById('tableBox').innerHTML = html;
|
||||
var dynamicTable = new DynamicTable(data.data.checkItemList);
|
||||
dynamicTable.initTHead('tHead', data.data.areaList);
|
||||
dynamicTable.initTBody('tBody', function(tdData) {
|
||||
var td = '';
|
||||
for(var i = 0, item; item = tdData.areaList[i++];) {
|
||||
td += '<td>'+ item.checkCount +'</td>';
|
||||
}
|
||||
return td;
|
||||
});
|
||||
});
|
||||
}, function(code, data) {
|
||||
top.dialog.msg(data.msg);
|
||||
}, function() {
|
||||
loadLayerIndex = top.dialog.msg('正在加载...', {icon: 16, time: 0, shade: 0.3});
|
||||
}, function() {
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
|
||||
// 事件 - 搜索
|
||||
$(document).on('click', '#search', function() {
|
||||
initTable();
|
||||
});
|
||||
|
||||
$(document).on('click', '#print', function() {
|
||||
var bodyHtml = $('html');
|
||||
var html = bodyHtml.clone();
|
||||
html.find('.button-group-box').remove();
|
||||
html.find('.layui-anim').css({'padding': '0px'});
|
||||
var win = window.open("打印窗口", "_blank");
|
||||
win.document.write(html.html());
|
||||
$(win.document).ready(function() {
|
||||
setTimeout(function() {
|
||||
win.print();
|
||||
win.close();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
Loading…
Reference in New Issue
Block a user