var g;
var mycol;
var testData;
var fd_id;
// 下拉框的值
var val;
// var login_name = top.com.sinosoft.lz.system.user.LoginInfo.();
// 获取用户部门
var corpId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
// 获取用户Id
var user_id = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
var corpName = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
var role_id = top.com.sinosoft.lz.system.user.LoginInfo.getRoleids();
var currDate = getNowFormatDate();
var role = "R002105430210";
var headType = "xq";
var role1 = '"' + role + '"';
var headType1 = '"' + headType + '"';
var Prourl = $.pathname()
+ "/ws/xianlutingyun/XianlutingyunService/getProjectName";
function initTree1($dom, setting, nodes) {
$.fn.zTree.init($dom, setting, nodes);
}
$(function() {
// ****布局
var layout = $("#layout1").layout({
leftWidth : 250,
space : 10
});
function customHeightSet(contentHeight) {
$(".layout_content").height(contentHeight - 30);
}
$("#layout1").layout({
onEndResize : function() {
var wi = $(".l-layout-content").width();
wi = wi * 0.85;
$(".accordition").css("width", (wi + 45) + "px");
$(".leftnav").css("width", (wi + 5) + 'px');
$(".parentNavDiv").css("width", wi + "px");
}
});
$("#layout1").find(".l-layout-header-toggle").on("click",function(){
$("#layout1").find(".l-layout-collapse-left-toggle").attr("tempW",$("#maingrid").find(".l-grid2").width());
$("#maingrid").find(".l-grid2").css({width:"100%"});
});
$("#layout1").find(".l-layout-collapse-left-toggle").on("click",function(){
$("#maingrid").find(".l-grid2").css({width:$(this).attr("tempW")});
});
function customHeightSet(contentHeight) {
$(".cusBoxContent").height(contentHeight - 20);
}
var setting1 = {
view : {
selectedMulti : false
},
async : {
dataType : 'JSON',
contentType : "application/json"
},
callback : {
onClick : nodeNick,
onExpand: checkExpand
}
};
var url = $.pathname() + "/ws/ReportHuiZong/HuiZongService/getYuAnTree";
var nodes = getThing(url, {"comp_id":corpId});
initTree1($("#reportTree"), setting1, nodes);
$("#warningNumber").on("change",function() {
var fdVal = $(this).val();
if (fdVal) {
var url = $.pathname()
+ "/ws/xianlutingyun/XianlutingyunService/getProjectTime";
var params = {
fd_id : fdVal
};
getProjectNames(url, params, "时间");
} else {
// $("#warningTime1").render();
// $("#dateSelect").val("");
$("#show").hide();
$("#show1").hide();
/*if ($("#show1").is(":hidden")) {
$("#show1").show();
$("#show2").hide();
$("#show").hide();
}*/
}
});
var params = getParams(role,"1");
getProjectNames(Prourl, params, "计划");
showTitle("线路停运及恢复情况");
totalShow("1", role, 'xq');
//数据比对
$("#compare").on("click",function(){
var url = "/nwyj/page/business/em/report/DataCompare.html";
var tp = $("#sel").val();
url = encodeURI(url+"?corpName="+corpName+"?type="+tp+"?roleId="+role+"?corpId="+corpId);
window.open(url);
});
$("#fullScreen").on("click",function(){
});
});
// 树节点单击方法
function nodeNick(event, treeId, treeNode) {
if (!treeNode.isParent) {
$("#sel").val(treeNode.id);
role = treeNode.parentId.split("_")[0];
headType = treeNode.type;
role1 = '"' + treeNode.parentId.split("_")[0] + '"';
headType1 = '"' + treeNode.type + '"';
showTitle(treeNode.name);
totalShow(treeNode.id, role, treeNode.type);
clearTime();
}
}
// 初始化表格
function init(cols) {
g = null;
g = $("#maingrid")
.quiGrid(
{
columns : eval('(' + cols + ')'),
data : testData,
// data:eval('('+testData+')'),
/*height : '90%',*/
width : "100%",
alternatingRow : false,
rowAttrRender : function(rowdata, rowid) {
return "总计" == rowdata.COMP_NAME ? "style=\"background-color:#f2f2f2;\""
: '';
},
rownumbers : true,
usePager : false,
enabledSort : false,
onAfterShowData:function(){
setContentHeight();
}
});
}
function print() {
var report_types = $("#sel").val();
var flag = $("#show").is(":hidden");
var selectDate = "";
if (flag) {
selectDate = $("#warningTime1").val();
} else {
selectDate = $("#dateSelect").val() + " " + $("#warningTime2").val();
}
var condition = "REPORT_ID = '" + fd_id + "'";
var sql = {
/*"listId" : findId(report_types),*/
"condition" : condition,
"report_type" : report_types,
"date" : selectDate,
"id" : corpId,
"json" : JSON.stringify(g.getData()),
"flag" : "huizong",
"warning_number" : $("#warningNumber").attr("relText")
};
var Columns = findColumn(report_types);
var columns_sub = Columns.substring(0, Columns.lastIndexOf(","));
if ('7' == report_types) {
printExcelExport("", sql, "导出" + $("#title").text(), [
'FD_OBJECTID', 'REPORT_ID', 'TEST', columns_sub ], $("#title")
.text(), 'yjxy');
} else {
printExcelExport("", sql, "导出" + $("#title").text(), [
'FD_OBJECTID', 'REPORT_ID', 'TEST', columns_sub ], $("#title")
.text(), 'report');
}
}
/**
* 获取报表表头
* @param val 报表类型
* @param type 报表分类(统计、明细)
*/
function getColumns(val, type) {
//alert(val+":"+type);
var urls = $.pathname()
+ "/ws/xianlutingyun/XianlutingyunService/getHuizongColumns";
$.ajax({
url : urls,
type : 'post',
timeout : 15000,
async : false,
data : {
report_type : val,
type : type
},
dataType : 'text',
success : function(data) {
mycol = data;
},
error : function(e) {
$.messager.alert('查询失败!', '访问服务失败!', 'error');
}
});
}
/**
* 获取行信息
* @param value 报表类型
* @param roleId
*/
function getRows(value, roleId) {
testData = null;
var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/huizong";
$.ajax({
url : urls,
type : 'post',
timeout : 15000,
async : false,
data : {
comp_id : corpId,
report_type : value,
roleId : roleId
},
dataType : 'json',
success : function(data) {
testData = data;
fd_id = data.rows[0].REPORT_ID;
},
error : function(e) {
$.messager.alert('查询失败!', '访问服务失败!', 'error');
}
});
}
/**
* 获取响应编号
* @param url
* @param params
* @param type
*/
function getProjectNames(url, params, type) {
$.ajax({
url : url,
type : 'post',
timeout : 15000,
async : false,
data : params,
dataType : 'json',
success : function(data) {
if (type == "计划") {
$("#warningNumber").data("data", data);
$("#warningNumber").render();
} else if (type == "时间") {
// $("#dateSelect").val("");
if (data[0].timeType == "周期性") {
$("#show").show();
$("#show1").hide();
$("#show2").show();
$("#warningTime2").data("data", data);
$("#warningTime2").render();
} else {
$("#show").hide();
$("#warningTime1").data("data", data);
$("#warningTime1").render();
$("#show1").show();
$("#show2").hide();
}
}
},
error : function(e) {
$.messager.alert('删除失败!', '删除失败!', 'error');
}
});
}
/**
* 查询
*/
function checkMsg() {
var newDataurl = $.pathname()
+ "/ws/xianlutingyun/XianlutingyunService/huizong";
var project = $("#warningNumber").val();
exportId = project;
var flag = $("#show2").is(":hidden");
//临时性
var protime1 = $("#warningTime1").val();
var protime2 = $("#warningTime2").val();
var date = $("#dateSelect").val();
var newDataParams = "";
var reportType = $("#sel").val();
var newTjParams = "";
if (reportType != "7") {
if (project=="" && date=="") {
top.Dialog.alert('请选择编号或者填报时间再查询');
return;
}
if(project=="" && date!=""){
if (headType == "xq") {
newDataParams = {
report_type : reportType,
comp_id : corpId,
warning_number : "",
date : date,
roleId : role
};
}else{
newTjParams = {
compId : corpId,
report_type : reportType,
report_id : "",
date : date
};
}
}else if (project != "") {
var reportId = $("#warningNumber").attr("relValue");
if(flag){
selectDate = protime1;
}else if(!flag && date==""){
selectDate = protime2;
}else{
selectDate = $("#dateSelect").val() + " " + $("#warningTime2").val();
}
if (headType == "xq") {
newDataParams = {
report_type : reportType,
comp_id : corpId,
warning_number : reportId,
date : selectDate,
roleId : role
};
} else {
newTjParams = {
compId : corpId,
report_type : reportType,
report_id : reportId,
date : selectDate
};
}
}
} else {
var time1 = $("#time1").val();
var time2 = $("#time2").val();
var time3 = "";
var totalTime = "";
if (time1 == "") {
top.Dialog.alert("请选择起始时间");
return;
} else if (time2 == "") {
time3 = getNowFormatDate();
totalTime = time1 + ";" + time3;
} else if (time1 != "" && time2 != "") {
totalTime = time1 + ";" + time2;
}
newDataParams = {
report_type : reportType,
date : totalTime,
roleId : role
};
}
if (headType == "xq") {
getNewData(newDataurl, newDataParams);
init(mycol);
} else {
tjInit(mycol, newTjParams);
}
};
function getNewData(url, params) {
$.ajax({
url : url,
type : 'post',
timeout : 15000,
async : false,
data : params,
dataType : 'json',
success : function(data) {
testData = data;
fd_id = data.rows[0].REPORT_ID;
},
error : function(e) {
$.messager.alert('查询失败!', '访问服务失败!', 'error');
}
});
}
function clearTime() {
$("#warningNumber").render();
$("#warningTime2").render();
$("#dateSelect").val("");
if ($("#show1").is(":hidden")) {
$("#show1").show();
$("#show2").hide();
$("#show").hide();
}
}
/**
* 汇总查询页面-导出功能
*/
function export_report() {
var report_types = $("#sel").val();
var flag = $("#show").is(":hidden");
var selectDate = "";
if (flag) {
selectDate = $("#warningTime1").val();
} else {
selectDate = $("#dateSelect").val() + " " + $("#warningTime2").val();
}
var condition = "REPORT_ID = '" + fd_id + "'";
var sql = {
/*"listId" : findId(report_types),*/
"condition" : condition,
"report_type" : report_types,
"date" : selectDate,
"id" : corpId,
"json" : JSON.stringify(g.getData()),
"flag" : "huizong",
"warning_number" : $("#warningNumber").attr("relText")
};
var Columns = findColumn(report_types);
var columns_sub = Columns.substring(0, Columns.lastIndexOf(","));
if ('7' == report_types) {
excelExport("", sql, "导出" + $("#title").text(), [
'FD_OBJECTID', 'REPORT_ID', 'TEST', columns_sub ], $("#title")
.text(), 'yjxy');
} else {
excelExport("", sql, "导出" + $("#title").text(), [
'FD_OBJECTID', 'REPORT_ID', 'TEST', columns_sub ], $("#title")
.text(), 'report');
}
}
/**
* 查询报表中不可用的字段
* @param type 报表类型
* @returns {String}
*/
function findColumn(type) {
var column = "";
$.ajax({
url : $.pathname() + "/ws/getReportId/ExportExcelService/getColumn",
type : 'post',
timeout : 15000,
async : false,
data : {
report_type : type
},
dataType : 'json',
success : function(data) {
for (var i = 0; i < data.rows.length; i++) {
column += data.rows[i].TABLE_COLUMN + ",";
}
},
error : function(e) {
$.messager.alert('获取列失败!', '访问服务失败!', 'error');
}
});
return column;
}
function showDetail(Goindex, name, val, display, comp) {
if (val == "未填报" || val == "0") {
return;
}
else {
var showType = $("#sel").val();
if (showType == "1" || showType == "3" || showType == "5"
|| showType == "8" || showType=="4" || showType == "101") {
if (showType == "8") {
if (display.indexOf("人") == -1) {
return;
}
}
if (comp == "总计") {
Goindex = "";
var totalData = testData;
if (totalData != "") {
for (var i = 0; i < totalData["rows"].length - 1; i++) {
Goindex += "'" + totalData["rows"][i]["FD_OBJECTID"]
+ "',";
}
Goindex = Goindex.substring(0, Goindex.lastIndexOf(","));
}
}
var diag = new parent.Dialog();// 定义一个窗口对象
diag.Top = 10;
diag.Title = "详情查看";// 窗口标题
diag.URL = "/nwyj/page/business/em/report/Data/Report1.html";// 窗口对应的页面
diag.Height = 590;
diag.Width = 1150;
diag.showOkButton = false;
diag.showCancelButton = false;
diag.CancelEvent = function(){
//$(parent.document.body).find("#frmright").height(bodyheight+30);
$(parent.document.body).find("#frmrightChild").height($(window.document.body).height()+30);
$(top.document.body).find("#frmright").height($(parent.document.body).height()+30);
diag.close();
};
diag.ShowMaxButton = true;
diag.show();// 显示窗口
/**/
diag.OnLoad = function() {
diag.innerFrame.contentWindow.showDeatilMsg(Goindex, name,
showType, display, comp);
};
}
}
return false;
}
function showMsg(rowdata, rowindex, value, column) {
var display = column.display.replace("\
", '');
if (value == undefined || value == "undefined") {
value = "";
}
return '' + value + '';
}
// 跳转方法
function _addStatus(rowdata, rowindex, value, column) {
if (value == undefined || value == "undefined") {
value = "";
}
var comp_id = '"' + rowdata.COMP_ID + '"';
var name = '"' + value + '"';
if ($("#sel").val() == "1") {
if (rowdata.COMP_NAME == "总计") {
return "