Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xianrendzw committed Oct 9, 2016
1 parent 11793b6 commit f38b7a3
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 131 deletions.
4 changes: 2 additions & 2 deletions easyreport-web/src/main/webapp/assets/js/home/index-amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ define(function (require, exports, module) {
menuItems.push('<div style=\"padding: 2px 5px;\">');
for (var i = 0; i < roots.length; i++) {
var module = roots[i].attributes;
var url = module.linkType == 1 ? module.url : EasyReport.ctxPath + '/' + module.url;
var url = module.linkType ? module.url : EasyReport.ctxPath + '/' + module.url;
var onClick = juicer("onclick=\"HomeIndex.addTab('${id}}','${name}','${url}','${icon}')\"", {
id: 'm_' + module.id,
url: url,
Expand Down Expand Up @@ -217,7 +217,7 @@ define(function (require, exports, module) {
menuItems.push("<div id=\"mm" + parent.id + "\" style=\"width: 150px;\">");
for (var i = 0; i < parent.children.length; i++) {
var module = parent.children[i].attributes;
var url = module.linkType == 1 ? module.url : EasyReport.ctxPath + '/' + module.url;
var url = module.linkType ? module.url : EasyReport.ctxPath + '/' + module.url;
var tmpl = "<div data-options=\"iconCls:'${iconCls}'\" " +
"onclick=\"HomeIndex.addTab('${id}','${name}','${url}','${iconCls}',${closable})\">${name}</div>";
menuItems.push(juicer(tmpl, {
Expand Down
4 changes: 2 additions & 2 deletions easyreport-web/src/main/webapp/assets/js/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var HomeIndexMVC = {
menuItems.push('<div style=\"padding: 2px 5px;\">');
for (var i = 0; i < roots.length; i++) {
var module = roots[i].attributes;
var url = module.linkType == 1 ? module.url : EasyReport.ctxPath + '/' + module.url;
var url = module.linkType ? module.url : EasyReport.ctxPath + '/' + module.url;
var onClick = juicer("onclick=\"HomeIndex.addTab('${id}}','${name}','${url}','${icon}')\"", {
id: 'm_' + module.id,
url: url,
Expand Down Expand Up @@ -216,7 +216,7 @@ var HomeIndexMVC = {
menuItems.push("<div id=\"mm" + parent.id + "\" style=\"width: 150px;\">");
for (var i = 0; i < parent.children.length; i++) {
var module = parent.children[i].attributes;
var url = module.linkType == 1 ? module.url : EasyReport.ctxPath + '/' + module.url;
var url = module.linkType ? module.url : EasyReport.ctxPath + '/' + module.url;
var tmpl = "<div data-options=\"iconCls:'${iconCls}'\" " +
"onclick=\"HomeIndex.addTab('${id}','${name}','${url}','${iconCls}',${closable})\">${name}</div>";
menuItems.push(juicer(tmpl, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ var ChartReportMVC = {
data: $("#chart-report-form").serializeObject(),
dataType: "json",
beforeSend: function () {
$.messager.progress({
title: '请稍后...',
text: '报表正在生成中...',
});
if (e) {
$.messager.progress({
title: '请稍后...',
text: '报表正在生成中...',
});
}
},
success: function (result) {
//$.messager.progress("close");
if (result.success) {
ChartReportMVC.Model.metaData = result.data;
ChartReportMVC.Util.initDimOptions();
Expand All @@ -67,7 +68,14 @@ var ChartReportMVC = {
ChartReportMVC.Controller.show("legend1");
}
} else {
$.messager.alert('操作提示', result.data.msg, 'error');
if (e) {
$.messager.alert('操作提示', result.data.msg, 'error');
}
}
},
complete: function () {
if (e) {
$.messager.progress("close");
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ var TableReportMVC = {
table.tablesorter({
sortInitialOrder: 'desc'
});
table.find('#easyreport>thead>tr').attr({
table.find('easyreport>thead>tr').attr({
title: "点击可以排序"
}).css({
cursor: "pointer"
Expand Down
244 changes: 124 additions & 120 deletions easyreport-web/src/main/webapp/assets/vendor/jquery.fixtableheader.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,137 @@
jQuery.fn.fixTableHeader = function(gv, scrollHeight) {
var sizenmu = [];// 放每个td的数组
var initWidth = $(gv).width();
$(gv).find("thead th").each(function() {
$(this).css("width", $(this).width())
});
$(gv).find("tbody tr").eq(0).children().each(function(index, value) {
jQuery.fn.fixTableHeader = function (gv, scrollHeight) {
var sizenmu = [];// 放每个td的数组
var initWidth = $(gv).width();
$(gv).find("thead th").each(function () {
$(this).css("width", $(this).width())
});
$(gv).find("tbody tr").eq(0).children().each(function (index, value) {

$(this).css("width", $(this).outerWidth());
})
var gvn = $(gv).clone(true).removeAttr("id");
var gvn = $(gvn).find("thead");
var table = $("<table>").addClass("easyreport");
table.append(gvn);
var $gv = $(gv);
$gv.before(table);
$gv.wrap("<div style='height:" + scrollHeight
+ "px; overflow-y: scroll;overflow-x:hidden; padding: 0;margin: 0;'></div>");
$(this).css("width", $(this).outerWidth());
})
var gvn = $(gv).clone(true).removeAttr("id");
var gvn = $(gvn).find("thead");
var table = $("<table>").addClass("easyreport");
table.append(gvn);
var $gv = $(gv);
$gv.before(table);
$gv.wrap("<div style='height:" + scrollHeight
+ "px; overflow-y: scroll;overflow-x:hidden; padding: 0;margin: 0;'></div>");

$gv.find("tbody tr").eq(0).children().each(function(index, value) {
sizenmu.push($(this).outerWidth())
$(this).css("width", $(this).outerWidth() - 21);
})
$gv.find("thead").remove();
$gv.find("tbody tr").eq(0).children().each(function (index, value) {
sizenmu.push($(this).outerWidth())
$(this).css("width", $(this).outerWidth() - 21);
})
$gv.find("thead").remove();

var c = $(gvn).find("tr:last").children();
var firstc = sizenmu.length - c.size();
sizenmu.pop();
$gv.parent().width(initWidth)// 设置宽度
$(gvn).find("tr:first").children().each(function(i) {
if (i < firstc) {
$(this).width(sizenmu[i] - 21);
}
var c = $(gvn).find("tr:last").children();
var firstc = sizenmu.length - c.size();
sizenmu.pop();
$gv.parent().width(initWidth)// 设置宽度
$(gvn).find("tr:first").children().each(function (i) {
if (i < firstc) {
$(this).width(sizenmu[i] - 21);
}

})
$(gvn).find("tr:last").children().each(function(index, value) {
$(this).width(sizenmu[firstc] - 21);
firstc = firstc + 1;
});
})
$(gvn).find("tr:last").children().each(function (index, value) {
$(this).width(sizenmu[firstc] - 21);
firstc = firstc + 1;
});
};
jQuery.fn.fixScroll = function(scroll) {
var $e = $(this),
offset = $e.offset(),
$scroll = scroll ? $(scroll) : $(window),
iswindow = "setInterval" in $scroll[0],
top = iswindow ? 0 : ($scroll.offset().top),
newDiv = $("<div />").css({
position : "fixed",
"z-index": 2,
width : $e.width() + 1
}),
scrollWdith = iswindow ? offset.top : offset.top - $scroll.offset().top,
left = offset.left;
jQuery.fn.fixScroll = function (scroll) {
var $e = $(this),
offset = $e.offset(),
$scroll = scroll ? $(scroll) : $(window),
iswindow = "setInterval" in $scroll[0],
top = iswindow ? 0 : ($scroll.offset().top),
newDiv = $("<div />").css({
position: "fixed",
"z-index": 2,
width: $e.width() + 1
}),
scrollWdith = iswindow ? offset.top : offset.top - $scroll.offset().top,
left = offset.left;

var first_TH = $(this).find('thead th:first-child');
var first_TH_width = first_TH.width() + 7;
var first_TH_height = first_TH.height();
var first_TH = $(this).find('thead th:first-child');
var first_TH_width = first_TH.width() + 7;
var first_TH_height = first_TH.height();

var $thList = $e.find("thead");
$thList.find("th").each(function() {
$(this).css("width", $(this).width()).data('element', $(this));
});
var $thList = $e.find("thead");
$thList.find("th").each(function () {
$(this).css("width", $(this).width()).data('element', $(this));
});

var cloneTh = $thList.clone(true);
if($(this).data('isSort')) {
cloneTh.css('cursor', 'pointer');
}
newDiv.append($("<table>").addClass("easyreport").append(cloneTh));
$e.before(newDiv);
var cloneTh = $thList.clone(true);
if ($(this).data('isSort')) {
cloneTh.css('cursor', 'pointer');
}
newDiv.append($("<table>").addClass("easyreport").append(cloneTh));
$e.before(newDiv);

cloneTh.on('click', 'th', function() {
$(this).data('element').trigger('sort');
})
cloneTh.on('click', 'th', function () {
$(this).data('element').trigger('sort');
})

$(this).bind('sortEnd', function(i, table) {
fixedRowInner.find('table tbody').html($(this).find('tbody').html());
})
$(this).bind('sortEnd', function (i, table) {
fixedRowInner.find('table tbody').html($(this).find('tbody').html());
})

var tableCopy = $(this).clone();
var copyFirst_TR = tableCopy.find('thead tr:first-child');
var fixRowCount = tableCopy.find('.c:first .back').length || 1;
var copyFirst_TH = copyFirst_TR.find('th');
var fixRowWidth = 0, prev_TH, width;
for(var i = 0, len = fixRowCount; i < len; i++) {
width = $thList.find('th').eq(i).width();
fixRowWidth += width + 7;
}
if(fixRowCount === 1) {
var first_TH_copy = copyFirst_TH.eq(0).clone().css({
"position": "fixed",
"top": 0,
"left": 0,
"width": width,
"height": first_TH_height,
"line-height": first_TH_height + 'px',
"z-index":5,
"display": "none"
});
copyFirst_TR.prepend(first_TH_copy);
first_TH_copy.bind('click', function() {
first_TH.trigger('sort');
});
copyFirst_TH.bind('click', function() {
first_TH.trigger('sort');
});
}
var fixedRow = $('<div style="position:absolute;top:0;left:0;overflow:hidden;width:' + (fixRowWidth) + 'px;"></div>');
var fixedRowInner = $('<div style="width:' + ($e.width() + 1) + 'px;"></div>');
fixedRowInner.append(tableCopy);
fixedRow.append(fixedRowInner);
$('#reportDiv').css('position', 'relative').append(fixedRow);
var tableCopy = $(this).clone();
var copyFirst_TR = tableCopy.find('thead tr:first-child');
var fixRowCount = tableCopy.find('.c:first .back').length || 1;
var copyFirst_TH = copyFirst_TR.find('th');
var fixRowWidth = 0, prev_TH, width;
for (var i = 0, len = fixRowCount; i < len; i++) {
width = $thList.find('th').eq(i).width();
fixRowWidth += width + 7;
}
if (fixRowCount === 1) {
var first_TH_copy = copyFirst_TH.eq(0).clone().css({
"position": "fixed",
"top": 0,
"left": 0,
"width": width,
"height": first_TH_height,
"line-height": first_TH_height + 'px',
"z-index": 5,
"display": "none"
});
copyFirst_TR.prepend(first_TH_copy);
first_TH_copy.bind('click', function () {
first_TH.trigger('sort');
});
copyFirst_TH.bind('click', function () {
first_TH.trigger('sort');
});
}
var fixedRow = $('<div style="position:absolute;top:0;left:0;overflow:hidden;width:' + (fixRowWidth) + 'px;"></div>');
var fixedRowInner = $('<div style="width:' + ($e.width() + 1) + 'px;"></div>');
fixedRowInner.append(tableCopy);
fixedRow.append(fixedRowInner);
$('#reportDiv').css('position', 'relative').append(fixedRow);

var fixRow_TH = fixedRow.find('th');
$scroll.bind("scroll", function() {
var scrollLeft = $scroll.scrollLeft();
if ($scroll.scrollTop() > scrollWdith) {
newDiv.show();
newDiv.css({
"top" : top,
"left" : -(scrollLeft - left)
});
if(first_TH_copy){first_TH_copy.show();}
} else {
newDiv.hide();
if(first_TH_copy){first_TH_copy.hide();}
}
if(scrollLeft > 5) {
fixedRow.css('left', (scrollLeft - left) + 'px').show();
} else {
fixedRow.hide();
}
});
var fixRow_TH = fixedRow.find('th');
$scroll.bind("scroll", function () {
var scrollLeft = $scroll.scrollLeft();
if ($scroll.scrollTop() > scrollWdith) {
newDiv.show();
newDiv.css({
"top": top,
"left": -(scrollLeft - left)
});
if (first_TH_copy) {
first_TH_copy.show();
}
} else {
newDiv.hide();
if (first_TH_copy) {
first_TH_copy.hide();
}
}
if (scrollLeft > 5) {
fixedRow.css('left', (scrollLeft - left) + 'px').show();
} else {
fixedRow.hide();
}
});
};

0 comments on commit f38b7a3

Please sign in to comment.