if($ == undefined){ $ = jQuery; } function initParams(){ //参数拖拽 $('#param_tree').tree({ dnd:true, onBeforeDrag:function(target){ return true; }, onDragEnter:function(target, source){ return false; } }); //参数接收 $("#optparam").droppable({ accept:"#param_tree .tree-node", onDragEnter:function(e,source){ $("#optparam").css("border", "1px solid #ff0000"); $(source).draggable('proxy').find("span").removeClass("tree-dnd-no"); $(source).draggable('proxy').find("span").addClass("tree-dnd-yes"); }, onDragLeave:function(e,source){ $("#optparam").css("border", "1px solid #d3d3d3"); $(source).draggable('proxy').find("span").addClass("tree-dnd-no"); $(source).draggable('proxy').find("span").removeClass("tree-dnd-yes"); }, onDrop:function(e,source){ $("#optparam").css("border", "1px solid #d3d3d3"); var node = $("#param_tree").tree("getNode", source); newparam("insert", node.attributes.tp); } }); //参数初始化 var strs = ""; for(i=0; pageInfo.params&&i"+obj.name+"("+getParamTypeDesc(obj.type)+")
"; } if(strs != ""){ $("#optparam").html(strs); } } function moveparam(pos){ var pid = curTmpInfo.paramId; var idx = findParamById(pid, true); if(idx == 0 && pos == "left"){ msginfo("参数已在最左边,无法移动。"); return; }else if(idx == pageInfo.params.length - 1 && pos == "right"){ msginfo("参数已在最右边,无法移动。"); return; } var pms = pageInfo.params; if(pos == "left"){ var tp = pms[idx - 1]; pms[idx - 1] = pms[idx]; pms[idx] = tp; //交换参数位置 $("#optparam #p"+pid).prev().before($("#optparam #p"+pid)); curTmpInfo.isupdate = true; }else if(pos == "right"){ var tp = pms[idx + 1]; pms[idx + 1] = pms[idx]; pms[idx] = tp; //交换参数位置 $("#optparam #p"+pid).next().after($("#optparam #p"+pid)); curTmpInfo.isupdate = true; } } function newparam(tp, paramType, pid){ var param = null; if(!paramType){ paramType = curTmpInfo.paramType; } if(!pid){ pid = curTmpInfo.paramId; } curTmpInfo.paramvals = []; if(tp == 'update'){ param = findParamById(pid); if(param.values){ curTmpInfo.paramvals = param.values; } } var str = ""; var defstr = ""; if(paramType == "dateselect"){ defstr = "now表示默认当前日期"; var datetype = ['yyyyMMdd', 'yyyy-MM-dd', 'yyyy年MM月dd日']; var datestr = ""; for(i=0; i"+datetype[i]+""; } str = "
日期格式:
最小值:
最大值:"; } if(paramType == "monthselect"){ defstr = "now表示默认当前月份"; var datetype = ['yyyyMM', 'yyyy-MM', 'yyyy年MM月']; var datestr = ""; for(i=0; i"+datetype[i]+""; } str = "
月份格式:
最小值:
最大值:"; } if(paramType == "yearselect"){ defstr = "now表示默认当前年份"; var datetype = ['yyyy', 'yyyy年']; var datestr = ""; for(i=0; i"+datetype[i]+""; } str = "
年份格式:
最小值:
最大值:"; } var tmp = ""; if(paramType == "checkbox" || paramType == "radio"){ //获取所有用户的表 $.ajax({ type:"post", url:"../model/listCube.action", data: {t: Math.random()}, dataType:"json", async:false, success: function(resp){ for(k=0; k"+resp[k].cubeName+""; } } }); } //获取动态值得value/text字段的 option var valOption = ""; if(param != null && param.option && param.valtype=="dynamic" && param.option.tableId && param.option.tableId != ''){ $.ajax({ type:"post", url:"../bireport/queryDims.action", data: {cubeId: param.option.tableId}, dataType:"json", async:false, success: function(resp){ for(k=0; k"+name+""; } } }); } var values = reloadParamVals(true); var ctx = "
显示名称:
长度:
默认值:"+str +"
隐藏参数:
" + (paramType=="radio"||paramType=="checkbox"?"
值列表
"+values+"
ValueText操作

