var taskStateReportTable, taskScheduleReportTable, manHourReportTable; var curTab = 1; $(function(){ $("#projId").ligerComboBox({slide:false, width:150, initValue:"-1"}); $("#createDateStart").ligerDateEditor({ showTime: false, labelAlign: 'left'}); $("#createDateEnd").ligerDateEditor({ showTime: false, labelAlign: 'left'}); $("#createDate").ligerComboBox({width:150, slide:false, resize:false, onSelected:function(value, text){ if(value != 3){ $("#createDateStartPanel").css("visibility", "hidden"); $("#createDateToPanel").css("visibility", "hidden"); $("#createDateEndPanel").css("visibility", "hidden"); }else{ $("#createDateStartPanel").css("visibility", "visible"); $("#createDateToPanel").css("visibility", "visible"); $("#createDateEndPanel").css("visibility", "visible"); } }}); $("#staffWorkReportTab").ligerTab({onAfterSelectTabItem:function(tabId){ if(tabId == "tabitem1"){ curTab = 1; searchReport(); }else if(tabId == "tabitem2"){ curTab = 2; searchReport(); }else if(tabId == "tabitem3"){ curTab = 3; searchReport(); } }}); loadTypeTree("deptBtn",{type:"dept",tab:tab,backId:"deptId",backName:"deptName"}); loadTypeTree("userBtn",{type:"user",tab:tab,backId:"userId",backName:"userName"}); getProjectList(); searchReport(); $("#pageloading").hide(); }); function getParams(){ var deptId = $("#deptId").val(); var projId = $("#projId").val(); var userId = $("#userId").val(); var createDate = $("#createDate").val(); var createDateStart = $.trim($("#createDateStart").val()); var createDateEnd = $.trim($("#createDateEnd").val()); var searchObj = {"deptId":"", "projId":"", "userId":"", "createDate":"", "createDateStart":"", "createDateEnd":"", "error":false, "errorMsg":""}; if(deptId != "" && deptId != -1){ searchObj.deptId = deptId; } if(projId != "" && projId != -1){ searchObj.projId = projId; } if(userId != ""){ searchObj.userId = userId; } if(createDate != ""){ searchObj.createDate = createDate; } if(createDateStart != ""){ searchObj.createDateStart = createDateStart; } if(createDateEnd != ""){ searchObj.createDateEnd = createDateEnd; } //结束时间不可大于起始时间 var start = new Date(createDateStart.replace("-","/")); var end = new Date(createDateEnd.replace("-","/")); if(start > end){ alert("结束时间不可大于起始时间") return; } // 针对工时报表的校验 if( (createDateStart == "" || createDateEnd == "") && curTab == 3 && createDate == 3){ searchObj.error = true; searchObj.errorMsg = "查看工时统计报表时,请设置统计时段"; $.ligerDialog.warn(searchObj.errorMsg+" "); }else if(deptId == "" || deptId == -1){ searchObj.error = true; searchObj.errorMsg = "请先选择部门后,再开始统计报表"; $.ligerDialog.warn(searchObj.errorMsg+" "); } return searchObj; } function getProjectList(){ var deptId = $("#deptId").val(); if(deptId && deptId != "-1"){ var projId = document.getElementById("projId"); projId.options.length = 0; addSelectOption(projId, " ", "-1"); addSelectOption(projId, "非项目", "0"); projId.value = "-1"; $.ajax({ type:"post", url:"StaffWorkReportAction.do?task=getProjectList&time=" + new Date().getTime(), data:{"deptId":deptId} , timeout:20000, cache:false, dataType:"json", success:function(data){ if(data.error){ showAjaxError(data.error); return; } var projectList = data.success; for(var i = 0; i < projectList.length; i++){ addSelectOption(projId, projectList[i].proj_name, projectList[i].universalid); } }, error:function(err){ showAjaxError(err); }, complete:function(msg,err){ $(projId).ligerGetComboBoxManager().setSelect(); } }); } } function initTaskStateReportTable(params){ if(!params){ params = {}; } if(taskStateReportTable == undefined){ taskStateReportTable = $("#taskStateReport").ligerGrid({ columns: [ { display: '姓名', name: 'userName', align: 'center', minWidth: 120, render: function (row) { var html = '' + row.userName + ''; return html; } }, { display: '未接收', name: 'unreceiveTaskCount', align: 'center', width: 100 }, { display: '进行中', name: 'progressTaskCount', align: 'center', width: 100 }, { display: '中断', name: 'stopTaskCount', align: 'center', width: 100 }, { display: '推迟', name: 'postponeTaskCount', align: 'center', width: 100 }, { display: '驳回', name: 'rejectTaskCount', align: 'center', width: 100 }, { display: '待审', name: 'pendingTaskCount', align: 'center', width: 100 }, { display: '完成', name: 'finishTaskCount', align: 'center', width: 100 }, { display: '任务合计', name: 'taskCount', align: 'center', width: 120 } ], pageSize:50, url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=1&type=1&time=' + new Date().getTime(), parms : params, pageParmName: 'curPage', pagesizeParmName: 'pageSize', width: '100%', height: '99%', rownumbers:true, enabledSort:false, method:"post", // delayLoad:true, onAfterShowData:function(data){ showMsg(data); refreshBtn(false); }, onError:function(err){ alert("获取数据失败,请刷新页面后重试!"); refreshBtn(false); } }); }else{ taskStateReportTable._setParms(params); taskStateReportTable.loadData(); } } function initTaskScheduleReportTable(params){ if(!params){ params={}; } if(taskScheduleReportTable == undefined){ taskScheduleReportTable = $("#taskScheduleReport").ligerGrid({ columns: [ { display: '姓名', name: 'userName', align: 'center', minWidth: 120 , render: function (row) { var html = '' + row.userName + ''; return html; } }, { display: '正常进行中的任务', name: 'normalInProgressTaskCount', align: 'center', width: 130 }, { display: '已延期的任务', name: 'postponeInProgressTaskCount', align: 'center', width: 130 }, { display: '延期完成的任务', name: 'postponeFinishTaskCount', align: 'center', width: 130 }, { display: '按时完成的任务', name: 'onScheduleFinishTaskCount', align: 'center', width: 130 }, { display: '提前完成的任务', name: 'aheadFinishTaskCount', align: 'center', width: 130 }, { display: '任务合计', name: 'taskCount', align: 'center', width: 120 }, { display: '任务正常执行率', name: 'normalTaskRate2Display', align: 'center', width: 120 } ], pageSize:50, url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=2&type=1&time=' + new Date().getTime(), parms : params, pageParmName: 'curPage', pagesizeParmName: 'pageSize', width: '100%', height: '99%', rownumbers:true, enabledSort:false, method:"post", // delayLoad:true, onAfterShowData:function(data){ showMsg(data); refreshBtn(false); }, onError:function(){ alert("获取数据失败,请刷新页面后重试!"); refreshBtn(false); } }); }else{ taskScheduleReportTable._setParms(params); taskScheduleReportTable.loadData(); } } function initManHourReportTable(params){ if(!params){ params = {}; } if(manHourReportTable == undefined){ manHourReportTable = $("#manHourReport").ligerGrid({ columns: [ { display: '姓名', name: 'userName', align: 'center', minWidth: 150 , render: function (row) { var html = '' + row.userName + ''; return html; } }, { display: '已报工时', name: 'pracTotalManHour', align: 'center', width: 250 }, { display: '应报工时(仅供参考,包含节假日)', name: 'planTotalManHour', align: 'center', width: 250 }, { display: '工时差', name: 'offsetManHour', align: 'center', width: 250 } ], pageSize:50, url: 'StaffWorkReportAction.do?task=deptStaffWorkReport&report=3&type=1&time=' + new Date().getTime(), parms : params, pageParmName: 'curPage', pagesizeParmName: 'pageSize', width: '100%', height: '99%', rownumbers:true, enabledSort:false, method:"post", // delayLoad:true, onAfterShowData:function(data){ showMsg(data); refreshBtn(false); }, onError:function(){ alert("获取数据失败,请刷新页面后重试!"); refreshBtn(false); } }); }else{ manHourReportTable._setParms(params); manHourReportTable.loadData(); } } /** * 查询当前报表 * @param delayLoad 初始化是是否不加载 */ function searchReport(){ var params = getParams(); if(!params.error){ refreshBtn(true); switch(curTab){ case 1 : initTaskStateReportTable(params);break; case 2 : initTaskScheduleReportTable(params);break; case 3 : initManHourReportTable(params);break; } } } function exportExcel(){ var params = getParams(); if(!params.error){ var curTable = getReportTable(); if(curTable != null){ refreshBtn(true); var pageSize = curTable.ligerGetGridManager().get("pageSize"); var page = curTable.ligerGetGridManager().get("page"); var action = "StaffWorkReportAction.do?task=deptStaffWorkReport"; action = action + "&report=" + curTab +"&type=2&pageSize="+ pageSize + "&curPage=" + page + convertJson2UrlParams(params); $("#exportExcelForm").attr("action", action).submit(); refreshBtn(false); } } } /** 获取表格对象 *@param tabId[int][可不传,为空时取得当前处于显示状态的表格对象,传入参数时,根据tabId获取表格对象] *@return ligerUi创建的表格对象 ***/ function getReportTable(tabId){ var obj = null; if(!tabId){ tabId = curTab; } switch(tabId){ case 1 : obj = $("#taskStateReport"); break; case 2 : obj = $("#taskScheduleReport"); break; case 3 : obj = $("#manHourReport"); break; default : obj = null; break; } return obj; } function showMsg(data){ if(data == undefined || data.Rows.length == 0){ var obj = getReportTable(); obj.find("div[class*='l-grid-body-inner']:last").next().html("