deptStaffWorkReport.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. var taskStateReportTable, taskScheduleReportTable, manHourReportTable;
  2. var curTab = 1;
  3. $(function(){
  4. $("#projId").ligerComboBox({slide:false, width:150, initValue:"-1"});
  5. $("#createDateStart").ligerDateEditor({ showTime: false, labelAlign: 'left'});
  6. $("#createDateEnd").ligerDateEditor({ showTime: false, labelAlign: 'left'});
  7. $("#createDate").ligerComboBox({width:150, slide:false, resize:false, onSelected:function(value, text){
  8. if(value != 3){
  9. $("#createDateStartPanel").css("visibility", "hidden");
  10. $("#createDateToPanel").css("visibility", "hidden");
  11. $("#createDateEndPanel").css("visibility", "hidden");
  12. }else{
  13. $("#createDateStartPanel").css("visibility", "visible");
  14. $("#createDateToPanel").css("visibility", "visible");
  15. $("#createDateEndPanel").css("visibility", "visible");
  16. }
  17. }});
  18. $("#staffWorkReportTab").ligerTab({onAfterSelectTabItem:function(tabId){
  19. if(tabId == "tabitem1"){
  20. curTab = 1;
  21. searchReport();
  22. }else if(tabId == "tabitem2"){
  23. curTab = 2;
  24. searchReport();
  25. }else if(tabId == "tabitem3"){
  26. curTab = 3;
  27. searchReport();
  28. }
  29. }});
  30. loadTypeTree("deptBtn",{type:"dept",tab:tab,backId:"deptId",backName:"deptName"});
  31. loadTypeTree("userBtn",{type:"user",tab:tab,backId:"userId",backName:"userName"});
  32. getProjectList();
  33. searchReport();
  34. $("#pageloading").hide();
  35. });
  36. function getParams(){
  37. var deptId = $("#deptId").val();
  38. var projId = $("#projId").val();
  39. var userId = $("#userId").val();
  40. var createDate = $("#createDate").val();
  41. var createDateStart = $.trim($("#createDateStart").val());
  42. var createDateEnd = $.trim($("#createDateEnd").val());
  43. var searchObj = {"deptId":"", "projId":"", "userId":"", "createDate":"", "createDateStart":"", "createDateEnd":"", "error":false, "errorMsg":""};
  44. if(deptId != "" && deptId != -1){
  45. searchObj.deptId = deptId;
  46. }
  47. if(projId != "" && projId != -1){
  48. searchObj.projId = projId;
  49. }
  50. if(userId != ""){
  51. searchObj.userId = userId;
  52. }
  53. if(createDate != ""){
  54. searchObj.createDate = createDate;
  55. }
  56. if(createDateStart != ""){
  57. searchObj.createDateStart = createDateStart;
  58. }
  59. if(createDateEnd != ""){
  60. searchObj.createDateEnd = createDateEnd;
  61. }
  62. //结束时间不可大于起始时间
  63. var start = new Date(createDateStart.replace("-","/"));
  64. var end = new Date(createDateEnd.replace("-","/"));
  65. if(start > end){
  66. alert("结束时间不可大于起始时间")
  67. return;
  68. }
  69. // 针对工时报表的校验
  70. if( (createDateStart == "" || createDateEnd == "") && curTab == 3 && createDate == 3){
  71. searchObj.error = true;
  72. searchObj.errorMsg = "查看工时统计报表时,请设置统计时段";
  73. $.ligerDialog.warn(searchObj.errorMsg+"  ");
  74. }else if(deptId == "" || deptId == -1){
  75. searchObj.error = true;
  76. searchObj.errorMsg = "请先选择部门后,再开始统计报表";
  77. $.ligerDialog.warn(searchObj.errorMsg+"  ");
  78. }
  79. return searchObj;
  80. }
  81. function getProjectList(){
  82. var deptId = $("#deptId").val();
  83. if(deptId && deptId != "-1"){
  84. var projId = document.getElementById("projId");
  85. projId.options.length = 0;
  86. addSelectOption(projId, " ", "-1");
  87. addSelectOption(projId, "非项目", "0");
  88. projId.value = "-1";
  89. $.ajax({
  90. type:"post",
  91. url:"StaffWorkReportAction.do?task=getProjectList&time=" + new Date().getTime(),
  92. data:{"deptId":deptId} ,
  93. timeout:20000,
  94. cache:false,
  95. dataType:"json",
  96. success:function(data){
  97. if(data.error){
  98. showAjaxError(data.error);
  99. return;
  100. }
  101. var projectList = data.success;
  102. for(var i = 0; i < projectList.length; i++){
  103. addSelectOption(projId, projectList[i].proj_name, projectList[i].universalid);
  104. }
  105. },
  106. error:function(err){
  107. showAjaxError(err);
  108. },
  109. complete:function(msg,err){
  110. $(projId).ligerGetComboBoxManager().setSelect();
  111. }
  112. });
  113. }
  114. }
  115. function initTaskStateReportTable(params){
  116. if(!params){
  117. params = {};
  118. }
  119. if(taskStateReportTable == undefined){
  120. taskStateReportTable = $("#taskStateReport").ligerGrid({
  121. columns: [
  122. { display: '姓名', name: 'userName', align: 'center', minWidth: 120,
  123. render: function (row) {
  124. var html = '<a href="#" onclick="seeUser(' + row.userId + ')">' + row.userName + '</a>';
  125. return html;
  126. }
  127. },
  128. { display: '未接收', name: 'unreceiveTaskCount', align: 'center', width: 100 },
  129. { display: '进行中', name: 'progressTaskCount', align: 'center', width: 100 },
  130. { display: '中断', name: 'stopTaskCount', align: 'center', width: 100 },
  131. { display: '推迟', name: 'postponeTaskCount', align: 'center', width: 100 },
  132. { display: '驳回', name: 'rejectTaskCount', align: 'center', width: 100 },
  133. { display: '待审', name: 'pendingTaskCount', align: 'center', width: 100 },
  134. { display: '完成', name: 'finishTaskCount', align: 'center', width: 100 },
  135. { display: '任务合计', name: 'taskCount', align: 'center', width: 120 }
  136. ],
  137. pageSize:50,
  138. url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=1&type=1&time=' + new Date().getTime(),
  139. parms : params,
  140. pageParmName: 'curPage',
  141. pagesizeParmName: 'pageSize',
  142. width: '100%',
  143. height: '99%',
  144. rownumbers:true,
  145. enabledSort:false,
  146. method:"post",
  147. // delayLoad:true,
  148. onAfterShowData:function(data){
  149. showMsg(data);
  150. refreshBtn(false);
  151. },
  152. onError:function(err){
  153. alert("获取数据失败,请刷新页面后重试!");
  154. refreshBtn(false);
  155. }
  156. });
  157. }else{
  158. taskStateReportTable._setParms(params);
  159. taskStateReportTable.loadData();
  160. }
  161. }
  162. function initTaskScheduleReportTable(params){
  163. if(!params){
  164. params={};
  165. }
  166. if(taskScheduleReportTable == undefined){
  167. taskScheduleReportTable = $("#taskScheduleReport").ligerGrid({
  168. columns: [
  169. { display: '姓名', name: 'userName', align: 'center', minWidth: 120 ,
  170. render: function (row) {
  171. var html = '<a href="#" onclick="seeUser(' + row.userId + ')">' + row.userName + '</a>';
  172. return html;
  173. }
  174. },
  175. { display: '正常进行中的任务', name: 'normalInProgressTaskCount', align: 'center', width: 130 },
  176. { display: '已延期的任务', name: 'postponeInProgressTaskCount', align: 'center', width: 130 },
  177. { display: '延期完成的任务', name: 'postponeFinishTaskCount', align: 'center', width: 130 },
  178. { display: '按时完成的任务', name: 'onScheduleFinishTaskCount', align: 'center', width: 130 },
  179. { display: '提前完成的任务', name: 'aheadFinishTaskCount', align: 'center', width: 130 },
  180. { display: '任务合计', name: 'taskCount', align: 'center', width: 120 },
  181. { display: '任务正常执行率', name: 'normalTaskRate2Display', align: 'center', width: 120 }
  182. ],
  183. pageSize:50,
  184. url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=2&type=1&time=' + new Date().getTime(),
  185. parms : params,
  186. pageParmName: 'curPage',
  187. pagesizeParmName: 'pageSize',
  188. width: '100%',
  189. height: '99%',
  190. rownumbers:true,
  191. enabledSort:false,
  192. method:"post",
  193. // delayLoad:true,
  194. onAfterShowData:function(data){
  195. showMsg(data);
  196. refreshBtn(false);
  197. },
  198. onError:function(){
  199. alert("获取数据失败,请刷新页面后重试!");
  200. refreshBtn(false);
  201. }
  202. });
  203. }else{
  204. taskScheduleReportTable._setParms(params);
  205. taskScheduleReportTable.loadData();
  206. }
  207. }
  208. function initManHourReportTable(params){
  209. if(!params){
  210. params = {};
  211. }
  212. if(manHourReportTable == undefined){
  213. manHourReportTable = $("#manHourReport").ligerGrid({
  214. columns: [
  215. { display: '姓名', name: 'userName', align: 'center', minWidth: 150 ,
  216. render: function (row) {
  217. var html = '<a href="#" onclick="seeUser(' + row.userId + ')">' + row.userName + '</a>';
  218. return html;
  219. }
  220. },
  221. { display: '已报工时', name: 'pracTotalManHour', align: 'center', width: 250 },
  222. { display: '应报工时(仅供参考,包含节假日)', name: 'planTotalManHour', align: 'center', width: 250 },
  223. { display: '工时差', name: 'offsetManHour', align: 'center', width: 250 }
  224. ], pageSize:50,
  225. url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=3&type=1&time=' + new Date().getTime(),
  226. parms : params,
  227. pageParmName: 'curPage',
  228. pagesizeParmName: 'pageSize',
  229. width: '100%',
  230. height: '99%',
  231. rownumbers:true,
  232. enabledSort:false,
  233. method:"post",
  234. // delayLoad:true,
  235. onAfterShowData:function(data){
  236. showMsg(data);
  237. refreshBtn(false);
  238. },
  239. onError:function(){
  240. alert("获取数据失败,请刷新页面后重试!");
  241. refreshBtn(false);
  242. }
  243. });
  244. }else{
  245. manHourReportTable._setParms(params);
  246. manHourReportTable.loadData();
  247. }
  248. }
  249. /**
  250. * 查询当前报表
  251. * @param delayLoad 初始化是是否不加载
  252. */
  253. function searchReport(){
  254. var params = getParams();
  255. if(!params.error){
  256. refreshBtn(true);
  257. switch(curTab){
  258. case 1 : initTaskStateReportTable(params);break;
  259. case 2 : initTaskScheduleReportTable(params);break;
  260. case 3 : initManHourReportTable(params);break;
  261. }
  262. }
  263. }
  264. function exportExcel(){
  265. var params = getParams();
  266. if(!params.error){
  267. var curTable = getReportTable();
  268. if(curTable != null){
  269. refreshBtn(true);
  270. var pageSize = curTable.ligerGetGridManager().get("pageSize");
  271. var page = curTable.ligerGetGridManager().get("page");
  272. var action = "StaffWorkReportAction.do?task=deptStaffWorkReport";
  273. action = action + "&report=" + curTab +"&type=2&pageSize="+ pageSize + "&curPage=" + page + convertJson2UrlParams(params);
  274. $("#exportExcelForm").attr("action", action).submit();
  275. refreshBtn(false);
  276. }
  277. }
  278. }
  279. /** 获取表格对象
  280. *@param tabId[int][可不传,为空时取得当前处于显示状态的表格对象,传入参数时,根据tabId获取表格对象]
  281. *@return ligerUi创建的表格对象
  282. ***/
  283. function getReportTable(tabId){
  284. var obj = null;
  285. if(!tabId){
  286. tabId = curTab;
  287. }
  288. switch(tabId){
  289. case 1 : obj = $("#taskStateReport"); break;
  290. case 2 : obj = $("#taskScheduleReport"); break;
  291. case 3 : obj = $("#manHourReport"); break;
  292. default : obj = null; break;
  293. }
  294. return obj;
  295. }
  296. function showMsg(data){
  297. if(data == undefined || data.Rows.length == 0){
  298. var obj = getReportTable();
  299. obj.find("div[class*='l-grid-body-inner']:last").next().html("<div style='padding-top:50px;width:100%;text-align:center'>没有相关统计数据……</div>");
  300. }
  301. }
  302. function refreshBtn(isDisabled){
  303. $("input[type='button']").each(function(){
  304. this.disabled = isDisabled;
  305. });
  306. }