tasklist_wev8.js
6.07 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
/**
设置任务完成
**/
function setComplete(checkbox,tasklistid){
//包含子任务的计划需确认子任务完成 方可点击完成操作
var childtaskpro = $(checkbox).closest("tr").find(".taskprocessval");
if(childtaskpro.length > 0 && childtaskpro.html() !== '100%'){
changeCheckboxStatus(checkbox,false);
window.top.Dialog.alert("提示:子任务未完全完成!");
return;
}
var msg = "",iscomplete=0;
if(checkbox.checked){
msg = "提示:是否确认完成?";
iscomplete = 1;
}else{
msg = "提示:是否取消完成?";
iscomplete = 0;
}
window.top.Dialog.confirm(msg,function(){
var senddata = {};
senddata["iscomplete"] = iscomplete;
senddata["tasklistid"] = tasklistid;
$.ajax({
type: "POST",
url:"/worktask/pages/taskcomplete.jsp",
dataType:'json',
data:senddata,
success:function(data){
if(data.success === '1'){
//更新进度条
var clotable = $(checkbox).closest("table");
var checklen = clotable.find("input:checked").length;
var checkalllen = clotable.find("input[type='checkbox']").length
var percentage = (checklen*100/checkalllen).toFixed(0)+'%';
var th = clotable.find(".reqprocess").parent();
th.html("<input type='hidden' name='reqpercent' value='"+percentage+"'>");
tasklistviews.generatorReqProcessBar();
window.top.Dialog.alert("数据更新成功!");
}
else
window.top.Dialog.alert("数据操作失败!");
}
});
},function(){
if(checkbox.checked)
changeCheckboxStatus(checkbox,false);
else
changeCheckboxStatus(checkbox,true);
});
}
var tasklistviews = (function($doc,$){
return{
//移除加载图标
removeLoadingItem:function(){
$(".loadingicon").remove();
},
//添加加载图标
addLoadingItem:function(){
var loadingicon = "<div class='loadingicon' > <image src='/express/task/images/loading1_wev8.gif'> </div>";
$(".tasklistspanel").append(loadingicon);
}, generatorPanels:function(reqtasklists){
var reqinfo,reqtasklist,tablestr=[];
if(reqtasklists.length === 0){
$(".tasklistspanel").html("<div class='remindinfo'>"+SystemEnv.getHtmlNoteName(4024,languageid)+"!</div>");
return;
}
//遍历数据集合
for(var i = 0, len = reqtasklists.length; i<len; i++){
reqinfo = reqtasklists[i].requestinfo,
reqtasklist = reqtasklists[i].tasklists;
tablestr.push(this.generatorPanel(reqinfo, reqtasklist));
}
$(".tasklistspanel").html(tablestr.join(""));
this.generatorReqProcessBar();
this.generatorTaskProcessBar();
$(".tasklistspanel").jNice();
//生成一个数据块
},generatorPanel:function(reqinfo,reqtasklist){
var table = [] ,tr ,headcls = '',reqpercent ,reqpercentstr = '' ,finish = 0, ischecked ,isdisabled ,cuid=$("#cuid").val();
//计算该任务百分比
for(var i=0, len=reqtasklist.length; i<len; i++){
if(reqtasklist[i].complete === "1"){
finish++;
}
}
if(reqtasklist.length>0){
reqpercent = (finish*100/reqtasklist.length).toFixed(0)+'%';
reqpercentstr = "<input type='hidden' name='reqpercent' value='"+reqpercent+"'>";
}
table.push("<div class='taskpanel'><table class='tasktable'><colgroup><col width='25%'><col width='25%'><col width='25%'><col width='25%'></colgroup>");
if(reqinfo.status === '8'){
headcls = "class = 'overtimeremind' ";
}
tr = "<thead><tr "+headcls+"><th>"+reqinfo.taskname+"</th><th>"+reqinfo.planenddate+"</th><th>"+reqinfo.liableperson+"</th><th>"+reqpercentstr+"</th></tr></thead>";
table.push(tr);
table.push("<tbody>");
for(var i=0, len=reqtasklist.length; i<len; i++){
ischecked = "",percenstr="" ,isdisabled = "";
if(reqtasklist[i].complete === "1"){
ischecked = "checked = 'checked'";
}
if(~~reqtasklist[i].reqids>0){
var percent = (~~reqtasklist[i].hascomplete*100/~~reqtasklist[i].reqids).toFixed(0)+'%';
percenstr = "<input type='hidden' name='taskpercent' value='"+percent+"'>";
}
if(reqtasklist[i].liableid !== cuid){
isdisabled = "disabled";
}
if(i === len-1)
tr = "<tr class='rowlast'><td><input type='checkbox' onclick='setComplete(this,\""+reqtasklist[i].listid+"\");' "+ischecked+" "+isdisabled+">"+reqtasklist[i].name+"</td><td>"+reqtasklist[i].enddate+"</td><td>"+reqtasklist[i].liableperson+"</td><td>"+percenstr+"</td></tr>"
else
tr = "<tr><td><input type='checkbox' onclick='setComplete(this,\""+reqtasklist[i].listid+"\");' "+ischecked+" "+isdisabled+">"+reqtasklist[i].name+"</td><td>"+reqtasklist[i].enddate+"</td><td>"+reqtasklist[i].liableperson+"</td><td>"+percenstr+"</td></tr>"
table.push(tr);
}
table.push("</tbody>");
table.push("</table></div>");
return table.join("");
//生成进度条
},generatorReqProcessBar:function(){
var reqitems = $("input[name='reqpercent']"), current, th ,processstr="",tpwidth, itemvalue;
for(var i=0,len=reqitems.length;i<len;i++){
current = $(reqitems[i]);
itemvalue = current.val();
th = current.parent();
tpwidth = th.width()-30;
tpwidth = ~~(itemvalue.replace("%",""))*tpwidth/100;
processstr = "<div class='reqprocess' style='width:"+tpwidth+"px;'></div><div class='processval'>"+itemvalue+"</div>";
th.html(processstr);
}
},//生成任务进度条
generatorTaskProcessBar:function(){
var taskitems = $("input[name='taskpercent']"), current, tr ,processstr="",tpwidth, itemvalue;
for(var i=0,len=taskitems.length;i<len;i++){
current = $(taskitems[i]);
itemvalue = current.val();
tr = current.parent();
tpwidth = tr.width()-30;
tpwidth = ~~(itemvalue.replace("%",""))*tpwidth/100;
processstr = "<div class='taskprocess' style='width:"+tpwidth+"px;'></div><div class='taskprocessval'>"+itemvalue+"</div>";
tr.html(processstr);
}
}
}
})(document,jQuery);