浏览代码

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionOperation

zhangweicheng 7 年之前
父节点
当前提交
e3328385f6

+ 1 - 1
modules/reports/controllers/rpt_controller_operation.js

@@ -170,7 +170,7 @@ module.exports = {
         getAllPagesCommonOrg(rpt_id, pageSize, dftOption, function(err, pageRst){
             fs.writeFileSync('D:/GitHome/ConstructionOperation/tmp/testRpt.js', JSON.stringify(pageRst));
             try {
-                rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, function(newName){
+                rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, null, function(newName){
                     res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                     res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".xlsx");
                     let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.xlsx');

+ 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);

+ 20 - 10
modules/reports/util/rpt_excel_util.js

@@ -287,7 +287,7 @@ function writeSharedString(sharedStrList){
     }
     return rst;
 }
-function writeSheets(pageData, paperSize, sharedStrList, stylesObj, isSinglePage){
+function writeSheets(pageData, paperSize, sharedStrList, stylesObj, isSinglePage, custSheetMergeBands){
     let rst = [];
     let private_pushDftFont = function(){
         let font = {};
@@ -329,15 +329,19 @@ function writeSheets(pageData, paperSize, sharedStrList, stylesObj, isSinglePage
     private_pushDftFont();
     private_buildFirstDftStyle();
     if (isSinglePage) {
-        rst.push(writeSheet(pageData, null, paperSize, sharedStrList, stylesObj));
+        rst.push(writeSheet(pageData, null, paperSize, sharedStrList, stylesObj, null));
     } else {
         for (let i = 0; i < pageData.items.length; i++) {
-            rst.push(writeSheet(pageData, pageData.items[i], paperSize, sharedStrList, stylesObj));
+            let appointedMergeBand = null;
+            if (custSheetMergeBands && custSheetMergeBands.length > i) {
+                appointedMergeBand = custSheetMergeBands[i];
+            }
+            rst.push(writeSheet(pageData, pageData.items[i], paperSize, sharedStrList, stylesObj, appointedMergeBand));
         }
     }
     return rst;
 }
-function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
+function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj, appointedMergeBand){
     let rst = [], xPos = [], yPos = [], yMultiPos = [], headerStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     let currentPageMergePos = null; //在 JV.PAGING_OPTION_INFINITY 场合应用
     let private_pre_analyze_pos = function(){
@@ -437,7 +441,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 +455,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
@@ -499,6 +505,9 @@ function writeSheet(pageData, sheetData, paperSize, sharedStrList, stylesObj){
             mergeBorder = (sheetData)?sheetData[JV.PROP_PAGE_MERGE_BORDER]:pageData[JV.BAND_PROP_MERGE_BAND],
             mergeBand = pageData[JV.BAND_PROP_MERGE_BAND]
         ;
+        if (appointedMergeBand !== null) {
+            mergeBand = appointedMergeBand;
+        }
         if (sheetBorder[borderStr] && sheetBorder[borderStr][JV.PROP_LINE_WEIGHT] !== undefined) {
             rst = sheetBorder[borderStr][JV.PROP_LINE_WEIGHT];
         }
@@ -807,7 +816,7 @@ function mergeProperties(orgObj, newObj) {
 }
 
 module.exports = {
-    exportExcel: function (pageData, paperSize, fName, options, custSheetNames, callback) {
+    exportExcel: function (pageData, paperSize, fName, options, custSheetNames, custSheetMergeBands, callback) {
         let rptOptions = ({singlePage: false, fileName: 'report'});
         if (options === 'true') {
             rptOptions.singlePage = true;
@@ -862,7 +871,7 @@ module.exports = {
         //6.
         let zip_worksheets = zip_xl.folder('worksheets');
         let sharedStrList = [], stylesObj = {};
-        data = writeSheets(pageData, paperSize, sharedStrList, stylesObj, isSinglePage);
+        data = writeSheets(pageData, paperSize, sharedStrList, stylesObj, isSinglePage, custSheetMergeBands);
         if (isSinglePage) {
             for (let i = 0; i < 1; i++) {
                 file = 'sheet' + (i + 1) + '.xml';
@@ -904,7 +913,7 @@ module.exports = {
         //   -- 简单来说,就是重新包装数据
         try {
             // 1.1 newPageData外围属性
-            let newContrl = {}, newFont = {}, newStyle = {};
+            let newContrl = {}, newFont = {}, newStyle = {}, custMergeBands = [];
             for (let i = 0; i < pageDataArray.length; i++) {
                 mergeProperties(newContrl, pageDataArray[i][JV.NODE_CONTROL_COLLECTION]);
                 mergeProperties(newFont, pageDataArray[i][JV.NODE_FONT_COLLECTION]);
@@ -921,6 +930,7 @@ module.exports = {
             for (let i = 0; i < pageDataArray.length; i++) {
                 let offsetY = 0;
                 let mergeBand = {};
+                custMergeBands.push(pageDataArray[i][JV.BAND_PROP_MERGE_BAND]);
                 mergeBand[JV.PROP_LEFT] = [];
                 mergeBand[JV.PROP_RIGHT] = [];
                 mergeBand[JV.PROP_TOP] = [];
@@ -974,7 +984,7 @@ module.exports = {
                 newPageData.items.push(pageItem);
             }
             //3. everything is ok, then call me
-            me.exportExcel(newPageData, paperSize, fName, 'false', sheetNames, callback);
+            me.exportExcel(newPageData, paperSize, fName, 'false', sheetNames, custMergeBands, callback);
             // fsUtil.writeObjToFile(newPageData, 'D:/GitHome/ConstructionOperation/tmp/combinedHeader.js');
         } catch (e) {
             console.log(e);

+ 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;

+ 36 - 7
web/maintain/std_glj_lib/js/glj.js

@@ -215,9 +215,41 @@ let repositoryGljObj = {
             me.initSel(0);
         }
     },
+    bindEnterKey: function () {
+        let me = this;
+        let sheet = me.workBook.getActiveSheet();
+        me.workBook.commandManager().register("myEnter", function(){
+            let orgRow = sheet.getActiveRowIndex();
+            let orgCol = sheet.getActiveColumnIndex();
+            if(sheet.isEditing()){
+                sheet.endEdit();
+            }
+            let code = sheet.getValue(orgRow, 0);
+            let newRow, newCol;
+            if(!me.currentCache[orgRow] && code !== undefined && code !== null && orgCol !== me.setting.header.length - 1){
+                newRow = orgRow;
+                newCol = orgCol + 1;
+                sheet.setActiveCell(newRow, newCol);
+            }
+            else{
+                newRow = orgRow + 1;
+                newCol = me.currentCache[orgRow + 1] ? orgCol : 0;
+                sheet.setActiveCell(newRow, newCol);
+            }
+            //触发事件
+            me.onLeaveCell({type: 'LeaveCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: orgRow, col: orgCol});
+            me.onEnterCell({type: 'EnterCell'}, {sheet: sheet, sheetName: sheet.name(), cancel: false, row: newRow, col: newCol});
+            let newSels = [{row: newRow, rowCount: 1, col: newCol, colCount: 1}];
+            let oldSels = [{row: orgRow, rowCount: 1, col: orgRow, colCount: 1}];
+            me.onSelectionChanged({type: 'SelectionChanged'}, {sheet: sheet, sheetName: sheet.name(), newSelections: newSels, oldSelections: oldSels});
+        });
+        me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.enter, false, false, false, false);
+        me.workBook.commandManager().setShortcutKey("myEnter", GC.Spread.Commands.Key.enter, false, false, false, false);
+    },
     buildSheet: function(container) {
         let me = repositoryGljObj;
         me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30, me);
+        me.bindEnterKey();
         me.repositoryGljDelOpr();
         me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
         me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
@@ -404,16 +436,15 @@ let repositoryGljObj = {
                     }
                 }
                 focusToCol = getFocusToCol(me);
-                if(focusToCol === -1){
-
-                }
-                else {
+                if(focusToCol !== -1) {
                     $('#gljAlertBtn').click();
                     $('#aleConfBtn').click(function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                        me.workBook.focus(true);
                     });
                     $('#gljAleClose').click(function () {
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
+                        me.workBook.focus(true);
                     });
                     $('#aleCanceBtn').click(function () {
                         me.addGljObj = null;
@@ -424,6 +455,7 @@ let repositoryGljObj = {
                             me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value('');
                         }
                         me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, 0);
+                        me.workBook.focus(true);
                     });
                 }
             }
@@ -462,7 +494,6 @@ let repositoryGljObj = {
             updateArr = [], addArr = [], updateBasePrcArr = [];
         me.editingRowIdx = args.row;
         rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
-        console.log(rObj);
         //更新
         if (me.currentEditingGlj["ID"] && me.currentGlj) {
             rObj["ID"] = me.currentEditingGlj["ID"];
@@ -543,7 +574,6 @@ let repositoryGljObj = {
                         }
                     }
                 }
-            //--------------------------------------
             if(me.currentEditingGlj.basePrice !== rObj.basePrice){
                 //update basePrice of ration when editting basePrice of glj
                 let gljType = -1;
@@ -571,7 +601,6 @@ let repositoryGljObj = {
                     me.updateRationBasePrcRq(updateBasePrcArr);
                 }
             }
-            //-----------------------------------------------------------
         }
         //新增
         else {