Browse Source

恢复默认列设置,安全文明基数

zhongzewei 7 years ago
parent
commit
33fadf4c94

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

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

+ 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 = '表达式不正确'
             }

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

@@ -1655,6 +1655,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(),
@@ -2318,6 +2345,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);
             }
         });