|
@@ -4,13 +4,13 @@ let rptTplObj = {
|
|
|
iniPage: function() {
|
|
|
let me = this
|
|
|
zTreeOprObj.getReportTemplateTree(RT.GrpType.CONSTRUCT);
|
|
|
+ bandTreeOprObj.getReportTplCfg();
|
|
|
preview_util.drawBorder($("#tplCanvas")[0]);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
let zTreeOprObj = {
|
|
|
treeObj: null,
|
|
|
- bandTreeObj: null,
|
|
|
currentNode: null,
|
|
|
getReportTemplateTree: function(grpType) {
|
|
|
let me = zTreeOprObj, params = {};
|
|
@@ -18,9 +18,9 @@ let zTreeOprObj = {
|
|
|
params.userId = userID;
|
|
|
params.tplType = RT.TplType.ALL;
|
|
|
CommonAjax.postEx("report_tpl_api/getRptTplTree", params, 20000, true, function(result){
|
|
|
- zTreeHelper.createTree(result, setting, "rptTplTree", me);
|
|
|
- me.refreshNodes();
|
|
|
- }, null, null
|
|
|
+ zTreeHelper.createTree(result, setting, "rptTplTree", me);
|
|
|
+ me.refreshNodes();
|
|
|
+ }, null, null
|
|
|
);
|
|
|
},
|
|
|
refreshNodes: function() {
|
|
@@ -271,6 +271,7 @@ let zTreeOprObj = {
|
|
|
onClick: function(event,treeId,treeNode) {
|
|
|
let me = zTreeOprObj;
|
|
|
me.currentNode = treeNode;
|
|
|
+ bandTreeOprObj.currentNode = null;
|
|
|
if (treeNode.nodeType == RT.NodeType.NODE) {
|
|
|
$("#rpt_tpl_display_label")[0].innerText = "...";
|
|
|
} else if (treeNode.nodeType == RT.NodeType.TEMPLATE) {
|
|
@@ -342,21 +343,40 @@ let zTreeOprObj = {
|
|
|
$("#rptTplMarginTop")[0].value = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_TOP];
|
|
|
$("#rptTplMarginBottom")[0].value = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_BOTTOM];
|
|
|
//2. 模板布局
|
|
|
- let bandList = rptTpl[JV.NODE_BAND_COLLECTION];
|
|
|
- me.buildTreeData(bandList);
|
|
|
- me.bandTreeObj = $.fn.zTree.init($("#band_tree_reversed"), bandSetting, bandList);
|
|
|
- me.bandTreeObj.expandAll(true);
|
|
|
+ bandTreeOprObj.iniTree(rptTpl);
|
|
|
//3. 指标映射
|
|
|
+ fieldMapTreeOprObj.iniTree(rptTpl);
|
|
|
//4. 指标摆放
|
|
|
//5. 计算式
|
|
|
}
|
|
|
},
|
|
|
+ previewRptTpl: function (rptTpl) {
|
|
|
+ let me = zTreeOprObj;
|
|
|
+ if (rptTpl) {
|
|
|
+ //
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+let bandTreeOprObj = {
|
|
|
+ treeObj : null,
|
|
|
+ currentNode: null,
|
|
|
+ innerCounter: 1,
|
|
|
+ reportCfg: null,
|
|
|
+ canTrickEvent: false,
|
|
|
+ iniTree: function(rptTpl) {
|
|
|
+ var me = this;
|
|
|
+ let bandList = rptTpl[JV.NODE_BAND_COLLECTION];
|
|
|
+ me.buildTreeData(bandList);
|
|
|
+ me.treeObj = $.fn.zTree.init($("#band_tree_reversed"), bandSetting, bandList);
|
|
|
+ me.treeObj.expandAll(true);
|
|
|
+ },
|
|
|
buildTreeData: function(bandList){
|
|
|
let rst = [], startIdx = 1;
|
|
|
//zTreeHelper.createTree(result, setting, "rptTplTree", me);
|
|
|
let private_setBandId = function (parentBand) {
|
|
|
- if (parentBand.band_s) {
|
|
|
- for (let band of parentBand.band_s) {
|
|
|
+ if (parentBand[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
+ for (let band of parentBand[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
band.ID = startIdx;
|
|
|
band.ParentID = parentBand.ID;
|
|
|
startIdx++;
|
|
@@ -373,10 +393,212 @@ let zTreeOprObj = {
|
|
|
|
|
|
return rst;
|
|
|
},
|
|
|
- previewRptTpl: function (rptTpl) {
|
|
|
- let me = zTreeOprObj;
|
|
|
+ getReportTplCfg: function() {
|
|
|
+ let me = this, params = {};
|
|
|
+ params.userId = userID;
|
|
|
+ CommonAjax.postEx("report_tpl_api/getUserRptCfg", params, 20000, true, function(result){
|
|
|
+ me.reportCfg = result;
|
|
|
+ me.refreshRptCfgs();
|
|
|
+ }, null, null
|
|
|
+ );
|
|
|
+ },
|
|
|
+ refreshRptCfgs: function () {
|
|
|
+ let me = this;
|
|
|
+ if (me.reportCfg) {
|
|
|
+ me.reportCfg.borderArr = [];
|
|
|
+ for (let style of me.reportCfg.styles) {
|
|
|
+ me.reportCfg.borderArr.push(style.ID);
|
|
|
+ $("#borderStyles").append("<option value='" + style.ID + "'>" + style.CfgDispName + "</option>");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let pf = $("#pageFrequency");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[0] + "'>每页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[1] + "'>首页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[2] + "'>尾页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[3] + "'>章首页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[4] + "'>章尾页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[5] + "'>分组</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[6] + "'>交叉行尾页</option>");
|
|
|
+ pf.append("<option value='" + JV.PAGE_STATUS[7] + "'>交叉列尾页</option>");
|
|
|
+ let ba = $("#bandAlignment");
|
|
|
+ ba.append("<option value='" + JV.LAYOUT[0] + "'>上</option>");
|
|
|
+ ba.append("<option value='" + JV.LAYOUT[1] + "'>下</option>");
|
|
|
+ ba.append("<option value='" + JV.LAYOUT[2] + "'>左</option>");
|
|
|
+ ba.append("<option value='" + JV.LAYOUT[3] + "'>右</option>");
|
|
|
+ ba.append("<option value='" + JV.LAYOUT[4] + "'>填充</option>");
|
|
|
+ },
|
|
|
+ extractBands: function (rptTpl) {
|
|
|
+ let me = this;
|
|
|
if (rptTpl) {
|
|
|
- //
|
|
|
+ let newBandList = [];
|
|
|
+ for (let node of me.treeObj.getNodes()) {
|
|
|
+ newBandList.push(me.createBandFromNode(node));
|
|
|
+ }
|
|
|
+ rptTpl[JV.NODE_BAND_COLLECTION] = newBandList;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ createBandFromNode: function(node) {
|
|
|
+ let me = this, rst = {};
|
|
|
+ rst[JV.BAND_PROP_ALIGNMENT] = node[JV.BAND_PROP_ALIGNMENT];
|
|
|
+ rst[JV.BAND_PROP_DISPLAY_TYPE] = node[JV.BAND_PROP_DISPLAY_TYPE];
|
|
|
+ rst[JV.BAND_PROP_HEIGHT] = node[JV.BAND_PROP_HEIGHT];
|
|
|
+ rst[JV.PROP_NAME] = node[JV.PROP_NAME];
|
|
|
+ rst[JV.PROP_CONTROL] = node[JV.PROP_CONTROL];
|
|
|
+ rst[JV.PROP_STYLE] = node[JV.PROP_STYLE];
|
|
|
+ if (node[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
+ rst[JV.BAND_PROP_SUB_BANDS] = [];
|
|
|
+ for (let subNode of node[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
+ rst[JV.BAND_PROP_SUB_BANDS].push(me.createBandFromNode(subNode));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ createDftBand: function () {
|
|
|
+ let me = this, rst = {};
|
|
|
+ rst[JV.BAND_PROP_ALIGNMENT] = 'Top';
|
|
|
+ rst[JV.BAND_PROP_DISPLAY_TYPE] = 'EveryPage';
|
|
|
+ rst[JV.BAND_PROP_HEIGHT] = '3';
|
|
|
+ rst[JV.PROP_NAME] = 'newBand_' + me.innerCounter;
|
|
|
+ me.innerCounter++;
|
|
|
+ rst[JV.PROP_CONTROL] = 'Default';
|
|
|
+ rst[JV.PROP_STYLE] = 'Default_None';
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ addRootBand: function (rptTpl) {
|
|
|
+ let me = this;
|
|
|
+ if (rptTpl) {
|
|
|
+ let newBand = me.createDftBand();
|
|
|
+ let newNodes = [], isSilent = false;
|
|
|
+ newNodes.push(newBand);
|
|
|
+ if (me.treeObj) {
|
|
|
+ me.treeObj.addNodes(null, -1, newNodes, isSilent);
|
|
|
+ } else {
|
|
|
+ me.treeObj = $.fn.zTree.init($("#band_tree_reversed"), bandSetting, newNodes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ addSubBand: function (rptTpl) {
|
|
|
+ let me = this;
|
|
|
+ if (rptTpl && me.currentNode != null) {
|
|
|
+ let newBand = me.createDftBand();
|
|
|
+ let newNodes = [], isSilent = false;
|
|
|
+ newNodes.push(newBand);
|
|
|
+ me.treeObj.addNodes(me.currentNode, -1, newNodes, isSilent);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ moveDownBand: function (rptTpl) {
|
|
|
+ let me = bandTreeOprObj;
|
|
|
+ if (rptTpl && me.currentNode && me.currentNode.getNextNode()) {
|
|
|
+ let nextNode = me.currentNode.getNextNode();
|
|
|
+ me.treeObj.moveNode(nextNode, me.currentNode, "next", true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ moveUpBand: function (rptTpl) {
|
|
|
+ let me = bandTreeOprObj;
|
|
|
+ if (rptTpl && me.currentNode && me.currentNode.getPreNode()) {
|
|
|
+ let preNode = me.currentNode.getPreNode();
|
|
|
+ me.treeObj.moveNode(preNode, me.currentNode, "prev", true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClick: function(event,treeId,treeNode) {
|
|
|
+ let me = bandTreeOprObj;
|
|
|
+ me.currentNode = treeNode;
|
|
|
+ me.canTrickEvent = false;
|
|
|
+ //then refresh the band tab properties
|
|
|
+ //边框样式borderStyles
|
|
|
+ $("#borderStyles ").get(0).selectedIndex = me.reportCfg.borderArr.indexOf(treeNode[JV.PROP_STYLE]);
|
|
|
+ //边框合并
|
|
|
+ $("#mergeBandBorder").get(0).checked = stringUtil.convertStrToBoolean(treeNode[JV.BAND_PROP_MERGE_BORDER]);
|
|
|
+ //位置
|
|
|
+ let posIdx = JV.LAYOUT.indexOf(treeNode[JV.BAND_PROP_ALIGNMENT])
|
|
|
+ $("#bandAlignment").get(0).selectedIndex = posIdx;
|
|
|
+ //高宽
|
|
|
+ switch(posIdx) {
|
|
|
+ case 0:
|
|
|
+ case 1:
|
|
|
+ $("#bandHeight").get(0).disabled = false;
|
|
|
+ $("#bandHeight").get(0).value = treeNode[JV.BAND_PROP_HEIGHT];
|
|
|
+ $("#bandWidth").get(0).disabled = true;
|
|
|
+ $("#bandWidth").get(0).value = "";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ case 3:
|
|
|
+ $("#bandHeight").get(0).disabled = true;
|
|
|
+ $("#bandHeight").get(0).value = "";
|
|
|
+ $("#bandWidth").get(0).disabled = false;
|
|
|
+ $("#bandWidth").get(0).value = treeNode[JV.BAND_PROP_WIDTH];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ $("#bandHeight").get(0).disabled = true;
|
|
|
+ $("#bandHeight").get(0).value = "";
|
|
|
+ $("#bandWidth").get(0).disabled = true;
|
|
|
+ $("#bandWidth").get(0).value = "";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ //频率
|
|
|
+ $("#pageFrequency").get(0).selectedIndex = JV.PAGE_STATUS.indexOf(treeNode[JV.BAND_PROP_DISPLAY_TYPE])
|
|
|
+ //
|
|
|
+ me.canTrickEvent = true;
|
|
|
+ },
|
|
|
+ bandStyleChange: function (e) {
|
|
|
+ //alert('You changed the band style to: ' + e.selectedOptions[0].text + '(' + e.selectedOptions[0].value + ')');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+let fieldMapTreeOprObj = {
|
|
|
+ treeObj : null,
|
|
|
+ iniTree: function(rptTpl) {
|
|
|
+ var me = this;
|
|
|
+ let fieldMapList = me.buildTreeData(rptTpl);
|
|
|
+ me.treeObj = $.fn.zTree.init($("#field_map_tree_reversed"), fieldMapSetting, fieldMapList);
|
|
|
+ me.treeObj.expandAll(true);
|
|
|
+ },
|
|
|
+ buildTreeData: function (rptTpl) {
|
|
|
+ let rst = [];
|
|
|
+ let private_setSubFields = function (parent, fieldList) {
|
|
|
+ for (let field of fieldList) {
|
|
|
+ parent.items.push(field);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DISCRETE_FIELDS]) {
|
|
|
+ rst.push({Name: JV.NODE_DISCRETE_FIELDS, items: [], isParent: true});
|
|
|
+ private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DISCRETE_FIELDS])
|
|
|
}
|
|
|
+ if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS]) {
|
|
|
+ rst.push({Name: JV.NODE_MASTER_FIELDS, items: [], isParent: true});
|
|
|
+ private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_MASTER_FIELDS])
|
|
|
+ }
|
|
|
+ if (rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS]) {
|
|
|
+ rst.push({Name: JV.NODE_DETAIL_FIELDS, items: [], isParent: true});
|
|
|
+ private_setSubFields(rst[rst.length - 1], rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS])
|
|
|
+ }
|
|
|
+
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ onClick: function () {
|
|
|
+ //
|
|
|
+ },
|
|
|
+ onBeforeRemove: function(treeId, treeNode){
|
|
|
+ if (treeNode.level === 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ beforeRename: function(treeId, treeNode, newName, isCancel) {
|
|
|
+ if (isCancel) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ if (treeNode.level === 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ onRemove: function () {
|
|
|
+ //
|
|
|
+ },
|
|
|
+ onRename: function () {
|
|
|
+ //
|
|
|
}
|
|
|
-}
|
|
|
+};
|