Просмотр исходного кода

Merge branch '1.0.0_online' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost into 1.0.0_online

zhongzewei 7 лет назад
Родитель
Сommit
363eaa17dc

+ 2 - 1
modules/all_models/ration.js

@@ -16,7 +16,8 @@ var rationAssItemSchema = mongoose.Schema({
     decimal: Number,
     carryBit: String,
     minValue: String,
-    maxValue: String
+    maxValue: String,
+    isAdjust:Number //0不调整,1调整
 }, { _id: false });
 
 // 定额、量价、工料机定额 合并存储

+ 1 - 0
modules/main/facade/ration_facade.js

@@ -603,6 +603,7 @@ function createRationAss(std) {
             let ass = std.rationAssList[i];
             ass._doc.actualValue = ass.stdValue;
             if(_.isString(ass._doc.assistCode)) ass._doc.assistCode = ass._doc.assistCode.replace("\n","");
+            ass._doc.isAdjust = 0;
             rationAssList.push(ass);
         }
     }

+ 1 - 0
modules/ration_glj/facade/glj_calculate_facade.js

@@ -284,6 +284,7 @@ function getContent(coes) {
 }
 
 function calculateTimes(ass){
+    if(ass.isAdjust == 0) return 0;//打勾辅助定额才计算
     let times =(ass.actualValue-ass.stdValue)/ass.stepValue;
     let r = false;
     if(times<0){

+ 6 - 1
modules/reports/controllers/rpt_controller.js

@@ -255,7 +255,12 @@ function getAllPagesCommon(user_id, prj_id, rpt_id, pageSize, orientation, custo
                         printCom.initialize(rptTpl);
                         printCom.analyzeData(rptTpl, tplData, defProperties, dftOption, outputType);
                         let maxPages = printCom.totalPages;
-                        let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
+                        let pageRst = null;
+                        if (maxPages > 0) {
+                            pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties, customizeCfg);
+                        } else {
+                            pageRst = printCom.outputAsPreviewPage(rptTpl, defProperties);
+                        }
                         if (pageRst) {
                             // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult.jsp");
                             cb(null, pageRst);

+ 51 - 2
modules/reports/rpt_component/jpc_flow_tab.js

@@ -737,10 +737,59 @@ JpcFlowTabSrv.prototype.createNew = function(){
             vIdx.push([-1, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
         }
         let unitFactor = JpcCommonHelper.getUnitFactor(rptTpl);
+        // me.multiCols = 1 * rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN];
+        let newMultiCols = 1 * rptTpl[JV.NODE_FLOW_INFO][JV.PROP_MULTI_COLUMN];
         // 2.2 Column tab
-        rst = rst.concat(me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0));
+        let private_colone_cells = function(orgCells) {
+            let newRst = [];
+            let newCopyCells = [];
+            newCopyCells.push(orgCells);
+            if (newMultiCols > 1) {
+                let minX = 10000, maxX = -10;
+                for (let cell of orgCells) {
+                    if (minX > parseInt(cell[JV.PROP_AREA][JV.PROP_LEFT])) minX = cell[JV.PROP_AREA][JV.PROP_LEFT];
+                    if (maxX < parseInt(cell[JV.PROP_AREA][JV.PROP_RIGHT])) maxX = cell[JV.PROP_AREA][JV.PROP_RIGHT];
+                }
+                let newW = maxX - minX, newSegW = newW / newMultiCols;
+                for (let i = 1; i < newMultiCols; i++) {
+                    let cells = [];
+                    for (let cell of orgCells) {
+                        let copyCell = {Value: cell.Value, area: {}, font: cell[JV.PROP_FONT], control: cell[JV.PROP_CONTROL], style: cell[JV.PROP_STYLE]};
+                        cells.push(copyCell);
+                        copyCell[JV.PROP_AREA][JV.PROP_LEFT] = cell[JV.PROP_AREA][JV.PROP_LEFT];
+                        copyCell[JV.PROP_AREA][JV.PROP_RIGHT] = cell[JV.PROP_AREA][JV.PROP_RIGHT];
+                        copyCell[JV.PROP_AREA][JV.PROP_TOP] = cell[JV.PROP_AREA][JV.PROP_TOP];
+                        copyCell[JV.PROP_AREA][JV.PROP_BOTTOM] = cell[JV.PROP_AREA][JV.PROP_BOTTOM];
+                    }
+                    newCopyCells.push(cells);
+                }
+                for (let ci = 0; ci < newCopyCells.length; ci++) {
+                    for (let cCell of newCopyCells[ci]) {
+                        cCell[JV.PROP_AREA][JV.PROP_LEFT] = Math.round(minX + newSegW * ci + (cCell[JV.PROP_AREA][JV.PROP_LEFT] - minX) / newMultiCols);
+                        cCell[JV.PROP_AREA][JV.PROP_RIGHT] = Math.round(minX + newSegW * ci + (cCell[JV.PROP_AREA][JV.PROP_RIGHT] - minX) / newMultiCols);
+                    }
+                }
+            }
+            for (let cCells of newCopyCells) {
+                for (let dCell of cCells) {
+                    newRst.push(dCell);
+                }
+            }
+            return newRst;
+        };
+        let tmpColCells = me.outputColumn(rptTpl, null, 1, 0, bands, unitFactor, 0);
+        if (newMultiCols > 1) {
+            tmpColCells = private_colone_cells(tmpColCells);
+        }
+        rst = rst.concat(tmpColCells);
         // 2.1 Content-Tab
-        rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec));
+        let tmpContentCells = me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec);
+        if (newMultiCols > 1) {
+            tmpContentCells = private_colone_cells(tmpContentCells);
+        } else {
+            // rst = rst.concat(me.outputPreviewContent(rptTpl, bands, unitFactor, controls, pageStatus, maxRowRec));
+        }
+        rst = rst.concat(tmpContentCells);
         // 2.3 Sum Seg
         rst = rst.concat(me.outputPreviewSegSum(rptTpl, bands, unitFactor, controls, pageStatus));
         // 2.4 Sum Page

+ 39 - 1
public/web/treeDataHelper.js

@@ -18,7 +18,7 @@ let tree_Data_Helper = {
             return tmpNodeRst;
         };
         let private_buildNodeData = function(parentItem, idArr, treeLevel, tbID) {
-            let iter = [], nextNode = private_getStartNode(idArr);
+            let iter = [], nextNode = private_getStartNode(idArr), pushedIds = [];
             while (nextNode !== null && nextNode !== undefined ) {
                 if (parentItem) {
                     parentItem[CHILDREN_NODE].push(nextNode);
@@ -26,6 +26,7 @@ let tree_Data_Helper = {
                     rst.push(nextNode);
                 }
                 iter.push(nextNode);
+                pushedIds.push(nextNode[NODE_ID]);
                 nextNode[TOP_BILL_ID] = tbID;
                 if (parentItem === null) {
                     nextNode[TOP_BILL_ID] = nextNode[NODE_ID];
@@ -40,7 +41,44 @@ let tree_Data_Helper = {
                 }
                 if (addLevel) nextNode[TREE_LEVEL] = treeLevel;
                 nextNode = tmpNodes[prefix + nextNode[NEXT_ID]];
+                if (nextNode === null || nextNode === undefined) {
+                    //备注: 考虑到实际数据的健壮性,有些节点会掉链子,需要用 parentItem[SUB_ID] 比对已经加上的节点,如发现加上的节点数量不够,那就得在这里补充上去
+                    if (parentItem) {
+                        if (parentItem[SUB_ID].length > iter.length) {
+                            for (let subId of parentItem[SUB_ID]) {
+                                if (pushedIds.indexOf(subId) < 0) {
+                                    let restNode = tmpNodes[prefix + subId];
+                                    if (addLevel) restNode[TREE_LEVEL] = treeLevel;
+                                    restNode[TOP_BILL_ID] = tbID;
+                                    parentItem[CHILDREN_NODE].push(restNode);
+                                    iter.push(restNode);
+                                }
+                            }
+                        }
+                    } else {
+                        if (idArr.length > iter.length) {
+                            for (let topId of idArr) {
+                                if (pushedIds.indexOf(topId) < 0) {
+                                    let restNode = tmpNodes[prefix + topId];
+                                    if (addLevel) restNode[TREE_LEVEL] = treeLevel;
+                                    restNode[TOP_BILL_ID] = restNode[NODE_ID];
+                                    if (restNode.flags && restNode.flags.length > 0) {
+                                        for (let flag of restNode.flags) {
+                                            if (flag.fieldName === "fixed") {
+                                                restNode[TOP_BILL_ID] = flag.flag;
+                                                break;
+                                            }
+                                        }
+                                    }
+                                    rst.push(restNode);
+                                    iter.push(restNode);
+                                }
+                            }
+                        }
+                    }
+                }
             }
+            pushedIds = [];
             for (let i = 0; i < iter.length; i++) {
                 let rtbID = tbID;
                 if (parentItem === null) {

+ 2 - 2
test/unit/reports/test_tpl_09.js

@@ -25,10 +25,10 @@ cfgCacheUtil.setupDftCache();
 let fsUtil = require("../../../public/fsUtil");
 
 let demoPrjId = - 1;
-let demoRptId = 232, pagesize = "A4";
+let demoRptId = 444, pagesize = "A4";
 
 // demoPrjId = 720; //QA: DW3
-demoPrjId = 2260; //QA:
+demoPrjId = 4563; //QA:
 //*/
 // let userId_Leng = "59cdf14a0034a1000ba52b97"; //小冷User Id 换成_id了
 let userId_Leng = "5acac1e885bf55000bd055ba";

+ 12 - 9
web/building_saas/main/js/models/ration_ass.js

@@ -98,33 +98,36 @@ var ration_ass = {
             updateData.push(newobj);
             return updateData;
         };
-        ration_ass.prototype.updateActualValue=function(assList,index,newVal){
+        ration_ass.prototype.updateActualValue=function(assList,index,newVal,isAdjust = 1){//修改实际值默认打勾
             let me = this;
             var selected = projectObj.project.mainTree.selected;
-            assList[index].actualValue=newVal;
+            let newList = _.cloneDeep(assList);
+            if(gljUtil.isDef(newVal))newList[index].actualValue=newVal;
+            newList[index].isAdjust = isAdjust;
             var rationname = selected.data.name;
             if(selected.data.hasOwnProperty('caption')){
-                 rationname = selected.data.caption.replace('%s',newVal);
+                 if(isAdjust == 1) newVal =  newList[index].stdValue;//如果是取消打勾,名字恢复成实际值
+                 rationname =  selected.data.caption.replace('%s',newVal);
             }
             var query = {
-                'ration':selected.data,
-                'editAss':assList[index],
+                'ration':{projectID:selected.data.projectID,ID:selected.data.ID},
+                'editAss':newList[index],
                 'editIndex':index
             };
             var doc ={
-                rationAssList:assList,
+                rationAssList:newList,
                 name:rationname
             };
 
             var updateData = this.getUpdateData('ut_update',query,doc);
             $.bootstrapLoading.start();
             CommonAjax.post("/ration/updateRationAss",updateData[0],function (result) {
+                //更新缓存
+                selected.data.rationAssList = newList;
                 $.bootstrapLoading.end();
                 zmhs_obj.refreshAfterUpdate(result);
-                zmhs_obj.showAssData();
+                zmhs_obj.showDatas();
             })
-           // project.pushNow('updateRationAss',[this.getSourceType()],updateData);
-
         };
         return new ration_ass(project);
     }

+ 24 - 5
web/building_saas/main/js/views/zmhs_view.js

@@ -21,7 +21,9 @@ let zmhs_obj = {
             forContent:function (item) {//所选人材机,内容和条件互换位置
                if(gljUtil.isDef(item.option_codes)&&item.option_codes!=""){
                    return item.name;
-               }else {
+               }else if(item.assistCode &&item.assistCode!="" ){//是辅助定额行,显示实际值
+                    return item.actualValue;
+               } else {
                    return item.content;
                }
             },
@@ -54,6 +56,7 @@ let zmhs_obj = {
     },
     assSpread:null,
     assSheet:null,
+    assFirstIndex:0,
     assSheetData: [],
     assSetting: {
         header: [
@@ -78,7 +81,7 @@ let zmhs_obj = {
             this.coeSheet = this.coeSpread.getSheet(0);
             sheetCommonObj.initSheet(this.coeSheet, this.coeSetting, 30);
             this.coeSheet.name('ration_coe');
-            this.coeSheet.bind(GC.Spread.Sheets.Events.CellClick, this.onCoeCellClick);
+            //this.coeSheet.bind(GC.Spread.Sheets.Events.CellClick, this.onCoeCellClick);  配合自定义系数使用,现在自定义系数不在这显示了
             this.coeSpread.bind(GC.Spread.Sheets.Events.ButtonClicked, this.onButtonClick);
             this.coeSheet.bind(GC.Spread.Sheets.Events.ValueChanged,this.onCoeValueChange);
             this.coeSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e,args) {
@@ -120,6 +123,9 @@ let zmhs_obj = {
             let ration = selected.data;
             coeList = ration_coe.getCoeByRationID(ration.ID);
             _.remove(coeList,{"coeID":-1})//2018-12-24 新需求,把自定义乘系数分离出来,这里排除自定义乘系数行
+            this.assFirstIndex = coeList.length;//辅助定额的起始下标
+            coeList = coeList.concat(this.getAssList(node))  //2019-01-23 新需求,将辅助定额合并到一个表显示
+
         }
         this.coeSheet.setRowCount(0);
         sheetCommonObj.showData(this.coeSheet, this.coeSetting,coeList);
@@ -130,6 +136,8 @@ let zmhs_obj = {
                 if(gljUtil.isDef(coeList[i].option_codes)&&coeList[i].option_codes!=""){
                     this.getComboBoxForCodes(coeList[i],i);//设置可选类型的下拉框
                     //  sheet.setValue(row, col, val, ch);
+                } else if(coeList[i].assistCode && coeList[i].assistCode !=''){//是辅助定额列
+                    this.coeSheet.getCell(i, 2, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                 } else if(coeList[i].coeID == -1){ //自定义系数列
                     this.coeSheet.getCell(i, 1, GC.Spread.Sheets.SheetArea.viewport).locked(false);
                     this.coeSheet.setCellType(i, 1, sheetCommonObj.getCustomerCoeCellType(this.generateHtmlString,this.bindCusEditorValue,this.updateCusCoeAfterEditor), GC.Spread.Sheets.SheetArea.viewport);
@@ -189,6 +197,12 @@ let zmhs_obj = {
             disableSpread(this.assSpread);
         }
     },
+    getAssList:function (node) {
+        let selected = node?node:projectObj.project.mainTree.selected;
+        let assList = selected&&selected.data.rationAssList ? selected.data.rationAssList : [];
+        this.assSheetData = assList;
+        return assList;
+    },
     refreshAfterUpdate:function(result,reload){
         let ration_glj = projectObj.project.ration_glj;
         let calcInstall = false;//是否记录安装增加费
@@ -374,7 +388,7 @@ let zmhs_obj = {
             args.sheet.getCell(args.row, args.col).value(newval);
         }
         let recode = me.coeSheetData[args.row];
-        projectObj.project.ration_coe.adjustCoeClick(recode, newval);
+        recode.assistCode && recode.assistCode != "" ? me.adjustAssClick(args,newval) : projectObj.project.ration_coe.adjustCoeClick(recode, newval);
     },
     generateHtmlString: function (context,cellRect,$editor) {//这里要改成动态的了,根据自定义系数内容生成对应的输入框
         let me = zmhs_obj;
@@ -412,6 +426,8 @@ let zmhs_obj = {
         let recode = zmhs_obj.coeSheetData[args.row];
         if(gljUtil.isDef(recode.option_codes)&&recode.option_codes!=""&& fieldID == 'name'){//说明是选择了下拉框
             projectObj.project.ration_coe.adjustCoeClick(recode, 1,{'select_code':args.newValue});
+        }else if(recode.assistCode &&recode.assistCode!=""){//编辑的是辅助定额
+            zmhs_obj.updateRationAss({editingText:args.newValue,row:args.row - zmhs_obj.assFirstIndex})//转换一下
         }
     },
     onCusValueChange:function (e,args) {
@@ -484,6 +500,10 @@ let zmhs_obj = {
             me.updateRationAss(args);
         }
     },
+    adjustAssClick:function (args,newval) {
+        let me = zmhs_obj, row = args.row - me.assFirstIndex;
+        projectObj.project.ration_ass.updateActualValue(me.assSheetData, row,null,newval);
+    },
     updateRationAss: function (args) {
         var me = zmhs_obj;
         var newval;
@@ -500,8 +520,7 @@ let zmhs_obj = {
             newval = scMathUtil.roundTo(newval, -2);
             projectObj.project.ration_ass.updateActualValue(me.assSheetData, args.row, newval);
         } else {
-            newval = recode.actualValue;
-            me.assSheet.getCell(args.row, args.col).value(newval);
+           me.showDatas()
         }
     },
     checkingActualValue(record, newval){

+ 4 - 1
web/building_saas/report/js/jpc_output.js

@@ -376,7 +376,10 @@ let JpcCanvasOutput = {
         ctx.fillRect(10 + me.offsetX,size[1] + me.offsetY,size[0],10);
     },
     getReportSizeInPixel: function(rptTpl, resolution) {
-        let rst = rptTpl[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
+        let rst = [8.27, 11.69];
+        if (rptTpl && rptTpl[JV.NODE_PAGE_INFO] && rptTpl[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE]) {
+            rst = rptTpl[JV.NODE_PAGE_INFO][JV.NODE_PAGE_SIZE].slice(0);
+        }
         rst[0] = Math.round(resolution[0] * rst[0]);
         rst[1] = Math.round(resolution[0] * rst[1]);
         return rst;

+ 7 - 3
web/building_saas/report/js/rpt_main.js

@@ -258,10 +258,11 @@ let zTreeOprObj = {
         hintBox.waitBox();
         CommonAjax.postEx("report_api/getReport", params, 15000, true,
             function(result){
+                hintBox.unWaitBox();
                 let pageRst = result;
-                if (pageRst) {
+                let canvas = document.getElementById("rptCanvas");
+                if (pageRst && pageRst.items && pageRst.items.length > 0) {
                     me.resetAfter(pageRst);
-                    let canvas = document.getElementById("rptCanvas");
                     me.currentRptPageRst = pageRst;
                     me.maxPages = pageRst.items.length;
                     me.currentPage = 1;
@@ -274,7 +275,10 @@ let zTreeOprObj = {
                         canvas.height = size[1] + 50;
                     }
                     me.showPage(1, canvas);
-                    hintBox.unWaitBox();
+                } else {
+                    //返回了无数据表
+                    JpcCanvasOutput.cleanCanvas(canvas);
+                    JpcCanvasOutput.drawPageBorder(me.currentRptPageRst, canvas, getScreenDPI());
                 }
             }, function(err){
                 hintBox.unWaitBox();