解决导出错误提示-唐浩 活跃ip导出报表格式更改

This commit is contained in:
zhanghongqing
2018-12-24 19:16:14 +08:00
parent fbbd5ec3bd
commit c05cc92f3b
6 changed files with 84 additions and 20 deletions

View File

@@ -81,7 +81,7 @@
<div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div> <div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div>
</div> </div>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <spring:message code="export"/> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;"> <ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;">
@@ -100,8 +100,8 @@
<th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th>
<th class="tl"><spring:message code="packets"/></th> <th class="tl"><spring:message code="packets"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th>
<th class="tl"><spring:message code="Gbyte"/></th> <th class="tl"><spring:message code="GByte"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="Gbyte"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="GByte"/>)</th>
</tr> </tr>
</thead> </thead>
<tbody id="tableData"></tbody> <tbody id="tableData"></tbody>

View File

@@ -58,7 +58,7 @@
<div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div> <div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div>
</div> --> </div> -->
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <spring:message code="export"/> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;"> <ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;">
@@ -77,8 +77,8 @@
<th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th>
<th class="tl"><spring:message code="packets"/></th> <th class="tl"><spring:message code="packets"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th>
<th class="tl"><spring:message code="Gbyte"/></th> <th class="tl"><spring:message code="GByte"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="Gbyte"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="GByte"/>)</th>
</tr> </tr>
</thead> </thead>
<tbody id="tableData"></tbody> <tbody id="tableData"></tbody>

View File

