|
@@ -2,7 +2,6 @@
|
|
|
|
|
|
let rptTplObj = {
|
|
|
iniPage: function() {
|
|
|
- let me = this
|
|
|
zTreeOprObj.getReportTemplateTree(RT.GrpType.CONSTRUCT);
|
|
|
bandTreeOprObj.getReportTplCfg();
|
|
|
preview_util.drawBorder($("#tplCanvas")[0]);
|
|
@@ -267,6 +266,14 @@ let zTreeOprObj = {
|
|
|
let me = zTreeOprObj, nodes = [];
|
|
|
nodes.push(me.createNodeFromZTreeNode(treeNode));
|
|
|
me.updateNodes(nodes);
|
|
|
+ if (treeNode.nodeType == RT.NodeType.TEMPLATE && treeNode.refId >= 0) {
|
|
|
+ if (treeNode.rptTpl != null) {
|
|
|
+ treeNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = treeNode.name;
|
|
|
+ $("#rptTplName")[0].value = treeNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME];
|
|
|
+ } else {
|
|
|
+ me.onClick(e, treeId, treeNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onClick: function(event,treeId,treeNode) {
|
|
|
let me = zTreeOprObj;
|
|
@@ -311,11 +318,13 @@ let zTreeOprObj = {
|
|
|
params.rptTplId = me.currentNode.refId;
|
|
|
CommonAjax.postEx("report_tpl_api/getRefRptTpl", params, 20000, true, function(result){
|
|
|
me.currentNode.rptTpl = result;
|
|
|
- me.refreshTplView(me.currentNode.rptTpl);
|
|
|
+ me.currentNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = me.currentNode.name;
|
|
|
+ tplHelper.refreshTplView(me.currentNode.rptTpl);
|
|
|
}, null, null
|
|
|
);
|
|
|
} else {
|
|
|
- me.refreshTplView(me.currentNode.rptTpl);
|
|
|
+ me.currentNode.rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = me.currentNode.name;
|
|
|
+ tplHelper.refreshTplView(me.currentNode.rptTpl);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -326,279 +335,21 @@ let zTreeOprObj = {
|
|
|
}
|
|
|
return rst;
|
|
|
},
|
|
|
- refreshTplView: function (rptTpl) {
|
|
|
- let me = zTreeOprObj;
|
|
|
- if (rptTpl) {
|
|
|
- //1. 模板信息
|
|
|
- $("#rptTplName")[0].value = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME];
|
|
|
- $("#rptTplPageSize")[0].selectedIndex = JV.PAGES_SIZE_STR.indexOf(rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE]);
|
|
|
- if (rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] === JV.ORIENTATION_PORTRAIT ||
|
|
|
- rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] === JV.ORIENTATION_PORTRAIT_CHN) {
|
|
|
- $("#rptTplPageOrientation")[0].selectedIndex = 1;
|
|
|
- } else {
|
|
|
- $("#rptTplPageOrientation")[0].selectedIndex = 0;
|
|
|
- }
|
|
|
- $("#rptTplMarginLeft")[0].value = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_LEFT];
|
|
|
- $("#rptTplMarginRight")[0].value = rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_RIGHT];
|
|
|
- $("#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. 模板布局
|
|
|
- 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[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
- for (let band of parentBand[JV.BAND_PROP_SUB_BANDS]) {
|
|
|
- band.ID = startIdx;
|
|
|
- band.ParentID = parentBand.ID;
|
|
|
- startIdx++;
|
|
|
- private_setBandId(band);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- for (let band of bandList) {
|
|
|
- band.ID = startIdx;
|
|
|
- band.ParentID = -1;
|
|
|
- startIdx++;
|
|
|
- private_setBandId(band);
|
|
|
- }
|
|
|
-
|
|
|
- return rst;
|
|
|
- },
|
|
|
- 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 () {
|
|
|
- //
|
|
|
+ extractMainInfo: function (rptTpl) {
|
|
|
+ //模板信息
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MAIN_INFO_RPT_NAME] = $("#rptTplName")[0].value;
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = JV.PAGES_SIZE_STR[$("#rptTplPageSize")[0].selectedIndex];
|
|
|
+ if ($("#rptTplPageOrientation")[0].selectedIndex == 1) {
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = JV.ORIENTATION_PORTRAIT;
|
|
|
+ } else {
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_ORIENTATION] = JV.ORIENTATION_LANDSCAPE;
|
|
|
+ }
|
|
|
+ if (rptTpl[JV.NODE_FLOW_INFO]) {
|
|
|
+ rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN] = parseInt($("#rptTplMultiCols")[0].value);
|
|
|
+ }
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_LEFT] = $("#rptTplMarginLeft")[0].value;
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_RIGHT] = $("#rptTplMarginRight")[0].value;
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_TOP] = $("#rptTplMarginTop")[0].value;
|
|
|
+ rptTpl[JV.NODE_MAIN_INFO][JV.NODE_MARGINS][JV.PROP_BOTTOM] = $("#rptTplMarginBottom")[0].value;
|
|
|
}
|
|
|
};
|