123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- 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<data.rows.length;i++){
- column += data.rows[i].TABLE_COLUMN+",";
- }
- },
-
- error : function(e) {
- $.messager.alert('获取列失败!', '访问服务失败!', 'error');
- }
- });
- return column;
- }
-
-
- function getRole_id(id){
- if(id.indexOf(",")!=-1){
- var role_ids = id.split(",");
- for(var i=0;i<role_ids.length;i++){
- if(role_ids[i]=="R002105430210"||role_ids[i]=="R002105430211"||role_ids[i]=="R002105430212"||role_ids[i]=="R002105430213"){
- return role_ids[i];
- }if(role_ids[i]=="R002105430200"){
- return role_ids[i];
- }
- if(role_ids[i]=="R002105430205"){
- return role_ids[i];
- }
- }
- }else{
- return id;
- }
- }
|