if($ == undefined){ $ = jQuery; } function selecttable(){ $('#pdailog').dialog({ title: '选择数据集', width: 400, height: 350, closed: false, cache: false, modal: true, toolbar:null, content:'', onLoad:function(){ }, buttons:[{ text:'确定', iconCls:"icon-ok", handler:function(){ var node = $("#targettables").tree("getSelected"); if(node == null){ msginfo("请选择表!"); return; } pageInfo.table = {dsetId:node.attributes.dsetId, dsid:node.attributes.dsid,dsetName:node.attributes.dsetName,priTable:node.attributes.priTable}; $("#comp_tab").tabs("select", 2); initTableTree(); curTmpInfo.isupdate = true; $('#pdailog').dialog('close'); } },{ text:'取消', iconCls:"icon-cancel", handler:function(){ $('#pdailog').dialog('close'); } }] }); $.getJSON("../model/listDataset.action", {t:Math.random()}, function(dt){ for(i=0; i"+o.name+"
"; } if(str == ""){ str = "
拖拽数据表字段到此处作为表格的列字段
"; }else{ str = "表格字段:" + str + ""; } var ctx = "
"+str +"
"; $("#dataProperty").html(ctx); //注册接收度量及维度拖放事件 $("#gridData").droppable({ accept:"#tabletree .tree-node", onDragEnter:function(e,source){ //对维度拖拽设置图标 $(source).draggable('proxy').find("span").removeClass("tree-dnd-no"); $(source).draggable('proxy').find("span").addClass("tree-dnd-yes"); $("#gridData").css("border", "1px solid #ff0000"); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 }, onDragLeave:function(e,source){ $(source).draggable('proxy').find("span").addClass("tree-dnd-no"); $(source).draggable('proxy').find("span").removeClass("tree-dnd-yes"); $("#gridData").css("border", "1px dotted #666"); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 }, onDrop:function(e,source){ var grid = findCompById(compId); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 //清除边框颜色 $("#gridData").css("border", "1px dotted #666"); //获取TREE var node = $("#tabletree").tree("getNode", source); if(grid.dsetId && grid.dsetId != node.attributes.dsetId){ msginfo("你拖入的字段"+node.text+"与表格已有的内容不在同一个表中,拖放失败!"); return; }else{ grid.dsetId = node.attributes.dsetId; grid.dsid = node.attributes.dsid; } if(!grid.cols){ grid.cols = []; } //判断是否存在 var exist = function(gid){ var r = false; for(j=0; j"+node.text+"
"; var obj = $("#gridData"); if(obj.find("#tabRows").size() == 0){ obj.html("表格字段:"+str+""); }else{ $("#gridData #tabRows").find("span.dimcol").last().after(str); } curTmpInfo.isupdate = true; gridView(grid); } }); } function gridView(grid){ if(!grid){ return; } if(!grid.cols || grid.cols.length==0){ return; } var json = eval("("+JSON.stringify(grid)+")"); json.portalParams = pageInfo.params; __showLoading(); $.ajax({ type: "POST", url: "GridView.action", contentType : "application/json", dataType:"html", data: JSON.stringify(json), success: function(resp){ __hideLoading(); $("#c_" + grid.id + " div.cctx div.ccctx").html(resp); }, error:function(resp){ __hideLoading(); $.messager.alert('出错了','系统出错,请查看后台日志。','error'); } }); } function setGridCol(ts, id, name, compId){ var offset = $(ts).offset(); //放入临时对象中,方便下次获 curTmpInfo.ckid = id; curTmpInfo.compId = compId; curTmpInfo.dimname = name; var comp = findCompById(compId); var col = findColById(id, comp); if(col.sort == 'asc'){ $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord1")).target, iconCls:"icon-ok"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord2")).target, iconCls:"icon-blank"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord3")).target, iconCls:"icon-blank"}); }else if(col.sort == 'desc'){ $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord1")).target, iconCls:"icon-blank"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord2")).target, iconCls:"icon-ok"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord3")).target, iconCls:"icon-blank"}); }else{ $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord1")).target, iconCls:"icon-blank"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord2")).target, iconCls:"icon-blank"}); $("#gridoptmenu").menu("setIcon", {target:$("#gridoptmenu").menu("getItem", $("#col_ord3")).target, iconCls:"icon-ok"}); } $("#gridoptmenu").menu("show", {left:offset.left, top:offset.top - 96}); } function gridColsort(tp){ var id = curTmpInfo.ckid; var compId = curTmpInfo.compId; var comp = findCompById(compId); var col = findColById(id, comp); //清楚其他字段的排序 for(i=0; i
"; } if(col.type == "Date" || col.type == "Datetime"){ fmtstr = "格 式 化:
"; } var ctx = "
显示名称:
所 属 表: "+col.tname+"
对应字段: "+col.name+"
"+fmtstr+"位置:
"; $('#pdailog').dialog({ title: '表格字段属性', width: 350, height: 270, closed: false, cache: false, modal: true, toolbar:null, content: ctx, buttons:[{ text:'确定', iconCls:"icon-ok", handler:function(){ var dispName = $("#pdailog #dispName").val(); var fmt = $("#pdailog #fmt").val(); var align = $("#pdailog #palign").val(); col.dispName = dispName; col.fmt = fmt; col.align = align; $('#pdailog').dialog('close'); curTmpInfo.isupdate = true; gridView(comp); } },{ text:'取消', iconCls:"icon-cancel", handler:function(){ $('#pdailog').dialog('close'); } }] }); } function tableColmove(tp){ var id = curTmpInfo.ckid; var compId = curTmpInfo.compId; var comp = findCompById(compId); var dims = comp.cols; if(dims.length <= 1){ msginfo('无效移动。'); return; } for(var i=0; i= dims.length - 1){ msginfo('无效移动。'); return; }else{ var tp = dims[i + 1]; dims[i + 1] = dims[i]; dims[i] = tp; //交换维度 $("#gridData #d_"+id).next().after($("#gridData #d_"+id)); curTmpInfo.isupdate = true; gridView(comp); return; } } break; } } } function delGridCol(){ var id = curTmpInfo.ckid; var compId = curTmpInfo.compId; var comp = findCompById(compId); if(comp.cols.length == 1){ msginfo("表格至少需要含有一个字段。"); return; } //从json移除 var idx = -1; for(i=0; i"+row.text+""; }} }}, {name:'背景颜色',col:'bgcolor', value:(comp.bgcolor?comp.bgcolor:""), group:'数据块属性', editor:{ type:'combobox', options:{data:colorJson, formatter:function(row){ return "
"+row.text+"
"; }} }} ] }); } function editBoxData(compId){ if($("#dataProperty").size() == 0){ $('#Jlayout').layout('add', {region:"south", id:"dataProperty", split:false, collapsible:false,height : 100, title:'绑定数据块度量', tools:[{ iconCls:'icon-cancel', handler:function(){ $('#Jlayout').layout("remove", "south"); } }]}); }else{ $('#Jlayout').layout('panel', "south").panel("setTitle", "绑定数据块度量"); } //切换选项卡到立方体 $("#comp_tab").tabs("select", 1); var comp = findCompById(compId); var str = ""; if(!comp.kpiJson){ str = "
拖拽需要展现的立方体度量到此处。
"; } var colstr = ""; var o = comp.kpiJson; if(o){ colstr = ""+o.kpi_name+""; } var ctx = "
"+str + colstr +"
"; $("#dataProperty").html(ctx); //注册接收度量及维度拖放事件 $("#dataProperty #boxData").droppable({ accept:"#datasettree .tree-node", onDragEnter:function(e,source){ var node = $("#datasettree").tree("getNode", source); var tp = node.attributes.col_type; //只能拖拽度量 if(tp == 2){ }else{ return; } //对维度拖拽设置图标 $(source).draggable('proxy').find("span").removeClass("tree-dnd-no"); $(source).draggable('proxy').find("span").addClass("tree-dnd-yes"); $(this).css("border", "1px solid #ff0000"); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 }, onDragLeave:function(e,source){ $(source).draggable('proxy').find("span").addClass("tree-dnd-no"); $(source).draggable('proxy').find("span").removeClass("tree-dnd-yes"); $(this).css("border", "1px dotted #666"); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 }, onDrop:function(e,source){ var id = compId var json = findCompById(id); e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 //清除边框颜色 $(this).css("border", "1px dotted #666"); //获取TREE var node = $("#datasettree").tree("getNode", source); var tp = node.attributes.col_type; //只能拖拽度量 if(tp == 2){ }else{ msginfo("只能拖拽度量到数据块中显示。"); return; } json.dsetId = node.attributes.dsetId; json.dsid = node.attributes.dsid; json.kpiJson = {"kpi_id":node.attributes.col_id, "kpi_name" : node.text, "col_name":node.attributes.col_name, "aggre":node.attributes.aggre, "fmt":node.attributes.fmt, "alias":node.attributes.alias,"tname":node.attributes.tname,"unit":node.attributes.unit,"rate":node.attributes.rate}; $("#dataProperty #boxData").html(""+node.text+""); //设置title comp.name = node.text; $("#c_" + comp.id + " div.ctit h5").html(comp.name); curTmpInfo.isupdate = true; boxView(comp); } }); } function boxView(comp){ if(!comp.kpiJson){ return; } var json = {"kpiJson":comp.kpiJson, height:comp.height, "dsid":comp.dsid, "dsetId":comp.dsetId, portalParams:pageInfo.params,params:comp.params}; __showLoading(); $.ajax({ type: "POST", url: "BoxView.action", contentType : "application/json", dataType:"html", data: JSON.stringify(json), success: function(resp){ __hideLoading(); $("#c_"+comp.id + " div.cctx div.ccctx").html(resp); }, error:function(resp){ __hideLoading(); $.messager.alert('出错了','系统出错,请查看后台日志。','error'); } }); } function findColById(id, comp){ var ret; for(i=0; i