123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- //获取用户Id
- var userId = top.com.sinosoft.lz.system.user.LoginInfo.getUser_id();
- var real_name = top.com.sinosoft.lz.system.user.LoginInfo.getReal_name();
- //获取用户部门Id
- var corpId = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_ids();
- var comp_name = top.com.sinosoft.lz.system.user.LoginInfo.getCorp_names();
- var dept_name = top.com.sinosoft.lz.system.user.LoginInfo.getDeptnames();
- var _thisUrl = decodeURI(decodeURI(window.location.href));
- //报表类型
- var report_type = _thisUrl.split("?")[3];
- var report_name = _thisUrl.split("?")[4];
- //事件类型
- var affairId = _thisUrl.split("?")[1];
- //事件名称
- var affair = _thisUrl.split("?")[2];
- //初始已配置的单位数据
- var beginCompId = [];
- //初始单位及报表字段配置数据
- var beginData = "";
- //选择的单位及单位名称
- var selectedCompId = [];
- var selectedCompName = [];
- //选择单位后自动配上所有的字段
- var columnData = getThing($.pathname() + "/ws/xianlutingyun/XianlutingyunService/getConfigurationColumns",{report_type:report_type},"json");
- var grid;
- var mycol,title;
- var testData;
- //var selectData={"list":[{"value":"checked","key":"√"}]};
- function initComplete(){
- $("#title").text(affair+"【"+report_name+"】"+"配置");
- //查询表头
- getColumns();
- //查询配置
- getColumnData();
- initGrid();
-
- $(".hand").hover(function(){$(this).addClass("hover");},function(){$(this).removeClass("hover");});
- $(".l-grid-hd-cell").removeClass("l-grid-hd-cell-checkbox");
- }
- function goback(){
- window.history.go(-1);
- }
- //获取(表头)
- function getColumns() {
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getReportColumns";
- $.ajax({
- url : urls,
- type : 'post',
- timeout : 300000,
- async : false,
- data : {
- "report_type" : report_type
- },
- dataType : 'text',
- success : function(data) {
- mycol = eval('(' + data + ')');
- title = eval('(' + data + ')')[0].display;
-
- },
- error : function(e) {
- $.messager.alert('查询表头失败!', '访问服务失败!', 'error');
- }
- });
- }
- /**
- * 加载单位和报表字段配置数据
- */
- function getColumnData(){
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/getColumnsData";
- $.ajax({
- url : urls,
- type : 'post',
- data : {"report_type":report_type,"corp_id":corpId,"affair":affairId},
- dataType : 'json',
- async : false,
- success : function(result){
- var data = result.data;
- beginCompId = [];
- selectedCompId = [];
- for(var i=0;i<data.length;i++){
- beginCompId.push(data[i].COMP_ID);
- selectedCompId.push(data[i].COMP_ID);
- }
- testData = result;
- },
- error : function(){
- $.messager.alert('查询配置表字段失败!', '访问服务失败!', 'error');
- }
- });
- }
- function initGrid(){
- grid = null;
- grid = $("#maingrid").quiGrid({
- columns : mycol,
- data : testData,
- usePager : false,//是否分页
- headerRowHeight : 50,//表头行的高度
- rownumbers : true,//是否显示行号
- rownumbersColWidth : 30,
- enabledEdit : true,//是否可编辑
- checkbox : true,
- checkboxColWidth : 30,
- width : "auto",
- /*height : "100%",*/
- multihead : true,//多表头模式时设为true
- enabledSort : false,//是否允许排序
- alternatingRow : false,//是否启用奇偶行变色效果
- //allowUnSelectRow : true,//设为true,则第一次点击选中行,第二次点击可以取消选中行
- onBeforeEdit : onBeforeEdit,
- onAfterEdit : onAfterEdit,
- toolbar : {
- items : [
- {text: '上移', click:upRow, iconClass: 'shangyi_tem'},
- {line:true},
- {text: '下移', click:downRow, iconClass: 'xiayi_tem'},
- {line:true},
- {text: '置顶', click:stickRow, iconClass : 'zhiding_tem'},
-
- {text:"重置",click:reset,iconClass:"icon_add", position : "right"},
- {line:true,position : "right"},
- {text:"单位配置",click:configuration, iconClass:"icon_edit", position : "right"},
- {line:true, position : "right"},
- {text:"保存",click:save, iconClass:"icon_add", position : "right"}
- ]
- },
- onAfterShowData : function(){
- setContentHeight();
- }
- });
- }
- function upRow(){
- //选中一行
- var rows = grid.getSelectedRows();
- if (rows.length == 0) {
- top.Dialog.alert('请选择一行记录操作');
- return;
- }else if(rows.length > 1){
- top.Dialog.alert('一次只能选择一行记录操作');
- return;
- }
- grid.up(rows[0]);
- }
- function downRow(){
- //选中一行或多行
- var rows = grid.getSelectedRows();
- if (rows.length == 0) {
- top.Dialog.alert('请选择一行记录操作');
- return;
- }else if(rows.length > 1){
- top.Dialog.alert('一次只能选择一行记录操作');
- return;
- }
- grid.down(rows[0]);
- }
- function stickRow(){
- //选中一行或多行
- var rows = grid.getSelectedRows();
- if (rows.length == 0) {
- top.Dialog.alert('请选择一行记录操作');
- return;
- }else if(rows.length > 1){
- top.Dialog.alert('一次只能选择一行记录操作');
- return;
- }
- var index = rows[0]["__index"];
- if(index==0){
- top.Dialog.alert('已经在第一行了');
- return;
- }
- grid.move(rows[0],0,false);
- }
- function onBeforeEdit(e){
- var name = e.column.name;
- if(e.value=="√"){
- // e.column["editor"]["data"]={"list":[{"value":"checked","key":"√"},{"value":"nochecked","key":"x"}]};
- e.record[name]="×";
- }else{
- // e.column["editor"]["data"]={"list":[{"value":"checked","key":"√"}]};
- e.record[name]="√";
- }
- }
- function onAfterEdit(e){
-
- }
- //表字段列自定义格式
- function showSelect(rowdata, rowindex, value, column){
- if(value=="√"){
- return "√";
- }
- }
- //单位列自定义格式
- function _addStatus(rowdata, rowindex, value, column){
- var id = '"'+rowdata.COMP_ID+'"';
- var name = '"'+rowdata.COMP_NAME+'"';
- return "<div class='comp' title='点击可预览表字段'><a href='javascript:void(0)' onclick='newHtml("+id+","+name+")'>"+value+"</a></div>";
- }
- function newHtml(id,name){
- $.indexOpenSelfWindow("/nwyj/page/business/em/report/ViewConfiguration.html?"+affairId+"?"+id+"?"+name+"?"+report_type+"?"+report_name);
- }
- function headStatus(rowdata, rowindex, value, column){
- var flag = rowdata.columns==undefined?true:false;//true--单表头,false--多表头
- var columns = flag?rowdata.name:rowdata.columns;
- var cols = [];
- for(var i=0;i<columns.length;i++){
- cols.push(flag?"_"+columns:"_"+columns[i].name);
- }
- // return '<div class="padding_left10"><span class="icon_lightOn hand" title="全选列操作" data-column=\''+cols+'\' onclick="getAll(this)">'+rowdata.head_name+'</span></div>';
- return '<div class="padding_left10"><a class="hand" title="反选列操作" href="javascript:void(0)" onclick="getAll(this)" data-column=\''+cols+'\'>'+rowdata.head_name+'</a></div>';
- }
- function getAll(obj){
- var _this = $(obj);
- var columns = _this.attr("data-column");
- var data = grid.getData();
- for(var i=0;i<data.length;i++){
- var rowdata = data[i];
- for(var j in rowdata){
- if(columns.indexOf("_"+j)>-1 && rowdata[j] == "×"){
- rowdata[j] = "√";
- }else if(columns.indexOf("_"+j)>-1 && rowdata[j] == "√"){
- rowdata[j] = "×";
- }
- }
- }
- grid.options.data = {"rows":data};
- grid.loadData();
- }
- /**
- * 单位配置
- */
- function configuration(){
- $(this).addClass("selectedButton");
- var diag = new top.Dialog();// 定义一个窗口对象
- diag.Title = "选择组织";// 窗口标题
- diag.URL = "/nwyj/page/business/em/report/selectDept.html";
- diag.Height = 450;
- diag.Width = 380;
- diag.ID = "ORG_IFRAME";
- diag.ShowButtonRow = true;
- diag.ShowCancelButton = false;// 不显示取消按钮
- // diag.ShowOkButton = false;
- diag.ButtonAlign = "center";// 按钮居中
- diag.OkButtonText=" 确 定 ";
- diag.OKEvent = function(){
- var data = grid.getData();//表格数据
- if(beginCompId.length==0){
- data = [];
- }else{
- var len = data.length;
- for(var i=0;i<len;i++){
- for(var j in data){
- if($.inArray(data[j]["COMP_ID"],beginCompId)==-1){
- data.splice(j, 1);
- break;
- }
- }
- }
- }
- var selectedComp = diag.innerFrame.contentWindow.queDing();
- selectedCompId = [];//单位
- selectedCompname = [];//单位名称
- for(var m=0;m<selectedComp.length;m++){
- var comp = selectedComp[m].split(",");
- selectedCompId.push(comp[0]);
- selectedCompname.push(comp[1]);
- }
- for(var i=0;i<selectedCompId.length;i++){
- var id = selectedCompId[i];
- var name = selectedCompname[i];
- if($.inArray(id,beginCompId)==-1){//不存在,则新增
- var addData = {};
- addData["COMP_ID"] = id;
- addData["COMP_NAME"] = name;
- for(var n in columnData[0]){
- addData[n] = columnData[0][n];
- }
- data.push(addData);
- }
- }
- for(var j=0;j<beginCompId.length;j++){
- var id = beginCompId[j];
- if($.inArray(id,selectedCompId)==-1){//不存在,则删除
- for(var k=0;k<data.length;k++){
- if(id==data[k].COMP_ID){
- data.splice(k,1);
- break;
- }
- }
- }
- }
- grid.options.data = {"rows":data};
- grid.loadData();
- diag.close();
- setContentHeight();
- };
- diag.CancelEvent = function(){
- setContentHeight();
- diag.close();
- };
- diag.show();// 显示窗口
- diag.OnLoad=function(){
- diag.innerFrame.contentWindow.showData(selectedCompId.join(","),report_type,affair);
- };
- diag.addButton("testBtn5"," 清除 ",function(){
- diag.innerFrame.contentWindow.qingChu();
- });
- diag.addButton("testBtn6"," 全选 ",function(){
- diag.innerFrame.contentWindow.quanXuan();
- });
- }
- /**
- * 保存单位和报表字段配置
- */
- function save(){
- var urls = $.pathname() + "/ws/xianlutingyun/XianlutingyunService/saveReportConfiguration";
- var data = grid.getData();
- var params = {"corp_id":corpId,"corp_name":comp_name,"report_type":report_type,"affair":affairId,"data":JSON.stringify(data)};
- $.ajax({
- url : urls,
- type : 'post',
- data : params,
- dataType : 'json',
- success : function(data){
- if(data.Msg.sucsess==true){
- var ids = data.Msg.data.split(",");
- beginCompId = [];
- selectedCompId = [];
- for(var c=0;c<ids.length;c++){
- if(""!=ids[c]){
- beginCompId.push(ids[c]);
- selectedCompId.push(ids[c]);
- }
- }
- }
- top.Dialog.alert(data.Msg.info);
- },
- error : function(){
- $.messager.alert('保存配置失败!', '访问服务失败!', 'error');
- }
- });
- }
- /**
- * 重置单位配置,恢复beginCompId
- */
- function reset(){
- top.Dialog.confirm("确定要重置?填写的信息会全部清除,请慎重选择|重置", function() {
- getColumnData();
- grid.options.data = testData;
- grid.loadData();
- setContentHeight();
- });
- }
- function setContentHeight(){
- var content = $("#maingrid").height();
- $(window.document.body).height(content+100);
- $(top.document.body).find("#frmright").height($(window.document.body).height());
- }
|