ListView.jsp
19.3 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
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/page/maint/common/initNoCache.jsp" %>
<%@ page import="java.net.URLDecoder"%>
<%@ page import="weaver.general.TimeUtil"%>
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page"/>
<%
String userid = user.getUID()+"";
String principalid = userid;
String basesql = "";
String func1 = "";
String operatedt = "";
String createdt = "";
if("sqlserver".equals(rs.getDBType())){
func1 = "isnull";
operatedt = "max(operatedate+' '+operatetime)";
createdt = "max(createdate+' '+createtime)";
}else if("mysql".equals(rs.getDBType())){
func1 = "IFNULL";
operatedt = "max(CONCAT(operatedate,' ',operatetime))";
createdt = "max(CONCAT(createdate,' ',createtime))";
}else{
func1 = "nvl";
operatedt = "max(CONCAT(CONCAT(operatedate,' '),operatetime))";
createdt = "max(CONCAT(CONCAT(createdate,' '),createtime))";
}
basesql = " t1.id,t1.name,t1.status,t1.creater,t1.principalid,t1.lev,t1.begindate,t1.enddate,t1.createdate,t1.createtime,t1.showallsub "
+",(select count(tfb.id) from TM_TaskFeedback tfb where tfb.taskid=t1.id) as fbcount"
+",(select "+operatedt+" from TM_TaskLog tlog where tlog.taskid=t1.id and tlog.type=0 and tlog.operator="+userid+") as lastviewdate"
+",(select "+createdt+" from TM_TaskFeedback fb where fb.taskid=t1.id and fb.hrmid<>"+userid+") as lastfbdate"
+","+func1+"((select distinct 1 from TM_TaskSpecial tts where tts.taskid=t1.id and tts.userid="+userid+"),0) as special"
+",(select max(tt.tododate) from TM_TaskTodo tt where tt.taskid=t1.id and tt.userid="+user.getUID()+") as tododate"
+",(select "+operatedt+" from TM_TaskLog tlog where tlog.taskid=t1.id and tlog.type not in (0,11,12)) as lastoperatedate"
+" from TM_TaskInfo t1 "
+" where (t1.deleted=0 or t1.deleted is null)";
String countsql = "select count(t1.id) as amount from TM_TaskInfo t1 where (t1.deleted=0 or t1.deleted is null)";
String typewhere = "";
StringBuffer sqlwhere = new StringBuffer();
//String orderby = " order by lastoperatedate desc";
String currentdate = TimeUtil.getCurrentDateString();
int sorttype = Util.getIntValue(request.getParameter("sorttype"),2);//分类排序类型
int status = Util.getIntValue(request.getParameter("status"),1);
if(sorttype==5) status=1;//Todolist视图是显示进行中
//String datatype = Util.null2String(request.getParameter("datatype"));
String condtype = Util.null2String(request.getParameter("condtype"));
int hrmid = Util.getIntValue(request.getParameter("hrmid"),0);
String tag = Util.null2String(URLDecoder.decode(request.getParameter("tag"),"utf-8"));
if(condtype.equals("7")){
status=2;//新完成的任务 状态为完成
sorttype=1;//列表展示
}
if(condtype.equals("1")){//本人相关的任务
sqlwhere.append(" and (t1.principalid="+userid//+" or t1.creater="+userid
+ " or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+userid+"))");
}else if(condtype.equals("2")){//本人创建的任务
sqlwhere.append(" and t1.creater="+userid);
}else if(condtype.equals("3")){//本人负责的任务
sqlwhere.append(" and t1.principalid="+userid);
}else if(condtype.equals("4")){//本人参与的任务
sqlwhere.append(" and exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+userid+")");
}else if(condtype.equals("5")){//被分享的任务
sqlwhere.append(" and exists (select 1 from TM_TaskSharer ts where ts.taskid=t1.id and ts.sharerid="+userid+")");
}else if(condtype.equals("6")){//标记关注的任务
sqlwhere.append(" and exists (select 1 from TM_TaskSpecial special where special.taskid=t1.id and special.userid="+userid+")");
}else if(condtype.equals("7")){//已完成新反馈的任务
sqlwhere.append(" and t1.status=2 and (t1.principalid="+user.getUID()+" or t1.creater="+user.getUID()
+ " or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+user.getUID()+")"
+ " or exists (select 1 from TM_TaskSharer ts where ts.taskid=t1.id and ts.sharerid="+user.getUID()+")"
+ " or exists (select 1 from TM_TaskSpecial special where special.taskid=t1.id and special.userid="+userid+")"
+ ")");
sqlwhere.append(" and ("+func1+"((select "+createdt+" from TM_TaskFeedback t3 where t3.taskid=t1.id and t3.hrmid<>"+userid+"),'')"
+">"+func1+"((select "+operatedt+" from TM_TaskLog t2 where t2.taskid=t1.id and t2.type=0 and t2.operator="+userid+"),''))");
}else if(condtype.equals("8")){//我分配的任务
sqlwhere.append(" and t1.creater="+userid+" and t1.principalid<>"+userid);
}else{//能查看的所有任务
sqlwhere.append(" and (t1.principalid="+user.getUID()+" or t1.creater="+user.getUID()
+ " or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+user.getUID()+")"
+ " or exists (select 1 from TM_TaskSharer ts where ts.taskid=t1.id and ts.sharerid="+user.getUID()+")"
+ " or exists (select 1 from HrmResource hrm where (hrm.id=t1.principalid or hrm.id=t1.creater) and hrm.managerstr like '%,"+user.getUID()+",%')"
+ " or exists (select 1 from HrmResource hrm,TM_TaskPartner tp where tp.taskid=t1.id and hrm.id=tp.partnerid and hrm.managerstr like '%,"+user.getUID()+",%')"
+ ")");
if(hrmid!=0&&hrmid!=user.getUID()){
principalid = hrmid + "";
sqlwhere.append(" and (t1.principalid="+hrmid //+" or t1.creater="+hrmid
+ " or exists (select 1 from TM_TaskPartner tp where tp.taskid=t1.id and tp.partnerid="+hrmid+"))");
}
if(!tag.equals("")){
sqlwhere.append(" and t1.tag like '%,"+tag+",%'");
}
}
if(status!=0) sqlwhere.append(" and t1.status="+status);
if(sorttype==4) sqlwhere.append(" and (t1.parentid='' or t1.parentid is null)");
int index = 0;
int _pagesize = 10;
int _total = 0;//总数
%>
<style type="text/css">
<%if(sorttype!=0){%>
.td_drag{cursor: move !important;}
.tr_hover .td_drag{background: url('../images/sprite.png') no-repeat -97px -748px;background-color: #F9F9F9 !important;}
.tr_hover .td_move,.tr_hover .td_blank{background-color: #F9F9F9 !important;border-right-color: #F9F9F9;border-top-color: #fff !important;}
.tr_hover .td_drag div{display: none;}
.tr_select .td_drag{background: url('../images/sprite.png') no-repeat -97px -748px;background-color: #CEE4FF !important;border-right-color: #CEE4FF;border-top-color: #fff !important;border-bottom-color: #75B4FF !important;}
.tr_select .td_move,.tr_select .td_blank{background-color: #CEE4FF !important;border-right-color: #CEE4FF;border-top-color: #fff !important;border-bottom-color: #75B4FF !important;}
.tr_select .td_drag div{display: none;}
.tr_select div.status1{background: url('../images/ing.png') center no-repeat;}
<%}%>
</style>
<div id="listscroll" class="scroll1" style="width: 100%;height:100%;position: relative;top: 0px;left: 0px;background: url('../images/line.png') left repeat-y;">
<%
String[] datetype = {""};
String[] datetitle = {""};
String titlecolor = "";
_pagesize = 20;
if(sorttype==1){//列表
_pagesize = 30;
}else if(sorttype==2){//到日期
datetype = new String[]{SystemEnv.getHtmlLabelName(382510,user.getLanguage()),SystemEnv.getHtmlLabelName(382511,user.getLanguage()),SystemEnv.getHtmlLabelName(382512,user.getLanguage()),SystemEnv.getHtmlLabelName(382513,user.getLanguage()),SystemEnv.getHtmlLabelName(382514,user.getLanguage())};
datetitle = new String[]{SystemEnv.getHtmlLabelName(382515,user.getLanguage()),SystemEnv.getHtmlLabelName(382516,user.getLanguage()),SystemEnv.getHtmlLabelName(382517,user.getLanguage()),SystemEnv.getHtmlLabelName(382518,user.getLanguage()),SystemEnv.getHtmlLabelName(382520,user.getLanguage())};
titlecolor = "#008040";
}else if(sorttype==3){//紧急程度
datetype = new String[]{SystemEnv.getHtmlLabelName(382501,user.getLanguage()),SystemEnv.getHtmlLabelName(382502,user.getLanguage()),SystemEnv.getHtmlLabelName(382503,user.getLanguage()),SystemEnv.getHtmlLabelName(382504,user.getLanguage()),SystemEnv.getHtmlLabelName(15808,user.getLanguage())};
datetitle = new String[]{SystemEnv.getHtmlLabelName(382523,user.getLanguage()),SystemEnv.getHtmlLabelName(382524,user.getLanguage()),SystemEnv.getHtmlLabelName(382525,user.getLanguage()),SystemEnv.getHtmlLabelName(382526,user.getLanguage()),SystemEnv.getHtmlLabelName(382527,user.getLanguage())};
}else if(sorttype==4){//层级
_pagesize = 10;
}else if(sorttype==5){//Todolist
datetype = new String[]{SystemEnv.getHtmlLabelName(15537,user.getLanguage()),SystemEnv.getHtmlLabelName(22488,user.getLanguage()),SystemEnv.getHtmlLabelName(382509,user.getLanguage()),SystemEnv.getHtmlLabelName(382499,user.getLanguage()),SystemEnv.getHtmlLabelName(382498,user.getLanguage())};
datetitle = new String[]{SystemEnv.getHtmlLabelName(382528,user.getLanguage()),SystemEnv.getHtmlLabelName(382529,user.getLanguage()),SystemEnv.getHtmlLabelName(382530,user.getLanguage()),SystemEnv.getHtmlLabelName(382531,user.getLanguage()),SystemEnv.getHtmlLabelName(382532,user.getLanguage())};
titlecolor = "blue";
}
for(int i=0;i<datetype.length;i++){
%>
<%if(datetype.length>1){ %>
<div id="sorttitle<%=i %>" class="sorttitle" style="<%=(!titlecolor.equals("")?"color:"+titlecolor:"") %>" title="<%=SystemEnv.getHtmlLabelName(382533,user.getLanguage()) %>"><div class="sorticon"></div><div class="sorthead" title="<%=datetitle[i] %>"><%=datetype[i] %></div><div class="sortmore">...</div></div>
<%} %>
<table id="datalist<%=i %>" class="datalist" cellpadding="0" cellspacing="0" border="0" _datetype="<%=i+1%>">
<tr class="tr_blank">
<td style="width: 23px;background: #EFEFEF;"></td><td style="width: 20px;"></td><td></td>
<td style="width: 22px;"></td><td style="width: 44px;"></td><td style="width: 44px;"></td>
</tr>
<tr class="tr_blank">
<td style="width: 23px;background: #EFEFEF;"></td><td style="width: 20px;"></td><td></td>
<td style="width: 22px;"></td><td style="width: 44px;"></td><td style="width: 44px;"></td>
</tr>
<%
if(sorttype==1){//列表
_pagesize = 30;
}else if(sorttype==2){//到日期
if(i==0){
typewhere = " and "+(("sqlserver".equals(rs.getDBType()))?"t1.enddate<>'' and ":"")+" t1.enddate is not null and t1.enddate<'"+currentdate+"'";
}else if(i==1){
typewhere = " and t1.enddate='"+currentdate+"'";
}else if(i==2){
typewhere = " and t1.enddate='"+TimeUtil.dateAdd(currentdate,1)+"'";
}else if(i==3){
typewhere = " and "+(("sqlserver".equals(rs.getDBType()))?"t1.enddate<>'' and ":"")+" t1.enddate is not null and t1.enddate>'"+TimeUtil.dateAdd(currentdate,1)+"'";
}else{
typewhere = " and (t1.enddate='' or t1.enddate is null)";
}
}else if(sorttype==3){//紧急程度
if(i==4){
typewhere = " and (t1.lev=0 or t1.lev is null)";
}else{
typewhere = " and t1.lev="+(i+1);
}
}else if(sorttype==4){//层级
_pagesize = 10;
}else if(sorttype==5){//Todolist
if(i==0){
typewhere = " and exists(select 1 from TM_TaskTodo tt where tt.taskid=t1.id and tt.tododate<>'1' and tt.userid="+principalid+" and tt.tododate<='"+currentdate+"')";
}else if(i==1){
typewhere = " and exists(select 1 from TM_TaskTodo tt where tt.taskid=t1.id and tt.tododate<>'1' and tt.userid="+principalid+" and tt.tododate='"+TimeUtil.dateAdd(currentdate,1)+"')";
}else if(i==2){
typewhere = " and exists(select 1 from TM_TaskTodo tt where tt.taskid=t1.id and tt.tododate<>'1' and tt.userid="+principalid+" and tt.tododate>'"+TimeUtil.dateAdd(currentdate,1)+"')";
}else if(i==3){
typewhere = " and not exists(select 1 from TM_TaskTodo tt where tt.taskid=t1.id and tt.userid="+principalid+")";
}else if(i==4){
typewhere = " and exists(select 1 from TM_TaskTodo tt where tt.taskid=t1.id and tt.tododate='1' and tt.userid="+principalid+")";
}
}
rs.executeSql(countsql+sqlwhere.toString()+typewhere);
if(rs.next()){
_total = rs.getInt(1);
}
%>
<tr id="" class='item_tr item_tr_blank' _taskid="" <%if(_total>0){ %>style="display: none;"<%} %>>
<td class="td_blank"><div> </div></td>
<td width='20px'>
<div id='' class='status' _taskid='' _status='1' title='' onclick='changestatus(this)'> </div>
<div id='' class="div_todo" style='display:none' onclick='showTodo2(this)' title='' _val='' _taskid=''> </div>
</td>
<td class='item_td'><input onfocus='doClickItem(this)' onblur='doBlurItem(this)' class='disinput addinput definput' type='text' name='' value='<%=SystemEnv.getHtmlLabelName(15266,user.getLanguage()) %>' id='' _index="<%=index++ %>"/></td>
<td class='item_count'> </td>
<td style="text-align: center;"><div id="" class="div_enddate" title=''> </div></td>
<td class='item_hrm'> </td>
</tr>
</table>
<%
if(_total>0){
request.getSession().setAttribute("TM_LIST_SQL_"+i,basesql+sqlwhere.toString()+typewhere);
request.getSession().setAttribute("TM_COUNT_SQL_"+i,countsql+sqlwhere.toString()+typewhere);
%>
<div id="listmore<%=i+1 %>" class="listmore" onclick="getListMore(this)" _datalist="datalist<%=i %>" _currentpage="0" _pagesize="<%=_pagesize %>" _total="<%=_total %>" _index="<%=i %>" _excludeids="" title="<%=SystemEnv.getHtmlLabelName(83704,user.getLanguage()) %>"><%=SystemEnv.getHtmlLabelName(131654,user.getLanguage()) %></div>
<script type="text/javascript">getListMore("#listmore<%=i+1 %>")</script>
<% } %>
<%
}
%>
<div style="width: 100%;height: 30px;overflow: hidden;"></div>
</div>
<div id="floattitle" _index="" class="dtitle" onclick="showtitle()" style="position: absolute;top: 0px;left: 0px;display: none;background: #FCFCFC;">
<div class="sorticon" style="background: none;"></div><div id="floathead" class="sorthead" style="<%=(!titlecolor.equals("")?"color:"+titlecolor:"") %>" title=""></div>
</div>
<%
//zhw 20140916 增加记住视图
int viewId = Util.getIntValue(request.getParameter("viewId"),0);
int taskId = Util.getIntValue(request.getParameter("taskid"),0);
String viewdate = TimeUtil.getCurrentTimeString();
String sql = "";
if(viewId==0){//数据库没有记录
sql = "insert into TM_TaskView (userid,menutype,listtype,status,viewdate,taskid,seltag,subuserid) values"
+" ("+userid+","+condtype+","+sorttype+","+status+",'"+viewdate+"',"+taskId+",'',"+hrmid+")";
}else{
sql = "update TM_TaskView set menutype="+condtype+",listtype="+sorttype+",status="
+status+",viewdate='"+viewdate+"',subuserid="+hrmid+",taskid="+taskId+" where id="+viewId;
}
rs.execute(sql);
if(viewId==0){
rs.execute("select id from TM_TaskView where userid="+user.getUID());
if(rs.next()){
viewId = rs.getInt("id");
}
}
%>
<script type="text/javascript">
var searchstatus = "<%=status%>";
var sorttype = "<%=sorttype%>";
var index = <%=index++%>;
principalid = "<%=principalid%>";
tag = "<%=tag%>";
viewId = <%=viewId%>;
//初始绑定事件
$(document).ready(function(){
if(sorttype!=0){
$("table.datalist").dragsort({
itemSelector: "tr",
dragSelector: ".td_drag",
dragBetween: true,
dragStart: function(){
//$(this).find(".disinput").blur();
olddatetype = $(this).parent().parent().attr("_datetype");
},
dragStart:function(){
$("div.operatediv").hide();
dragstatus=1;
},
dragEnd: function(){
dragstatus=0;
if(sorttype==2 || sorttype==3 || sorttype==5){
var dragobj = $(this).find("input.disinput");
var newdatetype = $(this).parent().parent().attr("_datetype");
var dragid = dragobj.attr("id");
if(olddatetype!=newdatetype){
$.ajax({
type: "post",
url: "/workrelate/task/data/Operation.jsp",
data:{"operation":"edit_field","taskId":dragid,"fieldname":sorttype,"fieldvalue":newdatetype},
contentType : "application/x-www-form-urlencoded;charset=UTF-8",
complete: function(data){
if(dragobj.attr("id")==detailid){
refreshDetail(dragobj.attr("id"));
}
}
});
//更改紧急程度时重置图标
if(sorttype==3){
if(newdatetype>4) newdatetype = 0;
$("#level_"+dragid).css("background","url('../images/level_0"+newdatetype+".png') center no-repeat").attr("title",leveltitle[newdatetype]);
}
//设置到期日
if(sorttype==2){
var enddate = "";
if(newdatetype==1){
enddate = yesterday;
}else if(newdatetype==2){
enddate = currentdate;
}else if(newdatetype==3){
enddate = tomorrow;
}else if(newdatetype==4){
enddate = nextweek;
}
$("#enddate_"+dragid).html(convertdate(enddate)).attr("title",enddate);
}
//更改标todo记
if(sorttype==5){
var todoname = "<%=SystemEnv.getHtmlLabelName(382534,user.getLanguage()) %>";
if(newdatetype==1){
todoname = "<%=SystemEnv.getHtmlLabelName(15537,user.getLanguage()) %>";
}else if(newdatetype==2){
todoname = "<%=SystemEnv.getHtmlLabelName(22488,user.getLanguage()) %>";
}else if(newdatetype==3){
todoname = "<%=SystemEnv.getHtmlLabelName(382509,user.getLanguage()) %>";
}
$("#todo_"+dragid).attr("_val",newdatetype).attr("title",todoname);
}
//设置读取更多数据时排除的ID
$("#listmore"+newdatetype).attr("_excludeids",$("#listmore"+newdatetype).attr("_excludeids")+dragid+",");
}
}
setIndex();//重置序号
},
placeHolderTemplate: "<tr><td style='width:15px'></td><td style='width:20px'></td><td style=''></td></tr>",
scrollSpeed: 5
});
}
$("div.sorttitle").bind("click",function(){
if($(this).nextAll("table:first").css("display")=="none"){
$(this).nextAll("table:first").show().next("div.listicon").show().next("div.listmore").show();
$(this).attr("title","<%=SystemEnv.getHtmlLabelName(382533,user.getLanguage()) %>");
$(this).find("div.sortmore").hide();
$(this).nextAll("div.listmore:first").show();
}else{
$(this).nextAll("table:first").hide().next("div.listicon").hide().next("div.listmore").hide();
$(this).attr("title","<%=SystemEnv.getHtmlLabelName(84396,user.getLanguage()) %>");
$(this).find("div.sortmore").show();
$(this).nextAll("div.listmore:first").hide();
}
});
/**
$("div.listmore").bind("mouseover",function(){
$(this).addClass("listmore_hover");
}).bind("mouseout",function(){
$(this).removeClass("listmore_hover");
});*/
$('#listscroll').perfectScrollbar({"wheelSpeed": 40});
$("#listscroll").scroll(function(){
if($('#ltodopanel').css("display")=="block"){
$('#ltodopanel').hide();
//var todotaskid = $('#ltodopanel').attr("_taskid");
//showTodo2($("#todo_"+todotaskid));
}
<%if(datetype.length>1){%>
//var scrollh = $(this).scrollTop();
//$("#floattitle").css("top",scrollh);
var tp = 0;
for(var i=<%=datetype.length%>-1;i>-1;i--){
if(tp>=0){
tp = $("#sorttitle"+i).position().top;
if(tp<0){
$("#floathead").html($("#sorttitle"+i).children("div.sorthead").html());
$("#floattitle").attr("_index",i).show();
}
}
}
if(tp>=0) $("#floattitle").hide();
<%}%>
});
setIndex();
});
</script>