Browse Source

1. copy模板时增加引用的选项 2. code sync

TonyKang 7 years ago
parent
commit
dd9be0f69c

+ 7 - 5
modules/reports/rpt_component/jpc_ex.js

@@ -215,12 +215,14 @@ JpcExSrv.prototype.createNew = function(){
         }
     };
     JpcResult.executeFormulas = function(runType, $CURRENT_TEMPLATE, $CURRENT_DATA, $CURRENT_RPT) {
-        let me = this;
-        for (let i = 0; i < me.formulas.length; i++) {
-            if (me.formulas[i][JV.PROP_RUN_TYPE] === runType) {
-                let expression = me.formulas[i][JV.PROP_EXPRESSION];
+        let execFmlMe = this;
+        for (let execFmlIdx = 0; execFmlIdx < execFmlMe.formulas.length; execFmlIdx++) {
+            //remark: 搞这么复杂的变量名是为了防止与表达式起冲突(如循环变量i,j,k,容易造成变量冲突且不容易看出问题)
+            if (execFmlMe.formulas[execFmlIdx][JV.PROP_RUN_TYPE] === runType) {
+                let expression = execFmlMe.formulas[execFmlIdx][JV.PROP_EXPRESSION];
                 if (expression) {
-                    let $ME = me.formulas[i];
+                    let $ME = execFmlMe.formulas[execFmlIdx];
+                    // console.log("current expression idx: " + execFmlIdx);
                     // console.log(expression);
                     try {
                         eval(expression);

+ 4 - 2
modules/reports/util/rpt_excel_util.js

@@ -437,7 +437,8 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
         for (let i = 0; i < stylesObj.fonts.length; i++) {
             let font = stylesObj.fonts[i];
             if (sheetFont) {
-                if (font[JV.FONT_PROPS[0]] === sheetFont[JV.FONT_PROPS[0]] && font.size === Math.round(sheetFont[JV.FONT_PROPS[1]] * 3 / 4)
+                // if (font[JV.FONT_PROPS[0]] === sheetFont[JV.FONT_PROPS[0]] && font.size === Math.round(sheetFont[JV.FONT_PROPS[1]] * 3 / 4)
+                if (font[JV.FONT_PROPS[0]] === sheetFont[JV.FONT_PROPS[0]] && font.size === Math.floor(sheetFont[JV.FONT_PROPS[1]] * 3 / 4)
                     && font[JV.FONT_PROPS[3]] === sheetFont[JV.FONT_PROPS[3]] && font[JV.FONT_PROPS[5]] === sheetFont[JV.FONT_PROPS[5]]) {
                     hasFont = true;
                     rst = i;
@@ -450,7 +451,8 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
         if (!hasFont) {
             let font = {};
             font[JV.FONT_PROPS[0]] = sheetFont[JV.FONT_PROPS[0]]; //font name
-            font.size = Math.round(sheetFont[JV.FONT_PROPS[1]] * 3 / 4);
+            // font.size = Math.round(sheetFont[JV.FONT_PROPS[1]] * 3 / 4);
+            font.size = Math.floor(sheetFont[JV.FONT_PROPS[1]] * 3 / 4);
             font.charset = 134;
             font.colorIdx = "8";
             font[JV.FONT_PROPS[3]] = sheetFont[JV.FONT_PROPS[3]]; //font bold

+ 22 - 9
web/maintain/report/js/rpt_tpl_main.js

@@ -359,9 +359,8 @@ let zTreeOprObj = {
             me.getNewNodeID(1, function (newNodeID) {
                 let orgID = treeNodes[0].ID;
                 treeNodes[0].ID = newNodeID;
-                treeNodes[0].refId = newNodeID;
                 newTopNode = me.buildRootNodeDoc(targetTopNode);
-                me.copyReportTemplate(orgID, newNodeID, true, function(goodResult){
+                if (confirm("是否引用相同的报表模板?")) {
                     me.updateTreeRootNode(newTopNode, false, function(goodRst){
                         canContinue = true;
                         if (treeNodes[0].rptTpl) {
@@ -372,10 +371,24 @@ let zTreeOprObj = {
                         displayMessage("更新模板节点失败!", "red", 2000);
                         console.log(badRst.toString());
                     });
-                }, function(badResult){
-                    displayMessage("Copy请求失败!", "red", 2000);
-                    console.log(badResult.toString());
-                });
+                } else {
+                    treeNodes[0].refId = newNodeID;
+                    me.copyReportTemplate(orgID, newNodeID, true, function(goodResult){
+                        me.updateTreeRootNode(newTopNode, false, function(goodRst){
+                            canContinue = true;
+                            if (treeNodes[0].rptTpl) {
+                                treeNodes[0].rptTpl.ID = newNodeID;
+                            }
+                            me.currentNode = treeNodes[0];
+                        }, function(badRst){
+                            displayMessage("更新模板节点失败!", "red", 2000);
+                            console.log(badRst.toString());
+                        });
+                    }, function(badResult){
+                        displayMessage("Copy请求失败!", "red", 2000);
+                        console.log(badResult.toString());
+                    });
+                }
             });
             if (canContinue) me.chkAndRreshRefTpl();
         } else {
@@ -716,7 +729,7 @@ let zTreeOprObj = {
                 $('#rptTypeSelectionModal').modal('show');
             } else {
                 //显示报表模板
-                me.chkAndRreshRefTpl();
+                me.chkAndRreshRefTpl(true);
             }
         }
     },
@@ -732,10 +745,10 @@ let zTreeOprObj = {
         }
         return rst;
     },
-    chkAndRreshRefTpl: function() {
+    chkAndRreshRefTpl: function(forceRefresh) {
         let me = zTreeOprObj, params = {};
         if (me.currentNode && me.currentNode.nodeType === RT.NodeType.TEMPLATE && me.currentNode.refId > 0) {
-            if (!(me.currentNode.rptTpl)) {
+            if (forceRefresh || !(me.currentNode.rptTpl)) {
                 params.rptTplId = me.currentNode.refId;
                 CommonAjax.postEx("report_tpl_api/getRefRptTpl", params, 20000, true, function(result){
                         me.currentNode.rptTpl = result;