@@ -46,12 +46,13 @@
<button type="button" class="btn blue" onClick="return searchList()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button> <button type="button" class="btn blue" onClick="return searchList()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button>
<button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button> <button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button>
</div> </div>
</div> </div>
<!-- 搜索内容与操作按钮栏 --> <!-- 搜索内容与操作按钮栏 -->
</form:form> </form:form>
</div> </div>
<div id="chart" style="width:95%;height:350px;"></div> <div id="chart" style="width:95%;height:350px;"></div>
<input id="total" type="hidden"/>
<div class="col-md-12"> <div class="col-md-12">
<div class="portlet"> <div class="portlet">
<div class="portlet-body"> <div class="portlet-body">
@@ -61,7 +62,7 @@
<spring:message code="traffic_ipactive_hour_max"></spring:message> <spring:message code="traffic_ipactive_hour_max"></spring:message>
</h3> </h3>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <spring:message code="export"/> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;"> <ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;">
@@ -106,6 +107,7 @@
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/offline-exporting.js"></script> <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/offline-exporting.js"></script>
<%-- <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/themes/grid.js"></script> --%> <%-- <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/themes/grid.js"></script> --%>
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting-data.js"></script> <script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/exporting-data.js"></script>
<script src="${pageContext.request.contextPath}/static/global/plugins/highcharts/js/standalone.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
loading(); loading();
@@ -114,7 +116,7 @@ $(document).ready(function(){
$("#beginDate").val(starth); $("#beginDate").val(starth);
$("#endDate").val(endh); $("#endDate").val(endh);
ipActiveMinuteList(starth,endh); ipActiveMinuteList(starth,endh);
ipActiveOneHourList(starth,endh); // ipActiveOneHourList(starth,endh);
//筛选功能初始化 //筛选功能初始化
$("#resetBtn").on("click",function(){ $("#resetBtn").on("click",function(){
$("select.selectpicker").each(function(){ $("select.selectpicker").each(function(){
@@ -126,6 +128,7 @@ $(document).ready(function(){
$("#searchForm")[0].reset(); $("#searchForm")[0].reset();
}); });
}); });
//导出列表 //导出列表
$(".export-btn").click(function(){ $(".export-btn").click(function(){
var dataType = $(this).attr("data-type"); var dataType = $(this).attr("data-type");
@@ -133,7 +136,7 @@ $(".export-btn").click(function(){
var end=$("#endDate").val(); var end=$("#endDate").val();
var htmlTitle=""; var htmlTitle="";
htmlTitle+="<tr class='tr-title'>"; htmlTitle+="<tr class='tr-title'>";
htmlTitle+= "<th class='tc' colspan='1'>"+"<spring:message code='traffic_ipactive_hour_max'/>"+"</th>"; htmlTitle+= "<th class='tc' colspan='1'>"+"<spring:message code='traffic_ipactive_hour_trend'/>"+"</th>";
htmlTitle+= "<th class='tc' colspan='2'>"+start+"--"+ end +"</th>"; htmlTitle+= "<th class='tc' colspan='2'>"+start+"--"+ end +"</th>";
htmlTitle+="</tr>" htmlTitle+="</tr>"
$("#contentTable thead").prepend(htmlTitle); $("#contentTable thead").prepend(htmlTitle);
@@ -156,7 +159,7 @@ function searchList(){
window.location.reload(); window.location.reload();
}else{ }else{
ipActiveMinuteList(start,end); ipActiveMinuteList(start,end);
ipActiveOneHourList(start,end); // ipActiveOneHourList(start,end);
} }
} }
@@ -164,14 +167,18 @@ function showIpActiveChart(rs){
var data=new Array(); var data=new Array();
var xData=new Array(); var xData=new Array();
xData=rs[0].statTime; xData=rs[0].statTime;
//var tickInterval=Math.ceil(xData.length/6);
var series=new Array(); var series=new Array();
var total=[];
$(rs).each(function(i, d) { $(rs).each(function(i, d) {
total.push(
sum(d.linkNum)
)
series.push({ series.push({
name: d.ipAddr, name: d.ipAddr,
data: d.linkNum data: d.linkNum
}); });
}) })
$("#total").val(JSON.stringify(total));
var chart = Highcharts.chart('chart', { var chart = Highcharts.chart('chart', {
chart:{ chart:{
//type: 'area', //type: 'area',
@@ -337,6 +344,62 @@ function showIpActiveChart(rs){
}); });
} }
(function(H) {
H.Chart.prototype.downloadXLS = function() {
var div = document.createElement('div'),
xlsxRows = [],
xlsxColumns = [];
div.style.display = 'none';
document.body.appendChild(div);
rows = this.getDataRows(true);
xlsxRows = H.map(rows.slice(1), function(row) {
return H.map(row, function(column) {
return {
type: typeof column === 'number' ? 'number' : 'string',
value: column
};
});
});
var start=$("#beginDate").val();
var end=$("#endDate").val();
var b =new Array();
b.push({
type:'string',
value:'IP-Active'
})
b.push({
type:"string",
value:start+"--"+end
})
xlsxRows.unshift(b);
var a =new Array();
a.push({
type:'string',
value:'Total'
})
var total=total=JSON.parse($("#total").val());
$(total).each(function(i, d) {
a.push({
type:"number",
value:d
})
})
xlsxRows.push(a)
zipcelx({
filename: 'IP-Active',
sheet: {
data: xlsxRows
}
});
};
}(Highcharts));
function sum(arr) {
return arr.reduce(function(prev, curr, idx, arr){
return prev + curr;
});
}
</script> </script>
</body> </body>
</html> </html>

View File

@@ -71,7 +71,7 @@
<div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div> <div id="chart" style="width:98%;height: 510px; -moz-user-select: none; position: relative;"></div>
</div> </div>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <spring:message code="export"/> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;"> <ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;">
@@ -90,8 +90,8 @@
<th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="link_num"/>)</th>
<th class="tl"><spring:message code="packets"/></th> <th class="tl"><spring:message code="packets"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="packets"/>)</th>
<th class="tl"><spring:message code="Gbyte"/></th> <th class="tl"><spring:message code="GByte"/></th>
<th class="tl"><spring:message code="percentage"/> (<spring:message code="Gbyte"/>)</th> <th class="tl"><spring:message code="percentage"/> (<spring:message code="GByte"/>)</th>
</tr> </tr>
</thead> </thead>
<tbody id="tableData"></tbody> <tbody id="tableData"></tbody>

View File

@@ -121,7 +121,7 @@
<i class="fa fa-download"> <spring:message code="print" /></i> <i class="fa fa-download"> <spring:message code="print" /></i>
</button> </button>
<div class="btn-group pull-right"> <div class="btn-group pull-right">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <spring:message code="export"/> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-wrench"></i> <spring:message code="export"/>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;"> <ul class="dropdown-menu" role="menu" style="min-width: 81px;right: -16px;">
@@ -142,8 +142,8 @@
<th><spring:message code="entrance_id"/></th> <th><spring:message code="entrance_id"/></th>
<th><spring:message code="packets"/></th> <th><spring:message code="packets"/></th>
<th><spring:message code="percentage"/> (<spring:message code="packets"/>)</th> <th><spring:message code="percentage"/> (<spring:message code="packets"/>)</th>
<th><spring:message code="Gbyte"/></th> <th><spring:message code="GByte"/></th>
<th><spring:message code="percentage"/> (<spring:message code="Gbyte"/>)</th> <th><spring:message code="percentage"/> (<spring:message code="GByte"/>)</th>
</tr> </tr>
</thead> </thead>
<tbody id="tableData"></tbody> <tbody id="tableData"></tbody>

File diff suppressed because one or more lines are too long