Selaa lähdekoodia

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

zhongzewei 7 vuotta sitten
vanhempi
commit
0cc7802a45

+ 1 - 0
config/gulpConfig.js

@@ -80,6 +80,7 @@ module.exports = {
         'web/building_saas/main/js/models/ration_ass.js',
         // 'web/building_saas/main/js/models/volume_price.js',
         'web/building_saas/main/js/models/labour_coe.js',
+        'web/building_saas/main/js/models/installation_fee.js',
         'public/web/id_tree.js',
         'web/building_saas/main/js/models/cache_tree.js',
         'web/building_saas/main/js/calc/calc_fees.js',

+ 99 - 0
modules/main/facade/installation_facade.js

@@ -0,0 +1,99 @@
+/**
+ * Created by zhang on 2018/1/31.
+ */
+import {installSectionModel,installFeeItemModel} from "../../complementary_ration_lib/models/schemas";
+import installationFeeModel from "../models/installation_fee";
+import engineeringModel from "../../users/models/schema/engineering_lib";
+const uuidV1 = require('uuid/v1');
+let consts = require('../../main/models/project_consts')
+
+module.exports={
+    copyInstallationFeeFromLib:copyInstallationFeeFromLib,
+    getData:getData
+};
+
+async function copyInstallationFeeFromLib(projectID,engineering_id) {
+
+    //安装增加费用内嵌文档的方式
+    let engineering = await engineeringModel.findById(engineering_id);
+    let ration_lib = engineering.ration_lib;
+    let installationFeeList = [];
+    for(let rl of ration_lib){
+       let installFeeItems = await installFeeItemModel.find({'rationRepId':rl.id});
+       let installSections = await installSectionModel.find({'rationRepId':rl.id});
+       let newInstallationFee = {
+           libID:rl.id,
+           libName:rl.name,
+           projectID:projectID
+       };
+        newInstallationFee.ID = uuidV1();
+       let create = false;
+       if(installFeeItems && installFeeItems.length > 0) {//费用项
+           create = true;
+           let tem_installFeeItem = [];
+           for(let ifee of installFeeItems){
+                let tem_fee ={
+                    feeItem:ifee.feeItem,
+                    feeType:ifee.feeType,
+                    position:ifee.position,
+                    ID:ifee.ID
+                };
+               tem_installFeeItem.push(tem_fee);
+           }
+           newInstallationFee.installFeeItem = tem_installFeeItem;
+       }
+
+       if(installSections && installSections.length > 0){//章节项
+           create = true;
+           let tem_installSections = [];
+           let tem_feeRules = [];
+           for(let isect of installSections){
+                let tem_sec={
+                    ID:isect.ID,
+                    feeItemId:isect.feeItemId,
+                    name:isect.name
+                };
+                if(isect.feeRule && isect.feeRule.length > 0){//规则项
+                    tem_sec.feeRuleId = isect.feeRule[0].ID; //选中第一个
+                    for(let ifeeR of isect.feeRule){
+                        let tem_feeRule = {
+                            ID: ifeeR.ID,
+                            code: ifeeR.code,
+                            rule: ifeeR.rule,
+                            base: ifeeR.base,
+                            feeRate: ifeeR.feeRate,
+                            labour: ifeeR.labour,
+                            material: ifeeR.material,
+                            machine: ifeeR.machine
+                        };
+                        tem_feeRule.sectionId = isect.ID;
+                        tem_feeRule.feeItemId = isect.feeItemId;
+                        tem_feeRules.push(tem_feeRule);
+                    }
+                }
+               tem_installSections.push(tem_sec);
+           }
+           newInstallationFee.installSection = tem_installSections;
+           newInstallationFee.feeRule = tem_feeRules;
+       }
+       if(create==true){
+           installationFeeList.push(newInstallationFee);
+       }
+    }
+    console.log(installationFeeList);
+    if(installationFeeList.length > 0){
+        await installationFeeModel.insertMany(installationFeeList);
+    }
+}
+
+function getData(projectID, callback) {
+    installationFeeModel.find({'projectID': projectID}, (err, datas) => {
+        if (err) {
+            callback(1, '', null);
+        } else {
+            callback(0, consts.projectConst.INSTALLATION_FEE, datas);
+        }
+    })
+}
+
+

+ 51 - 0
modules/main/models/installation_fee.js

@@ -0,0 +1,51 @@
+/**
+ * Created by Zhong on 2017/9/13.
+ */
+import mongoose from "mongoose";
+let Schema = mongoose.Schema;
+
+//安装增加费-费用规则
+let feeRuleSchema = new Schema({
+    ID: String,
+    sectionId: String, //分册章节id
+    feeItemId:String,
+    code: String,
+    rule: String,
+    base: String,
+    feeRate: Number,
+    labour: Number,
+    material: Number,
+    machine: Number
+});
+
+//安装增加费-分册章节
+let installSectionSchema = new Schema({
+    ID: String,
+    feeItemId: String,
+    feeRuleId: String,
+    name: String,
+    position: String//记取位置
+});
+
+//安装增加费-费用项
+let installFeeItemSchema = new Schema({
+    ID: String,
+    feeItem: String, //费用项
+    feeType: String, //费用类型
+    position: String//记取位置
+});
+
+let installationFeeSchema = new Schema({
+    ID:String,
+    libID:Number,
+    libName:String,
+    projectID:String,
+    installFeeItem:[installFeeItemSchema],
+    installSection:[installSectionSchema],
+    feeRule:[feeRuleSchema]
+},{versionKey:false});
+
+let installationFeeModel = mongoose.model("installation_fee",installationFeeSchema,"installation_fee");
+
+
+export{ installationFeeModel as default}

+ 2 - 0
modules/main/models/project.js

@@ -15,6 +15,7 @@ let projSetting = require('./proj_setting_model');
 var labour_coe_facade = require('../facade/labour_coe_facade');
 var calc_program_facade = require('../facade/calc_program_facade');
 import GLJController from "../../glj/controllers/glj_controller";
+let installation_facade = require('../facade/installation_facade');
 
 
 const ProjectModel = require('../../pm/models/project_model').project;
@@ -40,6 +41,7 @@ moduleMap[projectConsts.FEERATE] = fee_rate_data;
 moduleMap[projectConsts.LABOUR_COE] = labour_coe_facade;
 moduleMap[projectConsts.CALC_PROGRAM] = calc_program_facade;
 moduleMap[projectConsts.PROJECTGLJ] = new GLJController();
+moduleMap[projectConsts.INSTALLATION_FEE] = installation_facade;
 
 var Project = function (){};
 

+ 2 - 1
modules/main/models/project_consts.js

@@ -16,7 +16,8 @@ let projectConst = {
     // VOLUMEPRICE: 'volume_price',
     FEERATE:'feeRate',
     LABOUR_COE:'labour_coe',
-    CALC_PROGRAM:'calc_program'
+    CALC_PROGRAM:'calc_program',
+    INSTALLATION_FEE:'installation_fee'
 };
 
 let projectConstList = [

+ 6 - 0
modules/pm/models/project_model.js

@@ -22,6 +22,7 @@ let copyProjController = require('../controllers/copy_proj_controller');
 let feeRateFacade = require('../../fee_rates/facade/fee_rates_facade');
 let labourCoeFacade = require('../../main/facade/labour_coe_facade');
 let calcProgramFacade = require('../../main/facade/calc_program_facade');
+let installationFacade = require('../../main/facade/installation_facade');
 let logger = require("../../../logs/log_helper").logger;
 let BillsModel = require("../../main/models/bills").model;
 
@@ -140,6 +141,11 @@ ProjectsDAO.prototype.updateUserProjects = async function (userId, compilationId
                     data.updateData.property.zanguCalcMode = 0;
                     //计算选项
                     data.updateData.property.calcOptions = calcOptions
+                    //安装增加费
+                    if(parseInt(data.updateData.property.engineering)==4){
+                        await installationFacade.copyInstallationFeeFromLib(data.updateData.ID,data.updateData.property.engineering_id);
+                    }
+
 
                 }
                 newProject = new Projects(data.updateData);

+ 10 - 1
modules/ration_glj/models/ration_glj_temp.js

@@ -122,6 +122,12 @@ var rationAssItemSchema = mongoose.Schema({
     maxValue: String
 }, { _id: false });
 
+//定额安装增加费用
+let rationInstSchema = mongoose.Schema({
+    feeItemId: String,
+    sectionId: String
+},{_id: false});
+
 var rationItemSchema = mongoose.Schema({
     ID:Number,
     code: String,
@@ -132,9 +138,12 @@ var rationItemSchema = mongoose.Schema({
     rationRepId: Number,
     caption: String,
     feeType: Number,
+    jobContent: String,
+    annotation: String,
     rationGljList: [rationGljItemSchema],
     rationCoeList: Array,
-    rationAssList: [rationAssItemSchema]
+    rationAssList: [rationAssItemSchema],
+    rationInstList: [rationInstSchema]
 });
 mongoose.model("std_ration_lib_ration_items",rationItemSchema, "std_ration_lib_ration_items");
 

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

@@ -874,9 +874,28 @@
                 <div class="modal-body">
                     <div style="height:200px"><!--sjs id设置在这个div-->
                         <div class="row">
-                            <div class="modal-auto-height col-8" style="overflow: hidden" id="">
+                            <div class="modal-auto-height col-8" style="overflow: hidden" id="feeItemSheet">
                                 test ....
                             </div>
+                            <div class="modal-auto-height col-4" style="overflow: hidden" id="install_setting">
+                                <div style="height: 100px;border:1px solid #f00" >
+                                    <fieldset class="form-group" >
+                                        <h5>分项费用</h5>
+                                        <div class="form-check">
+                                            <label class="form-check-label">
+                                                <input class="form-check-input" name="install_setting_radios" id="all_project_calc" value="0" type="radio">
+                                                整个项目统一计取
+                                            </label>
+                                        </div>
+                                        <div class="form-check">
+                                            <label class="form-check-label">
+                                                <input class="form-check-input" name="install_setting_radios" id="FB_calc" value="1" type="radio">
+                                                每个分部单独计取
+                                            </label>
+                                        </div>
+                                    </fieldset>
+                                </div>
+                            </div>
                         </div>
                         <!--<table class="table table-sm table-bordered m-0">
                             <thead><tr><th></th><th>计取</th><th>费用项</th><th>费用类型</th><th>记取位置</th></tr></thead>

+ 70 - 157
web/building_saas/main/js/models/calc_program.js

@@ -553,7 +553,6 @@ const rationCalcBases = {
 
 let analyzer = {
     calcTemplate: null,
-    success: true,
 
     standard: function(expr){
         let str = expr;
@@ -587,47 +586,59 @@ let analyzer = {
     isCycleCalc: function (expr) {     // @5+@6  这里已经是ID引用
         let me = this;
         
-        function checkCycle() {
-            
-        }
-        let atIDArr = me.getAtIDArr(expr);
-        for (let atID of atIDArr){
-            let ID = atID.slice(1);
-            let item = me.calcTemplate.compiledCalcItems[ID];
-            let expression = item.expression;
-            if (expression.includes(atID)) return false;
-
+        function isCycle(nodeExpr) {
+            let atIDArr = me.getAtIDArr(nodeExpr);
+            for (let atID of atIDArr){
+                let ID = atID.slice(1);
+                let item = me.calcTemplate.compiledCalcItems[ID];
+                if (item.expression.includes(atID)) {
+                    return true;
+                }
+                else {
+                    isCycle(item.expression);
+                }
+            };
+            return false;
         };
+
+        return isCycle(expr);
     },
-    isLegal: function (expr) {
+    isLegal: function (expr) {   // 调用前必须先标准化
         let me = this;
-        let stdExpr = me.standard(expr);
 
         let invalidChars = /[^0-9\u4e00-\u9fa5\+\-\*\/\(\)\.\[\]F%]/g;
-        if (invalidChars.test(stdExpr)){
+        if (invalidChars.test(expr)){
             alert('表达式中含有无效的字符!');
             return false;
         };
 
         let pattCn = new RegExp(/[\u4E00-\u9FA5]+/gi);
-        let arrCn = stdExpr.match(pattCn);
+        let arrCn = expr.match(pattCn);
         let pattBase = new RegExp(/\[[\u4E00-\u9FA5]+\]/gi);
-        let arrBase = stdExpr.match(pattBase);
+        let arrBase = expr.match(pattBase);
         if (arrCn.length != arrBase.length){
-            alert('定额基数必须用“[]”括起来!');
+            for (let cn of arrCn){
+                let tempBase = `[${cn}]`;
+                  if (!arrBase.includes(tempBase)){
+                      alert(`定额基数“${cn}”必须用中括号[]括起来!`);
+                      return false;
+                  }
+            };
+            // 这里要加一个保险。因为上面的 for 循环在“主材费 + [主材费]” 情况下有Bug
+            alert('定额基数必须用中括号[]括起来!');
             return false;
         };
 
         for (let base of arrBase){
             let baseName = base.slice(1, -1);
             if (!rationCalcBases[baseName]){
-                alert('定额基数“' + baseName + '”末定义!');
+                alert('定额基数 [' + baseName + '] 末定义!');
                 return false;
             }
         };
 
         // 行引用检测、行引用转ID引用
-        let arrF = me.getFArr(stdExpr);
+        let arrF = me.getFArr(expr);
         for (let F of arrF){
             let num = F.slice(1);
             if (num > me.calcTemplate.calcItems.length){
@@ -636,140 +647,28 @@ let analyzer = {
             };
             let id = me.getFID(F);
             let fn = new RegExp(F, "g");
-            stdExpr = stdExpr.replace(fn, '@' + id);
+            expr = expr.replace(fn, `@('${id}')`);
         };
 
         // 循环计算
-        if (me.isCycleCalc(stdExpr)){
+        if (me.isCycleCalc(expr)){
             alert('表达式中有循环计算!');
             return false;
         }
-    },
-    analyzeCalcBase: function(expr){
-        // 前提:必须无空格、无特殊符号
-        function getCalcBase(expr){
-            let base = '',
-                iPos1 = -1, iPos2 = -1;
-            for (let i = 0; i < expr.length; i++) {
-                if (expr[i] === '['){
-                    iPos1 = i;
-                }
-                else if (iPos1 != -1 && expr[i]===']'){
-                    iPos2 = i;
-                };
-
-                if (iPos1 != -1 && iPos2 != -1){
-                    base = expr.slice(iPos1, iPos2 + 1);
-                    break;
-                }
-            };
-            return base;
-        };
-        function calcBaseToIDExpr(base){
-            /*// for test. 公路模式,基数到ID
-            let id = -1;
-            if (base == '[人工费]'){
-                id = 111;
-            }
-            else if (base == '[材料费]'){
-                id = 222;
-            }
-            else if (base == '[机械费]'){
-                id = 333;
-            }
-            else id = "错误";
-
-            return "@('" + id + "')";*/
-            let baseValue = base.slice(1, -1);
-            return "base('" + baseValue + "')";
-        };
-
-        while (expr.indexOf('[') > 0) {
-            let base = getCalcBase(expr);
-            let id = calcBaseToIDExpr(base);
-            let baseValue = base.slice(1, -1);   // []会给下面的正则带来干扰,这里去掉
-            var pattBase =new RegExp(baseValue, "g");
-            expr = expr.replace(pattBase, id);
-            expr = expr.replace(/\[base\('/g, "base('");      // [@('       [base('
-            expr = expr.replace(/'\)\]/g, "')");        // ')]
-        };
-
-        return expr;
-    },
-
-    analyzeLineRef: function(expr){
-        let me = this;
-        function isOperator(char){
-            var operator = "+-*/()";
-            return operator.indexOf(char) > -1;
-        };
-        function lineNumToID(lineNum){
-            if (lineNum > me.calcTemplate.calcItems.length){
-                me.success = false;
-                return '越界';
-            }
-            else{
-                let id = me.calcTemplate.calcItems[lineNum - 1].ID;
-                return id;
-            }
-        };
-        // 前提:必须无空格、无特殊符号、标准大写F
-        function getSection(expr){
-            let section = '',
-                iPos1 = -1, iPos2 = -1;
-            for (let i = 0; i < expr.length; i++) {
-                if (expr[i] === 'F'){
-                    iPos1 = i;
-                }
-                else if (iPos1 != -1 && isOperator(expr[i])){
-                    iPos2 = i;
-                }
-                else if (iPos1 != -1 && i == expr.length - 1){
-                    iPos2 = i + 1;
-
-                };
-                if (iPos1 != -1 && iPos2 != -1){
-                    section = expr.slice(iPos1, iPos2);
-                    break;
-                }
-            };
-            return section;
-        };
-        function sectionToIDExpr(section){
-            if (section){
-                let lineNum = section.slice(1);
-                if (isNaN(lineNum)){
-                    me.success = false;
-                    return '错误';      // 这里的返回提示不能加上section,因为会无限循环
-                }
-                else
-                    return "@('" + lineNumToID(lineNum) + "')";
-            }
-            else return '';
-        };
 
-        while (expr.indexOf('F') > 0) {
-            let sec = getSection(expr);
-            let id = sectionToIDExpr(sec);
-            var pattSec =new RegExp(sec, "g");
-            expr = expr.replace(pattSec, id);
-        };
-        return expr;
+        return true;
     },
-
     analyzeUserExpr: function(calcTemplate, calcItem){
         let me = this;
         me.calcTemplate = calcTemplate;
         let expr = calcItem.dispExpr;
-        // 标准化:处理特殊字符、中文符号、大小写
         expr = me.standard(expr);
         calcItem.dispExpr = expr;
-        // 先换掉计算基数
-        expr = me.analyzeCalcBase(expr);
-        // 再换掉行引用
-        expr = me.analyzeLineRef(expr);
-        calcItem.expression = expr;
-        return me.success;
+        if (me.isLegal(expr)){
+            calcItem.expression = expr;
+            return true;
+        }else
+            return false;
     }
 };
 
@@ -1079,10 +978,12 @@ class CalcProgram {
             let nodes = (treeNode.calcType == treeNodeCalcType.ctGatherBillsFees) ? treeNode.children : me.project.Ration.getRationNodes(treeNode);
             let rst = [];
             for (let ft of cpFeeTypes) {
+                let isEstimate = ft.name == '暂估费';
                 let ftObj = {};
                 ftObj.fieldName = ft.type;
                 ftObj.name = ft.name;
                 let buf = 0, btf = 0, btuf = 0, bttf = 0;
+                let bq = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 1;
 
                 if (treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
                     for (let node of nodes) {
@@ -1097,7 +998,6 @@ class CalcProgram {
                 }
                 else if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){     // 这里的算法要配合冷姐姐的神图才能看懂^_^
                     let sum_rtf = 0, sum_rttf = 0;
-                    let bq = calcTools.uiNodeQty(treeNode) ? calcTools.uiNodeQty(treeNode) : 1;
                     for (let node of nodes) {
                         let rq = calcTools.uiNodeQty(node) ? calcTools.uiNodeQty(node) : 0;
                         let ruf = 0, rtuf = 0, rtf = 0, rttf = 0;
@@ -1108,33 +1008,46 @@ class CalcProgram {
                             rttf = parseFloat(node.data.feesIndex[ft.type].tenderTotalFee);
                         };
                         if (me.project.property.billsCalcMode === leafBillGetFeeType.rationContent) {
-                            buf = (buf + (ruf * rq / bq).toDecimal(decimalObj.process)).toDecimal(decimalObj.process);
-                            btuf = (btuf + (rtuf * rq / bq).toDecimal(decimalObj.process)).toDecimal(decimalObj.process);
+                            buf = (buf + (ruf * rq / bq).toDecimal(decimalObj.bills.unitFee)).toDecimal(decimalObj.bills.unitFee);
+                            btuf = (btuf + (rtuf * rq / bq).toDecimal(decimalObj.bills.unitFee)).toDecimal(decimalObj.bills.unitFee);
                         };
                         sum_rtf = (sum_rtf + rtf).toDecimal(decimalObj.process);
                         sum_rttf = (sum_rttf + rttf).toDecimal(decimalObj.process);
                     };
-
-                    if (me.project.property.billsCalcMode == leafBillGetFeeType.rationPriceConverse ||
-                        me.project.property.billsCalcMode == leafBillGetFeeType.rationPrice) {
-                        buf = (sum_rtf / bq).toDecimal(decimalObj.process);
-                        btuf = (sum_rttf / bq).toDecimal(decimalObj.process);
-                    };
-                    if (isBaseFeeType(ft.type) ||
-                        (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice && ft.type == "common")){
+                    if (isEstimate){
                         btf = sum_rtf;
                         bttf = sum_rttf;
-                    }
-                    else{
-                        btf = (buf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
-                        bttf = (btuf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
+                    }else{
+                        if (me.project.property.billsCalcMode == leafBillGetFeeType.rationPriceConverse ||
+                            me.project.property.billsCalcMode == leafBillGetFeeType.rationPrice) {
+                            buf = (sum_rtf / bq).toDecimal(decimalObj.process);
+                            btuf = (sum_rttf / bq).toDecimal(decimalObj.process);
+                        };
+                        if (isBaseFeeType(ft.type) ||
+                            (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice && ft.type == "common")){
+                            btf = sum_rtf;
+                            bttf = sum_rttf;
+                        }
+                        else{
+                            btf = (buf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
+                            bttf = (btuf.toDecimal(decimalObj.bills.unitPrice) * bq).toDecimal(decimalObj.process);
+                        };
                     };
                 };
 
-                ftObj.unitFee = buf.toDecimal(decimalObj.bills.unitPrice);
                 ftObj.totalFee = btf.toDecimal(decimalObj.bills.totalPrice);
-                ftObj.tenderUnitFee = btuf.toDecimal(decimalObj.bills.unitPrice);
                 ftObj.tenderTotalFee = bttf.toDecimal(decimalObj.bills.totalPrice);
+                if (isEstimate){
+                    if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees){
+                        ftObj.unitFee = (ftObj.totalFee / bq).toDecimal(decimalObj.bills.unitPrice);
+                        ftObj.tenderUnitFee = (ftObj.tenderTotalFee / bq).toDecimal(decimalObj.bills.unitPrice);
+                    }
+                }
+                else{
+                    ftObj.unitFee = buf.toDecimal(decimalObj.bills.unitPrice);
+                    ftObj.tenderUnitFee = btuf.toDecimal(decimalObj.bills.unitPrice);
+                }
+
                 calcTools.checkFeeField(treeNode, ftObj);
 
                 rst.push(ftObj);
@@ -1413,7 +1326,7 @@ class CalcProgram {
                     }
                     else{
                         if (node.sourceType != ModuleNames.ration_glj) {
-                            rst = (rst + calcTools.getFee(node, 'common.totalFee')).toDecimal(decimalObj.bills.totalPrice);
+                            rst = (rst + calcTools.getFee(node, 'common.totalFee')).toDecimal(decimalObj.decimal("totalPrice", node));
                         };
                     }
                 }

+ 33 - 0
web/building_saas/main/js/models/installation_fee.js

@@ -0,0 +1,33 @@
+/**
+ * Created by zhang on 2018/1/31.
+ */
+var installation_fee = {
+    createNew: function (project) {
+        // 用户定义private方法
+        var tools = {};
+
+        // 所有通过this访问的属性,都不应在此单元外部进行写入操作
+        var installation_fee = function (proj) {
+            // this.project = proj;
+            this.datas = [];
+
+            var sourceType = ModuleNames.installation_fee;
+            this.getSourceType = function () {
+                return sourceType;
+            }
+            proj.registerModule(ModuleNames.installation_fee, this);
+        };
+
+        // prototype用于定义public方法
+        installation_fee.prototype.loadData = function (datas) {
+            this.datas = datas;
+        };
+
+        // 提交数据后返回数据处理
+        installation_fee.prototype.doAfterUpdate = function(err, data){
+
+        };
+        return new installation_fee(project);
+    }
+
+};

+ 34 - 2
web/building_saas/main/js/models/main_consts.js

@@ -12,7 +12,8 @@ const ModuleNames = {
     ration_ass:'ration_ass',
     quantity_detail:'quantity_detail',
     labour_coe: 'labour_coe',
-    calc_program: 'calc_program'
+    calc_program: 'calc_program',
+    installation_fee:'installation_fee'
 };
 
 const gljType = {
@@ -238,4 +239,35 @@ const cpFeeTypes = [
     {type: 'adjustMachineLabour', name: '调整机上人工费'},
     {type: 'estimate', name: '暂估费'},
     {type: 'common', name: '工程造价'}
-];
+];
+
+const engineeringType = {
+    // 建筑工程
+    ARCHITECTURE: 1,
+    // 装饰工程
+    DECORATE: 2,
+    // 仿古建筑工程
+    ANTIQUE_ARCHITECTURE: 3,
+    // 安装工程
+    BUILD_IN: 4,
+    // 市政土建工程
+    MUNICIPAL_CONSTRUCTION: 5,
+    // 市政安装工程
+    MUNICIPAL_BUILD_IN: 6,
+    // 人工土石方工程
+    ARTIFICIAL_EARTHWORK: 7,
+    // 机械土石方工程
+    MECHANICAL_EARTHWORK: 8,
+    // 炉窖砌筑工程
+    KILN_MASONRY: 9,
+    // 园林工程
+    GARDEN: 10,
+    // 绿化工程
+    PLANTING: 11,
+    // 单拆除工程
+    DISMANTLE: 12,
+    // 建筑修缮工程
+    BUILDING_REPAIR: 13,
+    // 安装修缮工程
+    BUILD_IN_REPAIR: 14
+};

+ 1 - 0
web/building_saas/main/js/models/project.js

@@ -80,6 +80,7 @@ var PROJECT = {
             this.ration_coe = ration_coe.createNew(this);
             this.ration_ass = ration_ass.createNew(this);
             this.quantity_detail = quantity_detail.createNew(this);
+            this.installation_fee = installation_fee.createNew(this);
             this.FeeRate = FeeRate.createNew(this);
             // this.VolumePrice = VolumePrice.createNew(this);
             this.projectGLJ = new ProjectGLJ();

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

@@ -482,6 +482,7 @@ ProjectGLJ.prototype.calcQuantity  = function (){
 ProjectGLJ.prototype.getQuantityPerGLJ =function (pglj,mixRatioSubdivisionMap,mixRatioTechMap) {
     let billIDs =   projectObj.project.Bills.getSubdivisionProjectLeavesID();//取分部分项上的所有叶子清单ID
     let tech_billIDS =  projectObj.project.Bills.getTechLeavesID();//取所有技术措施项目叶子清单ID
+    console.log(tech_billIDS);
     let ration_glj_list = projectObj.project.ration_glj.datas;
     let mixRatioMap = this.datas.mixRatioMap;
     let rations = projectObj.project.Ration.datas;

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

@@ -125,6 +125,4 @@ var ration_ass = {
         return new ration_ass(project);
     }
 
-
-
 };

+ 47 - 0
web/building_saas/main/js/views/installation_fee_view.js

@@ -0,0 +1,47 @@
+/**
+ * Created by zhang on 2018/1/30.
+ */
+let installationFeeObj={
+    rationInstallSheet:null,
+    installationFeeSpread:null,
+    rationInstallsetting: {
+        header: [
+            {headerName: "按统一设置", headerWidth: 100, dataCode: "name", dataType: "String"},
+            {headerName: "费用项", headerWidth: 120, dataCode: "stdValue", hAlign: "right", dataType: "String"},
+            {headerName: "费用规则", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "编码", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "基数", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "费率(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中人工(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中材料(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "其中机械(%)", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "费用类型", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"},
+            {headerName: "记取位置", headerWidth: 120, dataCode: "actualValue", hAlign: "right", dataType: "String"}
+        ],
+        view: {
+            lockColumns: [0, 1]
+        }
+    },
+    showCalcInstallSettingDiv:function () {
+        $("#calc_installation_fee").modal({show:true});
+    },
+    engineeringTypeChecking:function () {
+        let property = projectInfoObj.projectInfo.property;
+        let engineering = property.engineering;
+        if(engineering==engineeringType.BUILD_IN){//如果是安装工程,则显示
+            $('#AZZJF_div').show();
+        }
+    }
+};
+
+$(function () {
+    $('#calc_installation_fee').on('shown.bs.modal',function () {
+        if(installationFeeObj.installationFeeSpread == null){//初始化显示
+
+        }
+
+    })
+
+
+
+});

+ 24 - 9
web/building_saas/main/js/views/project_view.js

@@ -16,8 +16,6 @@ var projectObj = {
         let project = projectObj.project;
         subViewObj.loadComments(node);
         gljOprObj.showDataIfRationSelect(node);
-
-        // CSL.2017.07.25
         if (activeSubSheetIs(subSheetIndex.ssiCalcProgram)) {
             calcProgramObj.showData(node);
         };
@@ -37,6 +35,15 @@ var projectObj = {
         node.data.isSubcontract = true;
         let bname = '分包人工工日';
         alert(bname + ': ' + rationCalcBases[bname](node));*/
+
+/*        let value = projectObj.project.calcProgram.getBeforeTaxTotalFee([node]);
+        alert('前四项累计值排除当前选中项:' + value);*/
+
+/*        let t = projectObj.project.calcProgram.compiledTemplates[node.data.programID];
+        let c = t.calcItems[7];
+        c.dispExpr = '[定额基价人工费] + [定额基价材料费]  + F6 + [主材费]';
+        let rst = analyzer.analyzeUserExpr(t, c);
+        alert(`${rst}: ` + JSON.stringify(c));*/
     },
     refreshBaseActn: function (tree) {
         let setButtonValid = function (valid, btn) {
@@ -426,13 +433,6 @@ var projectObj = {
                 const autoHeight = that.project.property.displaySetting !== undefined ?
                     that.project.property.displaySetting.autoHeight : false;
                 that.project.projSetting.mainGridSetting.cols.forEach(function (col) {
-                    // for test.  后端没有绑定,暂时写死用于测试。
-/*                    if (col.data.field == '' && col.head.titleNames[0] == "取费专业") {
-                        col.data.field = 'programID';
-                        col.data.getText = 'getText.calcProgramName';
-                        col.data.cellType = 'cellType.calcProgramName';
-                    };*/
-
                     col.data.splitFields = col.data.field.split('.');
                     if (col.data.getText && Object.prototype.toString.apply(col.data.getText) === "[object String]") {
                         col.data.getText = MainTreeCol.getEvent(col.data.getText);
@@ -497,6 +497,7 @@ var projectObj = {
                 console.log("加载完成-----"+endTime);
                 console.log(`时间——${endTime - startTime}`);
                 that.project.projectMarkChecking();//是否需要重新进行造价计算
+                installationFeeObj.engineeringTypeChecking();//检查是否安装工程
             }
             else {
 
@@ -705,6 +706,20 @@ var projectObj = {
                         return true;
                     }
                 },
+                "calc_installation_fee": {
+                    name: "计取安装费用",
+                    icon: 'fa-sign-in',
+                    disabled: function () {
+                        return false;
+                    },
+                    callback: function (key, opt) {
+                        installationFeeObj.showCalcInstallSettingDiv();
+                    },
+                    visible: function(key, opt){
+                        let engineering = projectInfoObj.projectInfo.property.engineering;
+                        return engineering==engineeringType.BUILD_IN;
+                    }
+                },
                 "spr1": '--------',
                 "delete": {
                     name: '删除',

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

@@ -8,7 +8,7 @@ contentOprObj.buildSheet($("#jobSpread")[0]);
 characterOprObj.buildSheet($("#itemSpread")[0]);
 $("#tzjnrCon").hide();
 $("#subSpread").show();
-var subSpread = sheetCommonObj.createSpread($("#subSpread")[0], 5);
+var subSpread = sheetCommonObj.createSpread($("#subSpread")[0], 6);
 subSpread.getSheet(4).name('JSCX');
 
 pageCCOprObj.active = false;

+ 2 - 5
web/building_saas/main/js/views/zlfb_view.js

@@ -20,7 +20,7 @@ let zlfb_object={
                     FX_nodes.push(tem_node);
                     let l_code = zlfb_object.getLibCode(tem_node.data.code);
                     if(tem_node.data.billsLibId&&l_code!=false){
-                        reorganize= true;
+                        reorganize = true;
                         if(codeMap[l_code]){
                             codeMap[l_code].push(tem_node);
                         }else {
@@ -243,7 +243,6 @@ let zlfb_object={
         }
         updateData.projectID = FBFX.data.projectID;
         updateData.user_id = userID;
-        console.log(updateData);
         CommonAjax.post('/bills/reorganizeFBFX',updateData,function (data) {
             //更新前端缓存
             let billDatas = projectObj.project.Bills.datas;
@@ -285,8 +284,6 @@ let zlfb_object={
         },function () {
             //errorCallback
         });
-        console.log(newDataMap);
-        console.log(allNewNode);
     }
 }
 
@@ -300,4 +297,4 @@ $(function () {
         zlfb_object.sectionInfo=null;
     })
 
-})
+});