数据:
映射字段:
":"") +"
"; var tpname = getParamTypeDesc(paramType); $('#pdailog').dialog({ title: (tp == 'insert' ? '创建参数' : '编辑参数') + " - " + tpname, width: 410, height: paramType == "dateselect" || paramType == "monthselect"||paramType == "yearselect" ? 340 : (paramType=="text"?240:490), closed: false, cache: false, modal: true, toolbar:null, content:ctx, onLoad:function(){}, buttons:[{ text:'确定', iconCls:"icon-ok", handler:function(){ var paramid = "p_" + Math.round(Math.random() * 100000); var name = $("#pdailog #paramname").val(); if(name == ""){ msginfo("请输入参数显示名称!"); $("#pdailog #paramname").select(); return; } var defvalue = $("#pdailog #defvalue").val(); var size = $("#pdailog #size").val(); var tpname = getParamTypeDesc(paramType); if(isNaN(size)){ msginfo("长度必须是数字!"); $("#pdailog #size").select(); return; } if(size != ""){ if( size < 5 || size > 30){ msginfo("长度取值5-30!"); $("#pdailog #size").select(); return; } } var hiddenprm = $("#pdailog input[name=\"hiddenprm\"]:checked").val(); //判断是否有option值 if( paramType == 'radio' || paramType == 'checkbox'){ var r = $("#pdailog input[name=\"valtype\"]:checked").val(); if(r == 'static'){ if(!curTmpInfo.paramvals || curTmpInfo.paramvals.length == 0){ msginfo("您还未设置参数值。"); return; } }else { if($("#pdailog #dataset").val() == '' || $("#pdailog #param_option_val").val() == '' || $("#pdailog #param_option_text").val() == ''){ msginfo("您的参数还未绑定到数据。"); return; } } } var r = $("#pdailog input[name=\"valtype\"]:checked").val(); if(tp == 'insert'){ if($("#optparam span.charttip").size() > 0){ $("#optparam span.charttip").remove(); } var obj = {id:newGuid(), type:paramType, paramid:paramid, name:name,defvalue:defvalue, size:size, hiddenprm:hiddenprm}; if(paramType == "dateselect" || paramType == "monthselect" || paramType == "yearselect"){ obj.maxval = $("#pdailog #maxval").val(); obj.minval = $("#pdailog #minval").val(); obj.dtformat = $("#pdailog #dtformat").val(); } if( paramType == 'radio' || paramType == 'checkbox'){ obj.valtype = r; if(r == 'static'){ obj.values = curTmpInfo.paramvals; }else{ var val = $("#pdailog #param_option_val").val(); var vls = val.split("@"); var ts = $("#pdailog #dataset").val(); var tss = ts.split("@"); obj.option = {"tableId":tss[0], "tname":tss[1],"dsource":tss[2],"dimId":vls[0], "alias":vls[1]}; } } var str = ""+name+"("+tpname+")
"; $("#optparam").append(str); if(!pageInfo.params){ pageInfo.params = []; } pageInfo.params.push(obj); }else{ param.name = name; param.defvalue = defvalue; param.size = size; param.hiddenprm = hiddenprm; if(paramType == "dateselect" || paramType == "monthselect" || paramType == "yearselect"){ param.maxval = $("#pdailog #maxval").val(); param.minval = $("#pdailog #minval").val(); param.dtformat = $("#pdailog #dtformat").val(); } if(paramType == 'radio' || paramType == 'checkbox'){ param.valtype = r; if(r == 'static'){ param.values = curTmpInfo.paramvals; delete param.option; }else{ var val = $("#pdailog #param_option_val").val(); var vls = val.split("@"); var ts = $("#pdailog #dataset").val(); var tss = ts.split("@"); param.option = {"tableId":tss[0], "tname":tss[1],"dsource":tss[2],"dimId":vls[0], "alias":vls[1]}; delete param.values; } } $("#p" + param.id + " span.text").text(name + "("+tpname+")"); } curTmpInfo.isupdate = true; $('#pdailog').dialog('close'); } } ,{ text:'取消', iconCls:"icon-cancel", handler:function(){ $('#pdailog').dialog('close'); } }] }); $("#pdailog #valtype1,#pdailog #valtype2").bind("click", function(){ var val = $(this).val(); if(val == 'static'){ $("#pdailog #dynamic_div").css("display", "none"); $("#pdailog .param_left").css("display", "block"); $("#pdailog .param_right").css("display", "block"); }else{ $("#pdailog #dynamic_div").css("display", "block"); $("#pdailog .param_left").css("display", "none"); $("#pdailog .param_right").css("display", "none"); } }); //参数绑定到数据集,设置VALUE,TEXT 方法。 $("#pdailog #dataset").bind("change", function(){ var t1 = "param_option_val"; document.getElementById(t1).options.length = 0; var tp = $(this).attr("id"); var val = $(this).val(); if(val == ""){ return; } var tid = val.split("@")[0]; $.ajax({ type:"post", url:"../bireport/queryDims.action", data: {cubeId: tid}, dataType:"json", success: function(resp){ for(k=0; k 0){ $(this).remove(); } }); var str = ""; for(var i=0; i"+o.value+""+o.text+"   "; } for(var i=curTmpInfo.paramvals.length; i<5; i++){ str = str + ""; for(j=0; j<3; j++){ str = str + "   "; } str = str + ""; } if(isreturn == true){ return str; }else{ $(str).insertAfter("#pdailog #values table tr"); } } function paramdelvals(val){ var idx = -1; for(var i=0; i").appendTo("body"); } var t = null; if(isupdate && valId){ for(var i=0; iValue:Text:"; $('#dsColumn_div').dialog({ title: (isupdate == false ? '添加值':'编辑值'), width: 330, height: 170, closed: false, cache: false, modal: true, toolbar:null, content:ctx, onLoad:function(){}, onClose:function(){ $('#dsColumn_div').dialog('destroy'); }, buttons:[{ text:'确定', handler:function(){ var val = $("#dsColumn_div #val").val(); var txt = $("#dsColumn_div #txt").val(); if(val == "" || txt == ""){ msginfo("Value 和 Text 是必填项。"); return; } if(isupdate){ t.value = val; t.text = txt; }else{ curTmpInfo.paramvals.push({value:val, text:txt}); } reloadParamVals(); $('#dsColumn_div').dialog('close'); } },{ text:'取消', handler:function(){ $('#dsColumn_div').dialog('close'); } }] }); } function getParamTypeDesc(paramType){ var tpname = ""; if(paramType == "text"){ tpname = "输入框"; }else if(paramType == "radio"){ tpname = "单选框"; }else if(paramType == "checkbox"){ tpname = "多选框"; }else if(paramType == "dateselect"){ tpname = "日历框"; }else if(paramType == "monthselect"){ tpname = "月份框"; }else if(paramType == "yearselect"){ tpname = "年份框"; } return tpname; } function deleteParam(id){ if(!confirm("是否确认删除?")){ return; } var idx = findParamById(id, true); if(idx != null){ pageInfo.params.splice(idx, 1); } $("#p"+id).remove(); if($("#optparam span.pppp").size() == 0){ $("#optparam").html("查询条件区域
把参数放入此处作为报表查询条件
"); } curTmpInfo.isupdate = true; } function paramevent(compId){ var comp = findCompById(compId); var exist = function(id){ var ret = false; for(k=0; comp.link&&k
"; } } } var ctx = '
联动组件:'+str+'
'; $('#pdailog').dialog({ title: '参数事件设置', width: 300, height: 250, closed: false, cache: false, modal: true, toolbar:null, content: ctx, buttons:[{ text:'确定', handler:function(){ var o = []; $("#pdailog input[name=\"linkcomp\"]:checked").each(function(a, b){ o.push($(b).val()); }); comp.link = o; //参数联动的组件 curTmpInfo.isupdate = true; $('#pdailog').dialog('close'); } },{ text:'取消', handler:function(){ $('#pdailog').dialog('close'); } }] }); } function editInputData(comp){ if($("#dataProperty").size() == 0){ $('#Jlayout').layout('add', {region:"south", id:"dataProperty", split:false, collapsible:false,height : 120, title:'配置参数数据', tools:[{ iconCls:'icon-cancel', handler:function(){ $('#Jlayout').layout("remove", "south"); } }]}); }else{ $('#Jlayout').layout('panel', "south").panel("setTitle", "配置参数数据"); } var str = ""; if(comp.pcol){ str = "参数字段:"+comp.pcol.name+""; }else{ str = "
拖拽维度到此处作为页面参数字段
"; } var ctx = "
"+str+"
"; $("#dataProperty").html(ctx); //注册接收维度拖放事件 $("#tableData").droppable({ accept:"#datasettree .tree-node", onDragEnter:function(e,source){ var node = $("#datasettree").tree("getNode", source); var tp = node.attributes.col_type; //对维度拖拽设置图标 if(tp == 1 ){ $(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){ e.cancelBubble=true; e.stopPropagation(); //阻止事件冒泡 $(this).css("border", "1px dotted #666"); var node = $("#datasettree").tree("getNode", source); var tp = node.attributes.col_type; if(tp == 1){ if(comp.ctp == "dateselect" && node.attributes.dim_type != 'day'){ msginfo("拖入日历控件的字段必须是日期类型。"); return; }else if(comp.ctp != "dateselect" && node.attributes.dim_type == 'day' ){ msginfo("字段不能是日期类型。"); return; } var id = node.attributes.col_id; var p = {"id":id, "name":node.text, "type":node.attributes.dim_type, "colname":node.attributes.col_name, "tid":node.attributes.tid,"valType":node.attributes.valType,"tableName":node.attributes.tableName, "tableColKey":node.attributes.tableColKey,"tableColName":node.attributes.tableColName, "dimord":node.attributes.dimord, "ordcol":node.attributes.ordcol, "alias":node.attributes.alias, tname:node.attributes.tname}; comp.pcol = p; //设置组件的参数列 $("#tableData").html("参数字段:"+node.text+""); //更新参数数据 loadParamData(comp); } } }); } function setcompfilter(compId){ if(!compId){ compId = curTmpInfo.compId; } var comp = findCompById(compId); var str = "
"; str = str + ""; var t = comp.params; for(var i=0; t&&i"; } str = str + "
筛选字段判断条件筛选值值类型操作
"+o.col+"/"+o.tname+""+o.type+""+(o.usetype!='param'?(o.val+(o.val2 =='' ? "":"/"+o.val2)):"连接到参数")+""+o.valuetype+"
"; $('#pdailog').dialog({ title: '组件筛选', width: 680, height: 400, closed: false, cache: false, modal: true, toolbar:null, content:str, onLoad:function(){}, buttons:[{ text:'确定', iconCls:"icon-ok", handler:function(){ if(comp.type == 'table'){ tableView(comp, comp.id); }else if(comp.type == 'chart'){ chartview(comp, comp.id); } $('#pdailog').dialog('close'); } } ,{ text:'取消', iconCls:"icon-cancel", handler:function(){ $('#pdailog').dialog('close'); } }] }); } function delDatasetFilter(paramId, compId){ var comp = findCompById(compId); if(confirm("是否确认删除?")){ var idx = -1; for(i=0;comp.params&&i").appendTo("body"); } var cols = ""; var colLogic = ["=",">",">=","<", "<=", "!=", "between", "in", "like"]; var ftp = ""; var pms = ""; var pms2 = ""; var ctx = "
筛选字段:"+cols+"
判断条件:"+ftp+"
筛选值:"+pms+"
筛选值2:"+pms2+"
筛选值类型:
"; $('#dsColumn_div').dialog({ title: (isupdate == false ? '添加筛选条件':'编辑筛选条件'), width: 380, height: 270, closed: false, cache: false, modal: true, toolbar:null, content:ctx, onLoad:function(){}, onClose:function(){ $('#dsColumn_div').dialog('destroy'); }, buttons:[{ text:'确定', iconCls:"icon-ok", handler:function(){ if(!comp.params){ comp.params = []; } var col = $("#dsColumn_div #filtercolumn").val(); if(!col || col == ""){ msginfo("请选择筛选字段。"); return } var colStrs = col.split(","); var col = colStrs[0]; var colTname = colStrs[1]; if(isupdate == true){ t.col = col; var retCol = findTableCol(col, colTname); t.expression = retCol.expression; t.tname = colTname; t.vtype = retCol.type; t.type = $("#dsColumn_div #filtertype").val(); t.val = $("#dsColumn_div #filtervalue").val(); t.val2 = $("#dsColumn_div #filtervalue2").val(); t.valuetype = $("#dsColumn_div #valuetype").val(); t.linkparam = $("#dsColumn_div #linkparam").val() == null ?"":$("#dsColumn_div #linkparam").val(); t.linkparam2 = $("#dsColumn_div #linkparam2").val() == null ? "":$("#dsColumn_div #linkparam2").val(); t.usetype = $("#dsColumn_div .link_param").attr("tp"); }else{ var o = {id:newGuid(), type:$("#dsColumn_div #filtertype").val(), val:$("#dsColumn_div #filtervalue").val(), val2:$("#dsColumn_div #filtervalue2").val(), valuetype:$("#dsColumn_div #valuetype").val(), linkparam:($("#dsColumn_div #linkparam").val()==null?"":$("#dsColumn_div #linkparam").val()), linkparam2:($("#dsColumn_div #linkparam2").val()==null?"":$("#dsColumn_div #linkparam2").val()),usetype:$("#dsColumn_div .link_param").attr("tp")}; o.col = col; //获取表达式,tname var retCol = findTableCol(col, colTname); o.expression = retCol.expression; o.tname = retCol.tname; o.vtype = retCol.type; comp.params.push(o); } setcompfilter(compId); $('#dsColumn_div').dialog('close'); } },{ text:'取消', iconCls:"icon-cancel", handler:function(){ $('#dsColumn_div').dialog('close'); } }] }); $("#dsColumn_div #filtertype").change(function(){ var val = $(this).val(); if(val == 'between'){ $("#dsColumn_div #selval2").css("display", "block"); }else{ $("#dsColumn_div #selval2").css("display", "none"); } }); } function chglinkparam(ts, pos){ var tp = $(ts).attr("tp"); if(tp == "gdz"){ $(ts).attr("tp", "param").attr("title", "固定值"); $("#dsColumn_div #linkparam" + (pos==2?"2":"")).css("display","inline-block"); $("#dsColumn_div #filtervalue" + (pos==2?"2":"")).css("display","none"); }else{ $(ts).attr("tp", "gdz").attr("title", "链接到参数"); $("#dsColumn_div #filtervalue" + (pos==2?"2":"")).css("display","inline-block"); $("#dsColumn_div #linkparam" + (pos==2?"2":"")).css("display","none"); } } function findParamById(id, retIndex){ var ret = null; for(i=0; pageInfo.params&&i