Browse Source

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

chenshilong 7 years ago
parent
commit
a56dda4cfc

+ 13 - 10
modules/complementary_glj_lib/controllers/gljController.js

@@ -16,17 +16,20 @@ class GljController extends BaseController{
         let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
             rationValuation = sessionCompilation.ration_valuation,
             billValuation = sessionCompilation.bill_valuation,
-            engineeringLibModel = new EngineeringLibModel();
-        if(rationValuation[0]){
-            let engineeringList = rationValuation[0].engineering_list;
-            engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-            let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
-            gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+            engineeringLibModel = new EngineeringLibModel(),
+            valuationIDs = [] ;
+        for(let r of rationValuation){//{ "glj_lib.0": {$exists:1} }
+            if(r.id){
+                valuationIDs.push(r.id);
+            }
+        }
+        for(let b of billValuation){
+            if(b.id){
+                valuationIDs.push(b.id);
+            }
         }
-        else if(billValuation[0]){
-            let engineeringList = billValuation[0].engineering_list;
-            engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-            let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+        if(valuationIDs.length > 0){
+            let engineeringInfo = await engineeringLibModel.findDataByCondition({'valuationID': {"$in": valuationIDs},"glj_lib.0": {$exists:1}});//数组大于0
             gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
         }
         res.render('building_saas/complementary_glj_lib/html/tools-gongliaoji.html',{

+ 16 - 0
modules/main/controllers/project_controller.js

@@ -136,5 +136,21 @@ module.exports = {
             }
             res.json(result);
         })
+    },
+    getDefaultColSetting: async function(req, res){
+        let data = JSON.parse(req.body.data);
+        let result={
+            error: 0,
+            data: null
+        };
+        try{
+            result.data = await project_facade.getDefaultColSetting(data.libID);
+        }
+        catch(err){
+            logger.err(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
     }
 };

+ 7 - 1
modules/main/facade/project_facade.js

@@ -15,13 +15,15 @@ let project_glj_model = mongoose.model('glj_list');
 let ration_glj_facade = require("../../ration_glj/facade/ration_glj_facade");
 const uuidV1 = require('uuid/v1');
 const gljUtil = require('../../../public/gljUtil');
+let stdColSettingModel = mongoose.model('std_main_col_lib');
 
 module.exports = {
     markUpdateProject:markUpdateProject,
     removeProjectMark:removeProjectMark,
     updateNodes:updateNodes,
     calcInstallationFee:calcInstallationFee,
-    saveProperty: saveProperty
+    saveProperty: saveProperty,
+    getDefaultColSetting: getDefaultColSetting
 };
 
 async function calcInstallationFee(data) {
@@ -251,4 +253,8 @@ function saveProperty(data, callback){
             callback('', null);
         }}
     );
+}
+
+async function getDefaultColSetting(libID){
+    return await stdColSettingModel.findOne({ID: libID, deleted: false}, '-_id main_tree_col');
 }

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

@@ -296,12 +296,14 @@ async function addRationGLJ(std,newRation) {
                 newGLJ.unit = std_glj.unit;
                 newGLJ.specs = std_glj.specs;
                 newGLJ.basePrice = std_glj.basePrice;
+                newGLJ.marketPrice = std_glj.basePrice;
                 newGLJ.shortName = std_glj.shortName;
                 newGLJ.type = std_glj.gljType;
                 newGLJ.repositoryId = std_glj.repositoryId;
                 newGLJ.adjCoe = std_glj.adjCoe;
                 newGLJ.materialType = std_glj.materialType;
                 newGLJ.materialCoe = std_glj.materialCoe;
+                newGLJ.createType = 'normal';
                 let info = await  ration_glj_facade.getInfoFromProjectGLJ(newGLJ,unitPriceFileId);
                 newGLJ = ration_glj_facade.createNewRecord(info);
                 newRationGLJList.push(newGLJ);

+ 1 - 0
modules/main/routes/project_route.js

@@ -14,6 +14,7 @@ module.exports = function (app) {
     projectRouter.post('/updateNodes', projectController.updateNodes);
     projectRouter.post('/calcInstallationFee', projectController.calcInstallationFee);
     projectRouter.post('/saveProperty', projectController.saveProperty);
+    projectRouter.post('/getDefaultColSetting', projectController.getDefaultColSetting);
 
     app.use('/project',projectRouter);
 };

+ 12 - 17
modules/ration_glj/facade/ration_glj_facade.js

@@ -125,6 +125,7 @@ function get_lib_glj_info(ration_glj) {
                 ration_glj.unit = glj.unit;
                 ration_glj.specs = glj.specs;
                 ration_glj.basePrice = glj.basePrice;
+                ration_glj.marketPrice = glj.basePrice;
                 ration_glj.shortName = glj.shortName;
                 ration_glj.type = glj.gljType;
                 ration_glj.repositoryId = glj.repositoryId;
@@ -161,8 +162,8 @@ function createNewRecord(ration_glj) {
     newRecoed.original_code = ration_glj.original_code;
     newRecoed.unit = ration_glj.unit;
     newRecoed.specs = ration_glj.specs;
-    newRecoed.from = ration_glj.from ? ration_glj.from : undefined;
-    newRecoed.createType = ration_glj.createType ? ration_glj.createType : undefined;
+    newRecoed.from = ration_glj.from ? ration_glj.from : 'std';
+    newRecoed.createType = ration_glj.createType ? ration_glj.createType : 'normal';
     newRecoed.shortName = ration_glj.shortName;
     newRecoed.billsItemID = ration_glj.billsItemID;
     newRecoed.type = ration_glj.type;
@@ -500,22 +501,16 @@ function save(user_id, datas, callback) {
 }
 
 async function getLibInfo(req) {
-    let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
-        rationValuation = sessionCompilation.ration_valuation,
-        billValuation = sessionCompilation.bill_valuation,
-        engineeringLibModel = new EngineeringLibModel();
-    if (rationValuation[0]) {
-        let engineeringList = rationValuation[0].engineering_list;
-        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
-        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
-    }
-    else if (billValuation[0]) {
-        let engineeringList = billValuation[0].engineering_list;
-        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
-        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+    let gljLibId = null, engineerID, sessionCompilation = req.session.sessionCompilation,
+        engineeringLibModel = new EngineeringLibModel() ;
+    engineerID = req.params.engineerID;
+    if(engineerID){
+        let engineeringInfo = await engineeringLibModel.findDataByCondition({'_id': engineerID});
         gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    }else {
+        throw new Error("工程专业ID为空!");
     }
+
     let data = {
         userID: req.session.sessionUser.id,
         gljLibId: gljLibId,
@@ -575,7 +570,7 @@ function getGLJSearchInfo(ration_glj) {
         type: ration_glj.subType ? ration_glj.subType : ration_glj.type,//如果有subType,则是通过插入定额级的工料机进来的
         type_of_work: ration_glj.subType ? ration_glj.subType : ration_glj.type,
         base_price: ration_glj.basePrice,
-        market_price: ration_glj.basePrice,
+        market_price: ration_glj.marketPrice,
         repositoryId: ration_glj.repositoryId,
         adjCoe: ration_glj.adjCoe,
         materialType:ration_glj.materialType,

+ 1 - 1
modules/ration_glj/routes/ration_glj_route.js

@@ -8,7 +8,7 @@ let rgController = require('../controllers/ration_glj_controller');
 module.exports = function (app) {
 
     var rgRouter = express.Router();
-    rgRouter.get('/getGLJData', rgController.getGLJData);
+    rgRouter.get('/getGLJData/:engineerID', rgController.getGLJData);
     rgRouter.post('/addGLJ',rgController.addGLJ);
     rgRouter.post('/replaceGLJ',rgController.replaceGLJ);
     rgRouter.post('/mReplaceGLJ',rgController.mReplaceGLJ);

+ 34 - 3
modules/reports/controllers/rpt_controller.js

@@ -264,6 +264,37 @@ module.exports = {
             callback(req, res, err, pageRst);
         });
     },
+    getMultiReports: function (req, res) {
+        let params = JSON.parse(req.body.params),
+            prj_id = params.prj_id,
+            rpt_ids = params.rpt_ids.split(','),
+            customizeCfg = params.custCfg,
+            option = params.option;
+        let user_id = req.session.sessionUser.id;
+        let parallelFucs = [];
+        let dftOption = option||JV.PAGING_OPTION_NORMAL;
+        for (let id of rpt_ids) {
+            parallelFucs.push((function (rpt_id) {
+                return function (cb) {
+                    getAllPagesCommon(user_id, prj_id, rpt_id, null, null, customizeCfg, dftOption, function (err, pageRst) {
+                        if(err){
+                            cb(err);
+                        }
+                        else{
+                            cb(null, pageRst);
+                        }
+                    })
+                }
+            })(parseInt(id)));
+        }
+        async.parallel(parallelFucs, function (err, pageRstArray) {
+            if (err) {
+                callback(req, res, '数据有误', null);
+            } else {
+                callback(req, res, err, pageRstArray);
+            }
+        })
+    },
 
     getReportAllPagesSvg: function (req, res) {
         let params = JSON.parse(req.body.params),
@@ -303,7 +334,7 @@ module.exports = {
                 rpt_xl_util.exportExcel(pageRst, pageSize, rptName, isOneSheet, null, function(newName){
                     res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                     let rptNameURI = encodeURI(rptName);
-                    res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".xlsx\"; filename*=utf-8''" + rptNameURI );
+                    res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".xlsx\"; filename*=utf-8''" + rptNameURI + '.xlsx' );
                     let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.xlsx');
                     filestream.on('data', function(chunk) {
                         res.write(chunk);
@@ -347,7 +378,7 @@ module.exports = {
                 rpt_xl_util.exportExcelInOneBook(pageRstArray, pageSize, rptName, function(tmpFilePath){
                     res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                     let rptNameURI = encodeURI(rptName);
-                    res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".xlsx\"; filename*=utf-8''" + rptNameURI );
+                    res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".xlsx\"; filename*=utf-8''" + rptNameURI + '.xlsx');
                     let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + tmpFilePath + '.xlsx');
                     filestream.on('data', function(chunk) {
                         res.write(chunk);
@@ -462,7 +493,7 @@ module.exports = {
                 res.setHeader('Content-Type', 'application/vnd.openxmlformats');
                 // res.setHeader("Content-Disposition", "attachment; filename=" + strUtil.getPinYinCamelChars(rptName) + ".pdf");
                 let rptNameURI = encodeURI(rptName);
-                res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".pdf\"; filename*=utf-8''" + rptNameURI );
+                res.setHeader("Content-Disposition", "attachment; filename=\"" + rptNameURI + ".pdf\"; filename*=utf-8''" + rptNameURI + ".pdf"  );
 
                 let filestream = fs.createReadStream(__dirname.slice(0, __dirname.length - 28) + '/tmp/' + newName + '.pdf');
                 filestream.on('data', function(chunk) {

+ 1 - 0
modules/reports/routes/report_router.js

@@ -26,6 +26,7 @@ module.exports =function (app) {
     //now is the real:
     rptRouter.post('/getReport', reportController.getReportAllPages);
     rptRouter.post('/getReportSvg', reportController.getReportAllPagesSvg);
+    rptRouter.post('/getMultiReports', reportController.getMultiReports);
     rptRouter.get('/getExcelInOneBook/:prj_id/:rpt_ids/:size/:rptName/:option', reportController.getExcelInOneBook);
     rptRouter.get('/getExcel/:prj_id/:rpt_id/:size/:orientation/:rptName/:isOneSheet/:option', reportController.getExcel);
     rptRouter.get('/getPDF/:prj_id/:rpt_id/:size/:orientation/:rptName', reportController.getPDF);

+ 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

+ 3 - 2
test/unit/reports/test_rpt_test_template.js

@@ -27,8 +27,9 @@ let fsUtil = require("../../../public/fsUtil");
 
 let demoPrjId = - 1;
 // let demoRptId = 279;
-let demoRptId = 275; //测试模板-流水式
+// let demoRptId = 275; //测试模板-流水式
 // let demoRptId = 337; //19表
+let demoRptId = 361; //封1
 let pagesize = "A4";
 //288: 11-2表(新)
 //279: 04
@@ -79,7 +80,7 @@ test('测试 - 测试模板啦: ', function (t) {
                     let maxPages = printCom.totalPages;
                     let pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
                     if (pageRst) {
-                        // fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_测试模板.jsp");
+                        fsUtil.writeObjToFile(pageRst, "D:/GitHome/ConstructionCost/tmp/testBuiltPageResult_测试模板.jsp");
                     } else {
                         console.log("oh! no pages were created!");
                     }

+ 2 - 1
web/building_saas/main/html/main.html

@@ -682,8 +682,9 @@
                                                 </label>
                                             </div>
                                         </fieldset>
-                                        <div id="col_setting_spread" style="height:300px;overflow:hidden">
+                                        <div id="col_setting_spread" style="height:280px;overflow:hidden">
                                         </div>
+                                        <div><a style="margin-left: 5px;" class="btn btn-sm" id="recColSetting" href="javascript:void(0);">恢复默认列设置</a></div>
                                     </div>
                                 </div>
                             </div>

+ 29 - 7
web/building_saas/main/js/models/calc_base.js

@@ -134,21 +134,26 @@ let cbTools = {
         mapObj['CHARGE'] = Object.create(null);
         mapObj['TAX'] = Object.create(null);
         mapObj['OTHERS'] = Object.create(null);
-        let filter = ['CSXMF', 'ZZCSXMF', 'ZZCSXMDEJJZJGCF', 'ZZCSXMDEJJRGF', 'ZZCSXMDEJJCLF', 'ZZCSXMDEJJJXF', 'QTXMF', 'GF', 'SJ', 'SQGCZJ'];
+        mapObj['ENGINEERINGCOST'] = Object.create(null);
+        let filter = ['CSXMF', 'ZZCSXMF', 'ZZCSXMDEJJZJGCF', 'ZZCSXMDEJJRGF', 'ZZCSXMDEJJCLF', 'ZZCSXMDEJJJXF', 'QTXMF', 'GF', 'SJ', 'SQGCZJ', 'AQWMSGZXFY'];
+        //安全文明施工专项费用只有税金和工程造价能用
         for(let figure in baseFigures){
             if(filter.indexOf(baseFigures[figure]['base']) === -1){
                 mapObj['CONSTRUCTION_ORGANIZATION'][figure] = baseFigures[figure];
             }
-            if(baseFigures[figure]['base'] !== 'QTXMF' && baseFigures[figure]['base'] !== 'SQGCZJ'){
+            if(baseFigures[figure]['base'] !== 'QTXMF' && baseFigures[figure]['base'] !== 'SQGCZJ' && baseFigures[figure]['base'] !== 'AQWMSGZXFY'){
                 mapObj['OTHER'][figure] = baseFigures[figure];
             }
-            if(baseFigures[figure]['base'] !== 'GF' && baseFigures[figure]['base'] !== 'SQGCZJ'){
+            if(baseFigures[figure]['base'] !== 'GF' && baseFigures[figure]['base'] !== 'SQGCZJ' && baseFigures[figure]['base'] !== 'AQWMSGZXFY'){
                 mapObj['CHARGE'][figure] = baseFigures[figure];
             }
             if(baseFigures[figure]['base'] !== 'SJ' && baseFigures[figure]['base'] !== 'SQGCZJ'){
                 mapObj['TAX'][figure] = baseFigures[figure];
             }
             if(baseFigures[figure]['base'] !== 'SQGCZJ'){
+                mapObj['ENGINEERINGCOST'][figure] = baseFigures[figure];
+            }
+            if(baseFigures[figure]['base'] !== 'SQGCZJ' && baseFigures[figure]['base'] !== 'AQWMSGZXFY'){
                 mapObj['OTHERS'][figure] = baseFigures[figure];
             }
             if(baseFigures[figure]['base'] === 'SQGCZJ'){
@@ -180,6 +185,9 @@ let cbTools = {
         else if(this.isFlag(node.data) && node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.TAX){
             return calcBase.baseFigureClass.TAX;
         }
+        else if(this.isFlag(node.data) && node.data.flagsIndex.fixed.flag === calcBase.fixedFlag.ENGINEERINGCOST){
+            return calcBase.baseFigureClass.ENGINEERINGCOST;
+        }
         else {
             if(!parent){
                 return calcBase.baseFigureClass.OTHERS;
@@ -525,6 +533,13 @@ let baseFigureTemplate = {
         if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
         return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
     },
+    'AQWMSGZXFY': function (tender) {
+        const totalFeeType = tender ? 'tenderTotalFee' : 'totalFee';
+        let bill = calcBase.fixedBills[calcBase.fixedFlag.SAFETY_CONSTRUCTION]['bill'];
+        if(cbTools.isUnDef(bill) || cbTools.isUnDef(bill.ID)) return 0;
+        if(cbTools.isUnDef(bill.feesIndex) || Object.keys(bill.feesIndex).length === 0) return 0;
+        return cbTools.isDef(bill.feesIndex.common) && cbTools.isDef(bill.feesIndex.common[totalFeeType]) ? bill.feesIndex.common[totalFeeType] : 0;
+    },
     'JZMJ': function () {
         let buildingArea = projFeatureView.getFeature('buildingArea');
         return buildingArea ? parseFloat(buildingArea) : 0;
@@ -1006,6 +1021,7 @@ let baseFigureMap = {
     '其他项目费': {base: 'QTXMF',  fixedFlag: fixedFlag.OTHER, class: 'QTXM'},
     '规费': {base: 'GF', fixedFlag: fixedFlag.CHARGE, class: 'GF'},
     '税金': {base: 'SJ', fixedFlag: fixedFlag.TAX, class: 'SJ'},
+    '安全文明施工专项费用': {base: 'AQWMSGZXFY', fixedFlag: fixedFlag.SAFETY_CONSTRUCTION, class: 'CSXM'},
     //不于清单直接关联==========
     '建筑面积': {base: 'JZMJ', class: 'FBFX'},
     '税前工程造价': {base: 'SQGCZJ', class: 'SQGCZJ'},//安全文明施工专项费用使用
@@ -1187,9 +1203,12 @@ let cbAnalyzer = {
         }
         //转换成ID引用
         exp = cbParser.toIDExpr(exp);
-        if(this.cycleCalc(node, cbTools.getFigure(node), exp)){
+        if(this.cycleCalc(node, calcBase.baseFigures, exp)){
             throw '出现循环计算';
         }
+       /*  if(this.cycleCalc(node, cbTools.getFigure(node), exp)){
+            throw '出现循环计算';
+        }*/
         return exp;
      /*   if(this.inputLegal(exp)){
             if(this.arithmeticLegal(exp)){
@@ -1374,15 +1393,15 @@ let cbParser = {
         let exps = [];
         for(let i = 0, len = strs.length; i < len; i++){
             let exp = Object.create(null);
-            exp.orgExp = strs[i];
+            exp.orgExp = `{${strs[i]}}`;
             exps.push(exp);
         }
         //去{}
-        v = v.replace(/[{, },]/g, '');
+        //v = v.replace(/[{, },]/g, '');
         for(let i = 0, len = exps.length;i < len; i++){
             exps[i].compileExp = '$CBC.base(\'' + exps[i].orgExp + '\')';
             //暂估材料费作特殊处理
-            if(exps[i].orgExp === '暂估材料费(从子目汇总)' || exps[i].orgExp === '暂估材料费(从工料机汇总表汇总)'){
+            if(exps[i].orgExp === '{暂估材料费(从子目汇总)}' || exps[i].orgExp === '{暂估材料费(从工料机汇总表汇总)}'){
                 let reCount = v.split(exps[i].orgExp).length - 1;
                 while (reCount > 0){
                     v = v.replace(exps[i].orgExp, exps[i].compileExp);
@@ -1393,6 +1412,8 @@ let cbParser = {
                 v = v.replace(new RegExp(exps[i].orgExp, 'g'), exps[i].compileExp);
             }
         }
+        //去{}
+        v = v.replace(/[{, },]/g, '');
         //行引用
         let fidArr = this.getFIDArr(v);
         let fExps = [];
@@ -1514,6 +1535,7 @@ let calcBase = {
             node.changed = true;
         }
         catch (err){
+            console.log(err);
             if(typeof err === 'object'){
                 err = '表达式不正确'
             }

+ 2 - 0
web/building_saas/main/js/models/project_glj.js

@@ -678,6 +678,7 @@ ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
         var nodes = _.filter(projectObj.project.mainTree.items, function (tem) {
             if (tem.sourceType == ModuleNames.ration_glj && tem.data.projectGLJID == data.id) {
                 tem.data.marketUnitFee = data.unit_price.market_price;
+                tem.data.marketPrice = data.unit_price.market_price;
                 return true;
             }
         })
@@ -720,6 +721,7 @@ ProjectGLJ.prototype.getImpactRationNodes = function (gljs) {
                 let tem_g = gljMap[item.data.projectGLJID];
                 if(tem_g){
                     item.data.marketUnitFee = this.getMarketPrice(tem_g);//这里要按计算的市场价为准,不能直接取
+                    item.data.marketPrice = this.getMarketPrice(tem_g);
                     nodes.push(item);
                 }
             } else if (rationMap[item.data.ID] == true) {  //受影响的定额

+ 7 - 2
web/building_saas/main/js/models/ration_glj.js

@@ -500,7 +500,8 @@ var ration_glj = {
             projectObj.mainController.refreshTreeNode(nodes);
         };
         ration_glj.prototype.getGLJData = function (cb) {
-            CommonAjax.get('/rationGlj/getGLJData', function (data) {
+            let engineerID = projectInfoObj.projectInfo.property.engineering_id;
+            CommonAjax.get('/rationGlj/getGLJData/'+engineerID, function (data) {
                 cb(data);
             })
         };
@@ -543,6 +544,7 @@ var ration_glj = {
                         specs: glj.specs,
                         subType: glj.gljType,
                         basePrice: glj.basePrice,
+                        marketPrice:glj.basePrice,
                         original_code: glj.code,
                         shortName: glj.shortName,
                         serialNo: serialNo,
@@ -617,6 +619,7 @@ var ration_glj = {
                     unit: glj.unit,
                     specs: glj.specs,
                     basePrice: glj.basePrice,
+                    marketPrice:glj.basePrice,
                     shortName: glj.shortName,
                     type: glj.gljType,
                     adjCoe: glj.adjCoe,
@@ -648,7 +651,7 @@ var ration_glj = {
             if (selectCode == gljOprObj.getIndex(oldData, gljKeyArray)) {
                 return callback(null);
             }
-            if (oldData.createType == 'normal') {//只有是定额下带的工料机才需把类型改成替换,其它的保持不变
+            if (oldData.createType===undefined || oldData.createType == 'normal') {// createTypel 默认是normal 只有是定额下带的工料机才需把类型改成替换,其它的保持不变
                 oldData.rcode = oldData.code;
                 oldData.createType = 'replace';
             }
@@ -659,6 +662,7 @@ var ration_glj = {
             oldData.unit = glj.unit;
             oldData.specs = glj.specs;
             oldData.basePrice = glj.basePrice;
+            oldData.marketPrice = glj.basePrice;
             oldData.repositoryId = glj.repositoryId;
             oldData.materialType = glj.materialType;
             oldData. materialCoe =  glj.materialCoe;
@@ -707,6 +711,7 @@ var ration_glj = {
                 specs: glj.specs,
                 type: glj.gljType,
                 basePrice: glj.basePrice,
+                marketPrice:glj.basePrice,
                 repositoryId: glj.repositoryId,
                 materialType: glj.materialType,   //三材类别
                 materialCoe: glj.materialCoe,

+ 28 - 0
web/building_saas/main/js/views/project_view.js

@@ -1663,6 +1663,33 @@ $('#poj-set').on('show.bs.modal', function () {
         calcOptions.init();
     }
 });
+
+//恢复默认列设置
+$('#recColSetting').click(function () {
+    let libID = projectObj.project.property.colLibID ? projectObj.project.property.colLibID : null;
+    if(!libID){
+        alert('项目没有绑定标准列设置');
+        return;
+    }
+    $(this).addClass('disabled');
+    CommonAjax.post('/project/getDefaultColSetting', {libID: libID}, function (rstData) {
+        if(!rstData || rstData.length === 0){
+            alert('标准列设置没有数据');
+            $('#recColSetting').removeClass('disabled');
+            return;
+        }
+        let sheet = colSettingObj.settingSpread.getActiveSheet();
+        SheetDataHelper.massOperationSheet(sheet, function () {
+            for(let row = 0; row < sheet.getRowCount(); row++){
+                sheet.setValue(row, 0, rstData.main_tree_col.cols[row].visible);
+            }
+        });
+        $('#recColSetting').removeClass('disabled');
+    }, function () {
+        $('#recColSetting').removeClass('disabled');
+    });
+});
+
 $('#property_ok').click(function () {
     let project = projectObj.project,
         projectID = project.ID(),
@@ -2345,6 +2372,7 @@ function disableTools(){
     $('#std_labour_coe_files').prop('disabled', 'disabled');
     //呈现选项
     $('#display-setting').find('input').prop('disabled', 'disabled');
+    $('#recColSetting').remove();
     //项目属性确定
     $('#property_ok').addClass('disabled');
     //特征及内容

+ 1 - 1
web/building_saas/main/js/views/std_billsGuidance_lib.js

@@ -554,7 +554,7 @@ const billsGuidance = (function () {
     function bindBtn(){
         //打开清单指引库
         $('#stdBillsGuidanceTab').click(function () {
-            if(libSel.children().length === 0 && !projectReadOnly){
+            if(libSel.children().length === 0 && !projectReadOnly && !$(this).hasClass('disabled')){
                 initLibs(projectInfoObj.projectInfo.engineeringInfo.billsGuidance_lib);
             }
         });

+ 2 - 2
web/building_saas/report/html/rpt_main.html

@@ -43,13 +43,13 @@
                                 <div class="btn-group" role="group">
                                     <button id="btnRptOrientation" type="button" class="btn btn-outline-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">纵向</button>
                                     <div class="dropdown-menu" aria-labelledby="btnGroupDrop1">
-                                        <a class="dropdown-item" id="hrefRptOrientation" onclick="zTreeOprObj.changeOrientation(this)">横向</a>
+                                        <a class="dropdown-item" id="hrefRptOrientation" style="cursor:pointer" onclick="zTreeOprObj.changeOrientation(this)">横向</a>
                                     </div>
                                 </div>
                                 <div class="btn-group" role="group">
                                     <button id="btnRptPageSize" type="button" class="btn btn-outline-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">A4</button>
                                     <div class="dropdown-menu" aria-labelledby="btnGroupDrop2">
-                                        <a class="dropdown-item" id="hrefRptPageSize" onclick="zTreeOprObj.changePageSize(this)">A3</a>
+                                        <a class="dropdown-item" id="hrefRptPageSize" style="cursor:pointer" onclick="zTreeOprObj.changePageSize(this)">A3</a>
                                     </div>
                                 </div>
                             </div>

+ 52 - 65
web/building_saas/report/html/rpt_print.html

@@ -38,83 +38,70 @@
 <script type="text/javascript" src="/web/building_saas/report/js/rpt_print.js"></script>
 <SCRIPT type="text/javascript">
     function loading() {
-        if (sessionStorage.currentPageData) {
-            let pageData = JSON.parse(sessionStorage.currentPageData);
+        if (sessionStorage.multiRptsData) {
+            let multiRptData = JSON.parse(sessionStorage.multiRptsData);
             let scaleFactor = parseInt(sessionStorage.scaleFactor);
-            $(document).attr("title", pageData[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME]);
-            let orgHeight = 793, orgWidth = 1122;
-            let pageHeight = orgHeight * scaleFactor, pageWidth = orgWidth * scaleFactor;
-            if (sessionStorage.pageSize === 'A3') {
-                pageHeight = orgWidth * scaleFactor;
-                pageWidth = orgHeight * 2 * scaleFactor;
-                orgHeight = 1122;
-                orgWidth = 793 * 2;
-            } else if (sessionStorage.pageSize === '自定义') {
-                //自定义
-            }
-            if (sessionStorage.orientation === "纵向") {
-                let tmpInt = pageHeight;
-                pageHeight = pageWidth;
-                pageWidth = tmpInt;
-
-                tmpInt = orgWidth;
-                orgWidth = orgHeight;
-                orgHeight = tmpInt;
+            let svgArr = [];
+            for (let idx = 0; idx < multiRptData.length; idx++) {
+                let pageData = multiRptData[idx];
+                if (idx === 0) {
+                    $(document).attr("title", pageData[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME]);
+                }
+                svgArr = svgArr.concat(rptPrintHelper.buildSvgArr(pageData, -30, -30));
             }
-
+            showPreviewData(svgArr, scaleFactor, sessionStorage.pageSize, sessionStorage.orientation);
+            window.print();
+        } else if (sessionStorage.currentPageData) {
+            let pageData = JSON.parse(sessionStorage.currentPageData);
+            let scaleFactor = parseInt(sessionStorage.scaleFactor);
             let svgArr = rptPrintHelper.buildSvgArr(pageData, -30, -30);
-            for (let i = 0; i < pageData.items.length; i++) {
-                let div = $('<div class="pageBreak"></div>');
-                div.append($(svgArr[i].join("")));
-                $("body").append(div);
-            }
-            $(document.body).find("div").each(function(index,element){
-                $(element).find("svg").each(function(cIdx,elementSvg){
-                    elementSvg.setAttribute('height', pageHeight);
-                    elementSvg.setAttribute('width', pageWidth);
-                });
-            });
+            $(document).attr("title", pageData[JV.NODE_PAGE_INFO][JV.NODE_MAIN_INFO_RPT_NAME]);
+            showPreviewData(svgArr, scaleFactor, sessionStorage.pageSize, sessionStorage.orientation);
             window.print();
-        } if (sessionStorage.currentPageSvgData) {
+        } else if (sessionStorage.currentPageSvgData) {
             let svgArr = JSON.parse(sessionStorage.currentPageSvgData);
             let scaleFactor = 1;
-            let orgHeight = 793, orgWidth = 1122;
-            let pageHeight = orgHeight * scaleFactor, pageWidth = orgWidth * scaleFactor;
-            if (sessionStorage.pageSize === 'A3') {
-                pageHeight = orgWidth * scaleFactor;
-                pageWidth = orgHeight * 2 * scaleFactor;
-                orgHeight = 1122;
-                orgWidth = 793 * 2;
-            } else if (sessionStorage.pageSize === '自定义') {
-                //自定义
-            }
-            if (sessionStorage.orientation === "纵向") {
-                let tmpInt = pageHeight;
-                pageHeight = pageWidth;
-                pageWidth = tmpInt;
-
-                tmpInt = orgWidth;
-                orgWidth = orgHeight;
-                orgHeight = tmpInt;
-            }
-
-            for (let i = 0; i < svgArr.length; i++) {
-                let div = $('<div class="pageBreak"></div>');
-                div.append($(svgArr[i].join("")));
-                $("body").append(div);
-            }
-            $(document.body).find("div").each(function(index,element){
-                $(element).find("svg").each(function(cIdx,elementSvg){
-                    elementSvg.setAttribute('height', pageHeight);
-                    elementSvg.setAttribute('width', pageWidth);
-                });
-            });
+            showPreviewData(svgArr, scaleFactor, sessionStorage.pageSize, sessionStorage.orientation);
             window.print();
         } else {
             //alert("没有报表数据!");
         }
     }
 
+    function showPreviewData(svgArr, scaleFactor, pageSize, orientation) {
+        let orgHeight = 793, orgWidth = 1122;
+        let pageHeight = orgHeight * scaleFactor, pageWidth = orgWidth * scaleFactor;
+        if (pageSize === 'A3') {
+            pageHeight = orgWidth * scaleFactor;
+            pageWidth = orgHeight * 2 * scaleFactor;
+            orgHeight = 1122;
+            orgWidth = 793 * 2;
+        } else if (pageSize === '自定义') {
+            //自定义
+        }
+        if (orientation === "纵向") {
+            let tmpInt = pageHeight;
+            pageHeight = pageWidth;
+            pageWidth = tmpInt;
+
+            tmpInt = orgWidth;
+            orgWidth = orgHeight;
+            orgHeight = tmpInt;
+        }
+
+        for (let i = 0; i < svgArr.length; i++) {
+            let div = $('<div class="pageBreak"></div>');
+            div.append($(svgArr[i].join("")));
+            $("body").append(div);
+        }
+        $(document.body).find("div").each(function(index,element){
+            $(element).find("svg").each(function(cIdx,elementSvg){
+                elementSvg.setAttribute('height', pageHeight);
+                elementSvg.setAttribute('width', pageWidth);
+            });
+        });
+    }
+
     function closing() {
         //
     }

+ 37 - 7
web/building_saas/report/js/rpt_print.js

@@ -4,15 +4,45 @@
 
 let rptPrintHelper = {
     preview: function () {
-        if (zTreeOprObj.currentRptPageRst) {
-            sessionStorage.currentPageData = JSON.stringify(zTreeOprObj.currentRptPageRst);
-            sessionStorage.pageSize = rptControlObj.getCurrentPageSize();
-            sessionStorage.orientation = rptControlObj.getCurrentOrientation();
-            sessionStorage.scaleFactor = 1;
-            window.open('/rpt_print');
+        if (zTreeOprObj.checkedRptTplNodes && zTreeOprObj.checkedRptTplNodes.length > 0) {
+            let rptIds = [];
+            let params = {};
+            params.custCfg = zTreeOprObj.reportPageCfg;
+            params.prj_id = projectInfoObj.projectInfo.ID;
+            for (let tplNode of zTreeOprObj.checkedRptTplNodes) {
+                rptIds.push(tplNode.refId);
+            }
+            params.rpt_ids = rptIds.join(",");
+            CommonAjax.postEx("report_api/getMultiReports", params, 10000, true,
+                function(result){
+                    //sessionStorage.currentPageData = JSON.stringify(zTreeOprObj.currentRptPageRst);
+                    sessionStorage.multiRptsData = JSON.stringify(result);
+                    sessionStorage.pageSize = rptControlObj.getCurrentPageSize();
+                    sessionStorage.orientation = rptControlObj.getCurrentOrientation();
+                    sessionStorage.scaleFactor = 1;
+                    window.open('/rpt_print');
+                },
+                function(failRst){
+                    sessionStorage.currentPageData = null;
+                    console.log(failRst);
+                },
+                function(exceptionRst){
+                    sessionStorage.currentPageData = null;
+                    console.log(exceptionRst);
+                }
+            );
         } else {
-            sessionStorage.currentPageData = null;
+            //不可能的branch
         }
+        // if (zTreeOprObj.currentRptPageRst) {
+        //     sessionStorage.currentPageData = JSON.stringify(zTreeOprObj.currentRptPageRst);
+        //     sessionStorage.pageSize = rptControlObj.getCurrentPageSize();
+        //     sessionStorage.orientation = rptControlObj.getCurrentOrientation();
+        //     sessionStorage.scaleFactor = 1;
+        //     window.open('/rpt_print');
+        // } else {
+        //     sessionStorage.currentPageData = null;
+        // }
     },
     previewSvgData: function() {
         //