reportproject.js
11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
var currentPage=1;//当前页
var totalpage=0;//总页数
var pageNum = 5;//最多显示页数
var pageSize = 5;
var jsonOr = "";
var curserver
var isCreports="";
var showCreports="";
var isCreportsStats="";
var userid="";
var conditionStr="";
$(function() {
curserver = CONF_BACK_SERVERURL;
userid = $("#userId",parent.document).val();
loadlist(1,"");
clickEvent();
tab_li();
setListHeight();
});
//当窗口改变宽度时执行此函数
window.onresize=setListHeight;
function setListHeight() {
var tableTop = 145;//$("#nvaTab").offset().top;
var wh = $(window).height();
var bodyPadding = parseInt($("body").css("padding"));
var iframeTop = window.parent.$("#iframecontent").offset().top;
$("#reportList").css("height",wh-iframeTop-tableTop-bodyPadding+"px");
}
window.onload = function(){
setTimeout(function() {parent.window.NProgress.done()}, 500);
}
function userinfor(){
}
function pageWidget(total) {
layui.use('laypage', function(){
var laypage = layui.laypage;
laypage.render({
elem: 'laypage'
,count: total
,curr: currentPage
,limit: pageSize
,limits: [10, 13, 16, 20]
,limit:pageNum
,theme:"#337ab7"
,layout: ['count', 'prev', 'page', 'next', 'skip']
,jump: function(obj, first){
currentPage = obj.curr;
pageSize = obj.limit;
//首次不执行
if(!first){
if(isCreportsStats == "isCreports") {
loadlist(currentPage,conditionStr,"mycollection");
}else {
loadlist(currentPage,conditionStr);
}
}
}
});
});
}
function clickEvent(){
$("#datalist tbody tr").click(function (){
var reportName=$(this).find("td").html();
reportName=encodeURI(encodeURI(reportName));
var url=txtShowListUrl+reportName;
window.open(url);
});
$('#searchInput').bind('keyup', function(event) {
if (event.keyCode == "13") {
//回车执行查询
var searchInput = $('#searchInput').val();
conditionStr = searchInput.trim();
if(isCreportsStats == "isCreports")
loadlist(1,conditionStr,"mycollection");
else
loadlist(1,conditionStr);
}else{
conditionStr="";
}
});
$("#searchInput").on('input',function(e){
searchInfo = $("#searchInput").val();
if(searchInfo==''){
if(isCreportsStats == "isCreports")
loadlist(1,"","mycollection");
else
loadlist(1,"");
}
});
$('#searchbtn').click(function(){
var searchInput = $('#searchInput').val();
conditionStr=searchInput.trim();
if(isCreportsStats == "isCreports")
loadlist(1,searchInput,"mycollection");
else
loadlist(1,searchInput);
});
}
function loadlist(pageIndex,condition,state){
// hyh 新增 微信loading 2017/10/27
parent.window.$.showLoading();
currentPage = pageIndex;
pageSize=5;
$.ajax({
type: "POST",
url: curserver + '/mvc/reports/getReportsearch.do',
headers:{
"token":$.cookie('ftoken')
},
data:{
page:pageIndex,
userid:userid,
state:state,
condition:condition
},
dataType: 'json',
success:function(result){
var rowdatas=result.rows;
var totalre = result.total;
var totalpa =Math.ceil(totalre/5);
totalpage = totalpa;
dynamicDiv(rowdatas,"reportList",state);
pageWidget(totalre);
if(totalre==0){
$('#msg').css("display","block");
$('#pageZero').css("display","none");
$('#laypage').css("display","none");
}else{
$('#msg').css("display","none");
$('#pageZero').css("display","block");
$('#laypage').css("display","block");
}
setTimeout(function() {parent.window.$.hideLoading()},500);
}
});
}
function dynamicDiv(rowdatas,divid,state){
$("#"+divid).children().remove();
if(rowdatas.length>0){
for(var i=0;i<rowdatas.length;i++){
var rowdata = rowdatas[i];
var reportName = rowdata.NAME;
if(conditionStr != ""){
reportName=reportName.replace(conditionStr,'<span style="color:red;font-weight: bold;font-size:20px;">' + conditionStr
+ '</span>');
}
var time = new Date(rowdata.CREATEDT);
if(rowdata.REMARK==undefined||rowdata.REMARK==null){
rowdata.REMARK="";
}
if(rowdata.CREPORT=="1"){
showCreports="<span style=\"font-size:18px;\" onclick='Creports(this)' class=\"glyphicon glyphicon-star\" title='取消收藏'></span>"
}else{
showCreports="<span style=\"font-size:18px;color: #afafaf;\" onclick='Creports(this)' class=\"glyphicon glyphicon-star-empty\" title='收藏'></span>"
}
var listStr = "<div class=\"contentList\"><div style=\"margin-bottom:20px;position:relative\"><div id=\"rpid\">"+
'<input type="text" hidden="hidden" value='+rowdata.ID+'>'+
"<a style=\"font-weight: bold;font-size:20px;\" onclick=\"openDetail(this)\">"+reportName+"</a>"+
"</div><div style=\"color: #888484;margin-top:3px;\">"+rowdata.REMARK+"</div>"+
"<div style=\"color: #888484\">更新时间:"+time.format("yyyy-MM-dd hh:mm")+"</div>" +
"<a style=\"position:absolute;top:15px;right:100px\" ><span style=\"font-size:18px;color:#3388ff\">"+showCreports+"</span></a></div>" +
"</div>";
$("#"+divid).append(listStr);
}
}
}
function Creports(obj){
var id = $(obj).parent().parent().siblings("#rpid").find("input").val();
var creportStats=true;
if($(obj).attr("title")=="取消收藏"){
creportStats=false;
}
$.ajax({
type: "POST",
url: curserver + '/mvc/reports/collectionReport.do',
headers:{
"token":$.cookie('ftoken')
},
data:{userid:userid,reportid:id,creport:creportStats},
success:function(result){
if(isCreportsStats == "isCreports")
loadlist(1,"","mycollection");
else
loadlist(1,"");
}
});
}
/**
* 报表点击事件
* @param obj
*/
function openReport(obj){
// var report = $("#name").val();
// var reportalias = $(this).find("#alias").val();
// var url = "";
// if(reportalias.substr(reportalias.indexOf("."))==".jsp"){
// url = txtRepory + "/reportjsp/"+reportalias+"?&projectid="+projectid;
// }else{
//url = txtShowListUrl + report ;+ "&projectid=" + projectid;
// url = txtShowListUrl + report+".cpt" ;
// }
// url= encodeURI(encodeURI(url));
// window.open(url);
}
/**
* 查询统计
*/
function showReport(type){
if(type==1){
parent.layer.open({
type: 1, //page层
area: ['800px', '600px'],
title: '报表',
shade: 0.6, //遮罩透明度
moveType: 1, //拖拽风格,0是默认,1是传统拖动
//shift: 1, //0-6的动画形式,-1不开启
content: '<img alt="" src="ApprovalTask/images/baobiao.png">'
});
}else if(type==2){
window.parent.addTab('报表查询', 'ApprovalTask/Pages/searchstaticstics.html');
}
}
function searchlist(){
if($("#datalist").is(":hidden")){
$("#datalist").show();
$("#pagecount").show();
}
}
function tab_li(){
var lis = $("#tag > ul > li");
var condition
lis.click(function(){
var term = $(this).find("input").val();
var data_ = $("#searchInput").val().trim();
lis.each(function(){
$(this).removeClass("tag_active");
});
$(this).addClass("tag_active");
if(term=="预置报表"){
if(data_.length>0){
loadlist(1,data_);
}else{
loadlist(1,"");
}
isCreportsStats = "Creports"
}
if(term=="我的收藏"){
if(data_.length>0){
loadlist(1,data_,"mycollection");
}else{
loadlist(1,"","mycollection");
}
isCreportsStats = "isCreports"
}
});
}
function openDetail(obj){
var id = $(obj).parents().children("input").val();
// window.open(global.contextPath+"/view/projecttask/reportDetails.jsp?id="+id);
$.ajax({
type: "POST",
async: false,
url: curserver + global.modelctls.reports.detail,
headers:{
"token":$.cookie('ftoken')
},
data:{id:id},
dataType: 'json',
success:function(result){
currentReport = result;
$('#reportname').text(currentReport.name);
$('#reportmo').text(currentReport.remark);
var time = new Date(currentReport.createdt);
$("#reportTime").text(time.format("yyyy-MM-dd hh:mm"));
revisionid = currentReport.revisionid
$.ajax({
type: "POST",
async: false,
url: curserver + global.modelctls.reports.revision.content.get,
headers:{
"token":$.cookie('ftoken')
},
data:{ id: revisionid },
dataType:'text',
success:function(result){
var obj = result ? JSON.parse(result) : { path: '', args: [] };
finereportPath = obj.path
if(obj.args == undefined || obj.args.length == 0 || obj.args == null){
var reportURL = cjkEncode(CONF_REPORTURL+finereportPath);
//window.open(reportURL);
parent.saveOpenNew(window.open(reportURL, '_blank'));
return;
}else{
var name = obj.args[0].name;
var value = obj.args[0].value;
var reportURL = cjkEncode(CONF_REPORTURL+finereportPath+"&"+name+"="+value);
//window.open(reportURL);
parent.saveOpenNew(window.open(reportURL, '_blank'));
return;
}
}
});
}
});
}
function cjkEncode(text) {
if (text == null) {
return "";
}
var newText = "";
for (var i = 0; i < text.length; i++) {
var code = text.charCodeAt (i);
if (code >= 128 || code == 91 || code == 93) { //91 is "[", 93 is "]".
newText += "[" + code.toString(16) + "]";
} else {
newText += text.charAt(i);
}
}
return newText;
}
/**
* 动态分页按钮
*
* @param tatalre
* @param totalpa
*/
/*function dynamicPage(totalre, totalpa,currentPage) {
$("#total_records").html(totalre);
$("#total_page").html(totalpa);
var pageStart = "";
var pageEnd = "";
if(currentPage<=Math.round(pageNum/2)+1){
pageStart = 1;
pageEnd = pageNum;
}
if(currentPage>Math.round(pageNum/2)+1){
pageStart = currentPage-Math.round(pageNum/2);
pageEnd = currentPage+Math.round(pageNum/2)-2;
}
if(pageEnd>totalpa){
pageEnd = totalpa;
}
var ulcontent = $(".pagination");
ulcontent.children().filter('li').remove();
ulcontent.append("<li> <a onclick=\"jumpPage(0)\" aria-label=\"Previous\">" +
"<span aria-hidden=\"true\">上一页</span></a></li> ");
for(var i=pageStart;i<=pageEnd;i++){
if(i==currentPage){
ulcontent.append("<li class=\"active\"><a onclick=\"pageseach(" + i + ",'')\">"+i+"</a></li>");
}else{
ulcontent.append("<li><a onclick=\"pageseach(" + i + ",'')\">"+i+"</a></li>");
}
}
ulcontent.append("<li> <a onclick=\"jumpPage(1)\" aria-label=\"Next\">" +
"<span aria-hidden=\"true\">下一页</span></a></li> ");
pagging.modifyPagging(totalre, totalpa,currentPage);
}
pagging.config.list=function(pageindex){
pageseach(pageindex);
};
*//**
* 上一页、下一页调转
*
* @param index
*//*
function jumpPage(index) {
var pageindex = 1;
if (index == 0) {// 上一页
pageindex = currentPage - 1 <= 1 ? 1 : currentPage - 1;
} else {
pageindex = currentPage + 1 >= totalpage ? totalpage : currentPage + 1;
}
pageseach(pageindex);
}
*//**
* 点击分页调转
*//*
function pageseach(pageindex){
var searchInput = $("#searchInput").val();
//查询
if(searchInput != "")
loadlist(pageindex,searchInput);
else
loadlist(pageindex,"");
}*/