var g; /*var title = "";*/ var type = ""; var depts; var loadParams = ""; var role_id =top.com.sinosoft.lz.system.user.LoginInfo.getRoleids(); var roleId = getRole_id(role_id); var dept_id = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids(); var deptsel = ""; var roleArr = ["R002105430205","R002105430200"]; var roleToolBar = getRole_id(role_id); function initComplete() { var url = decodeURI(window.location.search); var type = url.split("?")[1]; var table = url.split("?")[2]; $("#type").val(type); $("#tables").val(table); $("#title").text(table); loadParams = { "listId" : '329', "condition" : "is_del =0 and report_type='"+type+"'", direction : 'desc', // 排序方式 sort : 'REPORT_NAME_329' }; init(table,loadParams); } function init(data,params){ var option = { columns : [ { display :data , columns : [ {display : '一级表头', name : 'TABLE_HEAD_329',align : 'center',width : "25%"}, {display : '字段描述', name : 'COLUMN_NAME_329',align : 'center', width : "25%"}, {display : '是否在用', name : 'IS_USED_329_SHOW',align : 'center', width : "25%"}, {display : '是否统计', name : 'IS_COUNT_329_SHOW',align : 'center', width : "25%"} ], } ], pageSize : 10, rownumbers : true, percentWidthMode : true, checkbox : true }; var roleCons = roleButtonArr(); /*var toblBars = { items :[ {text : '新增',click : 'onAdd',iconClass : 'add1_tem',disabled : false,id:"16xz"}, {text : '删除',click : 'onDelete',iconClass : 'delete_tem', disabled : false,id:"16sc"}, {text : '修改', click : 'onEdit',iconClass : 'update_tem',disabled : false,id:"16xg"}, {text : '预览', click : 'onView',iconClass : 'view_tem',disabled : false,id:"16yl"}, {text : '导出', click : 'onReportExport',iconClass : 'export_tem',disabled : false,id:"16dc"}, {text : '返回', click : 'goback',iconClass : 'back_tem',disabled : false,id:"16fh"}, ], roleCons:roleCons };*/ var toblBars; if(dept_id!="C984DC9C294A486096C25FAA78C99AED"||$.inArray(roleToolBar,roleArr)==-1&&dept_id=="C984DC9C294A486096C25FAA78C99AED"){ toblBars = {items:[ {text : '预览', click : 'onView',iconClass : 'view_tem',disabled : false,id:"16yl"}, {text : '导出', click : 'onReportExport',iconClass : 'export_tem',disabled : false,id:"16dc"}, {text : '返回', click : 'goback',iconClass : 'back_tem',disabled : false,id:"16fh"} ]}; }else{ toblBars = { items: [ {text : '新增',click : 'onAdd',iconClass : 'add1_tem',disabled : false,id:"16xz"}, {text : '删除',click : 'onDelete',iconClass : 'delete_tem', disabled : false,id:"16sc"}, {text : '修改', click : 'onEdit',iconClass : 'update_tem',disabled : false,id:"16xg"}, {text : '预览', click : 'onView',iconClass : 'view_tem',disabled : false,id:"16yl"}, {text : '导出', click : 'onReportExport',iconClass : 'export_tem',disabled : false,id:"16dc"}, {text : '返回', click : 'goback',iconClass : 'back_tem',disabled : false,id:"16fh"} ], roleCons:roleCons }; } var options={ url : $.pathname() + '/ws/crud/CRUDService/queryQui', params : params, width : "100%", gridOptions:option, paperOpration:{showInput:"true"}, toolBarOptions:toblBars }; g=gridAndSingleRecode=$("#maingrid").quickgridAndSingleRecode(options); } //增加 function onAdd(){ var url = "/nwyj/page/business/em/report/Type_Add.html?"+$("#type").val()+"?"+$("#tables").val(); window.parent.document.getElementById("frmright").setAttribute("src", encodeURI(url)); } //删除 function onDelete(){ var rows = g.getSelectedRows(); var rowsLength = rows.length; if (rowsLength == 0) { top.Dialog.alert("请选中要删除的记录!"); return; } var ids = ""; var flag = true; for ( var i = 0; i < rowsLength; i++) { if(rows[i].IS_USED_329=="1"){ flag = false; top.Dialog.alert("备用字段不能删除"); return; }else{ ids += rows[i].FD_OBJECTID_329 + ";"; } } if(flag){ top.Dialog.confirm("确定要删除吗?|删除", function() { // 删除记录 $.post($.pathname() +"/ws/xianlutingyun/XianlutingyunService/deleteReport", { fd_id : ids,type:"yj" }, function(result) { if (result.Msg.sucsess == true) { top.Dialog.alert("删除成功",null,null,null,null); // 刷新表格数据 g.rend(); } else { top.Dialog.alert("删除失败!"); } }, "json"); }); } } //修改 function onEdit(){ var row = g.getSelectedRows(); if(row.length==0){ top.Dialog.alert("请选择一条记录修改"); return; } if(row.length>1){ top.Dialog.alert("一次只能修改一条记录"); return; } var title = row[0].TABLE_HEAD_329; var desc = row[0].COLUMN_NAME_329; var name = row[0].TABLE_COLUMN_329; var count = row[0].IS_COUNT_329; var type = row[0].REPORT_TYPE_329; var report_name = row[0].REPORT_NAME_329; /*var changeDept = $("#dept").val();*/ window.parent.document.getElementById("frmright").setAttribute("src", encodeURI("/nwyj/page/business/em/report/Type_Alter.html?"+title+"?"+desc+"?"+name+"?"+count+"?"+type+"?"+report_name)); } //预览 function onView(){ /* var dept = $("#dept").val(); var sel = $("#sel").val();*/ /*var data = g.getData(); var name = data[0].REPORT_NAME_329;*/ window.parent.document.getElementById("frmright").setAttribute("src",encodeURI("/nwyj/page/business/em/report/View.html?"+$("#type").val()+"?"+$("#tables").val())); } function onReportExport(){ var url = decodeURI(window.location.search); var type = url.split("?")[1]; var table = url.split("?")[2]; var Columns = findColumn(type); var columns_sub = Columns.substring(0, Columns.lastIndexOf(",")); var condition = '1=1'; var sql = { "flag":"muban", "listId" :findId(type), "condition":condition, "id":dept_id, "report_type":type }; excelExport(findId(type),sql,"导出"+table,['FD_OBJECTID','REPORT_ID','TEST','COMP_ID',columns_sub],"导出"+table,"report"); //excelExport(findId(type),sql," 导出"+table,['FD_OBJECTID','REPORT_ID','TEST','COMP_ID',columns_sub],type,'report'); } function goback(){ var iframe = parent.document.getElementsByName("frmright")[0]; iframe.src = "/nwyj/page/business/em/report/report_model.jsp"; } //根据选中记录查找classId function findId(type){ var classId=""; $.ajax({ url : $.pathname() + "/ws/getReportId/ExportExcelService/getReportClassId", type : 'post', timeout : 15000, async : false, data : { report_type:type }, dataType : 'json', success : function(data) { classId = data.rows[0].CLASSID; }, error : function(e) { $.messager.alert('获取ID失败!', '访问服务失败!', 'error'); } }); return classId; } //过滤没用的列 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