Przeglądaj źródła

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

Conflicts:
	web/building_saas/main/js/views/project_view.js
zhongzewei 7 lat temu
rodzic
commit
5343939f14

+ 1 - 1
modules/main/facade/quantity_detail_facade.js

@@ -351,7 +351,7 @@ async function summateResults (query,detailList,decimal) {
         decimal = await decimal_facade.getBillsQuantityDecimal(query.projectID,bill.unit);
        // quantity = getQuantityByUnit(quantity,bill.unit);
         quantity = scMathUtil.roundTo(quantity, -decimal);
-        doc = {quantity:quantity,isFromDetail:1};
+        doc = {quantity:quantity,isFromDetail:1,quantityEXP:'GCLMXHJ'};
         await bill_model.update({'ID':query.billID,'projectID':query.projectID,deleteInfo: null},doc);
     }
     return doc

+ 1 - 0
modules/main/models/bills.js

@@ -29,6 +29,7 @@ let billsSchema = new Schema({
     name: String,
     unit: String,
     quantity: String, // Decimal
+    quantityEXP:String,//工程量表达式
     feeRateID:Number,
     feeRate:String,
     isFromDetail:{type: Number,default:0},//1 true 0 false

+ 40 - 3
web/building_saas/glj/js/composition.js

@@ -12,8 +12,10 @@ $(document).ready(function() {
 
     // 切换tab触发refresh
     $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+        if($(e.target).data('name')==undefined){
+            return;
+        }
         currentTag = $(e.target).data('name');
-
         // 获取工料机当前选中的行号
         let projectGLJId = 0;
         if (currentTag === "mix-ratio") {
@@ -68,6 +70,7 @@ function compositionSuccess(info) {
     let parentData = jsonData[row];
     let ratioData = _.find(parentData.ratio_data,{"id":info.id});
     let con_key = gljOprObj.getIndex(ratioData,gljKeyArray);
+    let updateNodes=[];
     for(let i=0;i< jsonData.length;i++){
         let tem_key = gljOprObj.getIndex(jsonData[i],gljKeyArray);
         if(con_key == tem_key){
@@ -76,11 +79,45 @@ function compositionSuccess(info) {
             projectGLJSheet.setCellByField('quantity', info.change, true,i);
         }
     }
-
+    //更新ratio 数据
+    ratioData[info.field]=info.newValue;
+    //更新组成物map里的数据
+    let p_key = gljOprObj.getIndex(parentData,gljKeyArray);
+    let m_list = projectObj.project.projectGLJ.datas.mixRatioMap[p_key];
+    let m_ratioData = _.find(m_list,{"id":info.id});
+    if(m_ratioData){
+        m_ratioData[info.field]=info.newValue;
+    }
     // 设置父级3个价格
+    parentData.unit_price.market_price =  info.parentMarketPrice;
+    parentData.unit_price.base_price =  info.parentBasePrice;
+    //更新表格
     projectGLJSheet.setCellByField('unit_price.market_price', info.parentMarketPrice, false);
-    projectGLJSheet.setCellByField('unit_price.base_price', info.parentBasePrice, false);
+    projectGLJSheet.setCellByField('base_price', info.parentBasePrice, false);
     projectGLJSheet.setCellByField('adjust_price', info.parentMarketPrice, false);
     // 更新组成物缓存
     projectObj.project.composition.loadData();
+    //选查找使用了父项目工料机的定额工料机
+    let ration_gljs = _.filter(projectObj.project.ration_glj.datas,{'projectGLJID':parentData.id});
+    let nodes = projectObj.project.mainTree.nodes;
+    let prefix = projectObj.project.mainTree.prefix;
+    for(let rg of ration_gljs){
+        let node = nodes[prefix+rg.rationID];
+        if(node){
+            updateNodes.push(node);
+        }
+    }
+    //或者是使用了父项目工料机的工料机类型的定额
+    let rations = _.filter(projectObj.project.Ration.datas,{'type':3,'projectGLJID':parentData.id});
+    for(let r of rations){
+        let r_node = nodes[prefix+r.ID];
+        if(r_node){
+            r_node.data.marketUnitFee=info.parentMarketPrice;
+            updateNodes.push(r_node);
+        }
+    }
+    if(updateNodes.length>0){
+        projectObj.project.calcProgram.calcRationsAndSave(updateNodes);
+    }
+    gljOprObj.refreshView();
 }

+ 1 - 0
web/building_saas/glj/js/composition_spread.js

@@ -229,6 +229,7 @@ CompositionSpread.prototype.updateConsumption = function(info, callback) {
                 alert('更改数据失败!');
             } else {
                 info.id = id;
+                info.field = field;
                 info.parentMarketPrice = parentMarketPrice;
                 info.parentBasePrice = parentBasePrice;
                 info.change = info.newValue - info.oldValue;

+ 8 - 1
web/building_saas/glj/js/project_glj.js

@@ -27,6 +27,10 @@ let otherFileData = {};
 let currentTag = '';
 let isChanging = false;
 let initPage = false;
+let projectGLJView={
+    currentTag:''
+}
+
 $(document).ready(function () {
     $('#tab_gongliaoji').on('show.bs.tab', function (e) {
         $(e.relatedTarget.hash).removeClass('active');
@@ -287,6 +291,9 @@ function spreadInit() {
 
     // 切换tab触发refresh
     $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
+        if($(e.target).data('name')==undefined){
+            return;
+        }
         currentTag = $(e.target).data('name');
         if (currentTag === 'ration') {
             projectGLJSheet.filterData('unit_price.type', []);
@@ -366,7 +373,7 @@ function changeIsEvaluate (id){
         let pratioM =datas.mixRatioConnectData[con_key];//找到父key
         let conditions = [];
         if(pratioM&&pratioM.length>0){
-            for(let p_key in pratioM ){
+            for(let p_key of pratioM ){
                 conditions.push(gljOprObj.getConditionByKey(p_key));
             }
         }

+ 3 - 0
web/building_saas/main/js/models/bills.js

@@ -520,6 +520,9 @@ var Bills = {
                     project.ration_glj.updataOrdelete(selected.source);
                 }
                 if(parent){
+                    if(parent.children.length==0&&parent.data.feesIndex&&parent.data.feesIndex.common){
+                        parent.data.feesIndex.common.unitFee = 0;
+                    }
                     projectObj.converseCalculateBills(parent);
                 }else { //删除的是大项费用要重新计算工程造价节点
                     project.Bills.calcEngineeringCostNode(controller);

+ 143 - 138
web/building_saas/main/js/models/calc_program.js

@@ -1,9 +1,6 @@
 /**
  * Created by CSL on 2017-07-19.
  * 计算程序。所有定额、清单、父清单的计算都从此入。
- *  dispExpr: F8*(L-1); expression: "@('8') * (L-1)";
- *  说明:F后跟行号,L替换人工系数值,@后跟ID。用到L的规则必须有labourCoeID属性(反过来不要求),
- *  用到费率的规则必须有feeRateID属性,当有该属性时,会自动显示费率值。
  */
 
 /*  新版GLD 取消了默认清单模板,所以这里废弃。先留着,预防不时之需。
@@ -433,7 +430,7 @@ let treeNodeTools = {
     isNullBill: function (treeNode) {
         return this.isLeafBill(treeNode) && (treeNode.children.length === 0) && (!treeNode.data.calcBase);
     },
-    isEngineeringCostBill: function (treeNode) {
+    isTotalCostBill: function (treeNode) {
         return treeNode.data.flagsIndex && treeNode.data.flagsIndex.fixed && treeNode.data.flagsIndex.fixed.flag &&
             treeNode.data.flagsIndex.fixed.flag == fixedFlag.ENGINEERINGCOST;
     },
@@ -451,11 +448,15 @@ let treeNodeTools = {
         return treeNode.sourceType === ModuleNames.ration && treeNode.data.type === rationType.gljRation;
     },
 
-    initFeeField(treeNode, fieldName){
+    initFees(treeNode){
         if (!treeNode.data.fees) {
             treeNode.data.fees = [];
             treeNode.data.feesIndex = {};
+            treeNode.changed = true;
         };
+    },
+    initFeeField(treeNode, fieldName){
+        this.initFees(treeNode);
         if (!treeNode.data.feesIndex[fieldName]) {
             let fee = {
                 'fieldName': fieldName,
@@ -466,8 +467,29 @@ let treeNodeTools = {
             };
             treeNode.data.fees.push(fee);
             treeNode.data.feesIndex[fieldName] = fee;
+            treeNode.changed = true;
+        };
+    },
+    checkFeeField(treeNode, feeObj){
+        if (!feeObj) return;
+        if (feeObj.fieldName == '') return;
+
+        // 初始化前先拦截末定义的情况
+        if (!treeNode.data.feesIndex || !treeNode.data.feesIndex[feeObj.fieldName]){
+            if (feeObj.unitFee == 0 && feeObj.totalFee == 0) return;
+        }
+
+        this.initFeeField(treeNode, feeObj.fieldName);
+
+        if (treeNode.data.feesIndex[feeObj.fieldName].unitFee != feeObj.unitFee){
+            treeNode.data.feesIndex[feeObj.fieldName].unitFee = feeObj.unitFee;
+            treeNode.changed = true;
+        };
+
+        if (treeNode.data.feesIndex[feeObj.fieldName].totalFee != feeObj.totalFee){
+            treeNode.data.feesIndex[feeObj.fieldName].totalFee = feeObj.totalFee;
+            treeNode.changed = true;
         };
-        treeNode.changed = true;
     },
     initSummaryFee(treeNode){
         if (!treeNode.data.summaryFees){
@@ -765,112 +787,114 @@ class CalcProgram {
         treeNode.calcType = treeNodeTools.getCalcType(treeNode);
         // if (treeNode.calcType == treeNodeCalcType.ctCalcBaseValue) return;
 
-        function initFees(treeNode){
-            if (!treeNode.data.fees) {
-                treeNode.data.fees = [];
-                treeNode.data.feesIndex = {};
-                treeNode.changed = true;
-            };
+        function isBaseFeeType(type){
+            return ['labour', 'material', 'machine', 'mainMaterial', 'equipment'].indexOf(type) > -1;
         };
 
-        function checkFee(treeNode, feeObj){
-            if (!feeObj) return;
-            if (feeObj.fieldName == '') return;
-
-            if (!treeNode.data.feesIndex[feeObj.fieldName]){
-                let fee = {
-                    'fieldName': feeObj.fieldName,
-                    'unitFee': feeObj.unitFee,
-                    'totalFee': feeObj.totalFee,
-                    'tenderUnitFee': 0,
-                    'tenderTotalFee': 0
+        // 计算暂估费用
+        function calcEstimateFee(treeNode){
+            let sumU = 0, sumT = 0;
+
+            if (treeNodeTools.isTotalCostBill(treeNode)){
+                let nodes = projectObj.project.mainTree.roots;
+                for (let node of nodes){
+                    if (treeNodeTools.isTotalCostBill(node)) break;
+                    let eU = 0, eT = 0;
+                    if (node.data.feesIndex && node.data.feesIndex.estimate){
+                        eU = node.data.feesIndex.estimate.unitFee;
+                        eT = node.data.feesIndex.estimate.totalFee;
+                    }
+                    else {
+                        eU = 0, eT = 0;
+                    };
+                    sumU = (sumU + parseFloatPlus(eU)).toDecimal(decimalObj.process);
+                    sumT = (sumT + parseFloatPlus(eT)).toDecimal(decimalObj.process);
                 };
-                treeNode.data.fees.push(fee);
-                treeNode.data.feesIndex[feeObj.fieldName] = fee;
-                treeNode.changed = true;
+                sumU = (sumU).toDecimal(decimalObj.bills.unitPrice);
+                sumT = (sumT).toDecimal(decimalObj.bills.totalPrice);
             }
             else{
-                if (treeNode.data.feesIndex[feeObj.fieldName].unitFee != feeObj.unitFee){
-                    treeNode.data.feesIndex[feeObj.fieldName].unitFee = feeObj.unitFee;
-                    treeNode.changed = true;
+                if (!treeNode.data.gljList) return;
+
+                let eTypes = [
+                    gljType.GENERAL_MATERIAL, gljType.MAIN_MATERIAL, gljType.EQUIPMENT,
+                    gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO,
+                    gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR];
+                let eDetailTypes = [gljType.MAIN_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO];
+
+                let GLJObjs = [];
+                for (let glj of treeNode.data.gljList) {
+                    if (eTypes.indexOf(glj.type) >= 0) {
+                        if (glj.isEstimate){
+                            'code','name','specs','unit','type'
+                            GLJObjs.push({code: glj.code, name: glj.name, specs: glj.specs, unit: glj.unit, type: glj.type,
+                                quantity: glj.quantity, marketPrice: glj.marketPrice});
+                        }
+                        else{   // 组成物
+                            if (eDetailTypes.indexOf(glj.type) >= 0){
+                                let mds = projectObj.project.composition.getCompositionByGLJ(glj);
+                                if (!mds) mds = [];
+                                for (let md of mds){
+                                    if (md.isEstimate){
+                                        let isExist = false;
+                                        let mdQ = (parseFloatPlus(glj.quantity) * parseFloatPlus(md.consumption)).toDecimal(decimalObj.process);
+
+                                        for (let obj of GLJObjs){
+                                            if (gljOprObj.getIndex(md, gljKeyArray) == gljOprObj.getIndex(obj, gljKeyArray)){
+                                                isExist = true;
+                                                obj.quantity = (parseFloatPlus(obj.quantity) + mdQ).toDecimal(decimalObj.process);
+                                                break;
+                                            }
+                                        };
+                                        if (!isExist)
+                                            GLJObjs.push({code: md.code, quantity: mdQ, marketPrice: md.marketPrice});
+                                    }
+                                }
+                            }
+                        }
+                    };
                 };
 
-                if (treeNode.data.feesIndex[feeObj.fieldName].totalFee != feeObj.totalFee){
-                    treeNode.data.feesIndex[feeObj.fieldName].totalFee = feeObj.totalFee;
-                    treeNode.changed = true;
+                for (let obj of GLJObjs){
+                    sumU = sumU + (parseFloatPlus(obj.quantity) * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
+                    sumU = sumU.toDecimal(decimalObj.process);
+
+                    let q = (parseFloatPlus(obj.quantity) * parseFloatPlus(treeNode.data.quantity)).toDecimal(decimalObj.process);
+                    sumT = sumT + (q * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
+                    sumT = sumT.toDecimal(decimalObj.process);
+                };
+                sumU = sumU.toDecimal(decimalObj.bills.unitPrice);
+                if (projectObj.project.property.zanguCalcMode == zanguCalcType.common){
+                    sumT = (parseFloatPlus(treeNode.data.quantity) * sumU).toDecimal(decimalObj.bills.totalPrice);
+                }
+                else if (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial){
+                    sumT = sumT.toDecimal(decimalObj.bills.totalPrice);
                 };
             };
-        };
 
-        function isBaseFeeType(type){
-            return ['labour', 'material', 'machine', 'mainMaterial', 'equipment'].indexOf(type) > -1;
+            treeNodeTools.checkFeeField(treeNode, {'fieldName': 'estimate', 'unitFee': sumU, 'totalFee': sumT});
         };
 
-        function estimateFee(treeNode){
-            if (!treeNode.data.gljList) return undefined;
-
-            let eTypes = [
-                gljType.GENERAL_MATERIAL, gljType.MAIN_MATERIAL, gljType.EQUIPMENT,
-                gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO,
-                gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR];
-            let eDetailTypes = [gljType.MAIN_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO];
-
-            let GLJObjs = [];
-            for (let glj of treeNode.data.gljList) {
-                if (eTypes.indexOf(glj.type) >= 0) {
-                    if (glj.isEstimate){
-                        GLJObjs.push({code: glj.code, quantity: glj.quantity, marketPrice: glj.marketPrice});
-                    }
-                    else{   // 组成物
-                        if (eDetailTypes.indexOf(glj.type) >= 0){
-                            let mds = projectObj.project.composition.getCompositionByGLJ(glj);
-                            if (!mds) mds = [];
-                            for (let md of mds){
-                                if (md.isEstimate){
-                                    let isExist = false;
-                                    let mdQ = (parseFloatPlus(glj.quantity) * parseFloatPlus(md.consumption)).toDecimal(decimalObj.process);
-
-                                    for (let obj of GLJObjs){
-                                        if (md.code == obj.code){
-                                            isExist = true;
-                                            obj.quantity = (parseFloatPlus(obj.quantity) + mdQ).toDecimal(decimalObj.process);
-                                            break;
-                                        }
-                                    };
-                                    if (!isExist)
-                                        GLJObjs.push({code: md.code, quantity: mdQ, marketPrice: md.marketPrice});
-                                }
-                            }
-                        }
+        // 删掉多余的费用。例如:从其它计算方式切换到公式计算方式,会多出其它的费(不光是common)
+        function deleteUselessFees(treeNode){
+            let reserveArr = treeNodeTools.isTotalCostBill(treeNode)? ['common', 'estimate']:['common'];
+            if (treeNode.data.fees && treeNode.data.fees.length > 0){
+                let feesArr = treeNode.data.fees;
+                for (let i = 0; i < feesArr.length; i++) {
+                    if (!reserveArr.includes(feesArr[i].fieldName)) {
+                        delete treeNode.data.feesIndex[feesArr[i].fieldName];
+                        feesArr.splice(i, 1);
+                        treeNode.changed = true;
                     }
-                };
-            };
-
-            let sumU = 0, sumT = 0, unitFee = 0, totalFee = 0;
-            for (let obj of GLJObjs){
-                sumU = sumU + (parseFloatPlus(obj.quantity) * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
-                sumU = sumU.toDecimal(decimalObj.process);
-
-                let q = (parseFloatPlus(obj.quantity) * parseFloatPlus(treeNode.data.quantity)).toDecimal(decimalObj.process);
-                sumT = sumT + (q * parseFloatPlus(obj.marketPrice)).toDecimal(decimalObj.process);
-                sumT = sumT.toDecimal(decimalObj.process);
-            };
-            unitFee = sumU.toDecimal(decimalObj.bills.unitPrice);
-            if (projectObj.project.property.zanguCalcMode == zanguCalcType.common){
-                totalFee = (parseFloatPlus(treeNode.data.quantity) * unitFee).toDecimal(decimalObj.bills.totalPrice);
-            }
-            else if (projectObj.project.property.zanguCalcMode == zanguCalcType.gatherMaterial){
-                totalFee = sumT.toDecimal(decimalObj.bills.totalPrice);
+                }
             };
-
-            return {'fieldName': 'estimate', 'unitFee': unitFee, 'totalFee': totalFee};
         };
 
         // 父清单汇总子项(定额或子清单)的费用类别
         if (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees ||
             treeNode.calcType == treeNodeCalcType.ctGatherBillsFees){
             treeNode.data.programID = null;
-            initFees(treeNode);
+            treeNodeTools.initFees(treeNode);
 
             let objsArr = (treeNode.calcType == treeNodeCalcType.ctGatherRationsFees) ? me.project.Ration.getRationsByNode(treeNode) : treeNode.children;
             let rst = [];
@@ -933,7 +957,7 @@ class CalcProgram {
                 ftObj.totalFee = btf.toDecimal(decimalObj.bills.totalPrice);
                 ftObj.tenderUnitFee = btuf.toDecimal(decimalObj.bills.unitPrice);
                 ftObj.tenderTotalFee = bttf.toDecimal(decimalObj.bills.totalPrice);
-                checkFee(treeNode, ftObj);
+                treeNodeTools.checkFeeField(treeNode, ftObj);
 
                 rst.push(ftObj);
             };
@@ -947,19 +971,14 @@ class CalcProgram {
             if (treeNode.data.programID) treeNode.data.programID = null;
 
             let uf = (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.unitFee) ? treeNode.data.feesIndex.common.unitFee : 0;
+            uf = uf.toDecimal(decimalObj.bills.unitPrice);
             let tuf = (treeNode.data.feesIndex && treeNode.data.feesIndex.common && treeNode.data.feesIndex.common.tenderUnitFee) ? treeNode.data.feesIndex.common.tenderUnitFee : 0;
+            tuf = tuf.toDecimal(decimalObj.bills.unitPrice);
             let q = treeNode.data.quantity ? treeNode.data.quantity : 0;
             let tf = (uf * q).toDecimal(decimalObj.bills.totalPrice);
             let ttf = (tuf * q).toDecimal(decimalObj.bills.totalPrice);
-
-            delete treeNode.data.fees;    // 直接删掉再新增,不用一个个费判断更新,效率更高。
-            delete treeNode.data.feesIndex;
-            treeNodeTools.initFeeField(treeNode, 'common');
-            treeNode.data.feesIndex.common.unitFee = uf.toDecimal(decimalObj.bills.unitPrice);
-            treeNode.data.feesIndex.common.totalFee = tf.toDecimal(decimalObj.bills.totalPrice);
-            treeNode.data.feesIndex.common.tenderUnitFee = tuf.toDecimal(decimalObj.bills.unitPrice);
-            treeNode.data.feesIndex.common.tenderTotalFee = ttf.toDecimal(decimalObj.bills.totalPrice);
-            treeNode.changed = true;
+            deleteUselessFees(treeNode);
+            treeNodeTools.checkFeeField(treeNode, {'fieldName': 'common', 'unitFee': uf, 'totalFee': tf});
             treeNode.data.calcTemplate = {"calcItems": []};
         }
         // 叶子清单公式计算
@@ -975,38 +994,22 @@ class CalcProgram {
             let tuf = uf;
             let tf = (me.project.property.billsCalcMode === leafBillGetFeeType.rationPrice) ? (b * f / 100).toDecimal(decimalObj.bills.totalPrice) : (uf * q).toDecimal(decimalObj.bills.totalPrice);
             let ttf = tf;
+            deleteUselessFees(treeNode);
+            treeNodeTools.checkFeeField(treeNode, {'fieldName': 'common', 'unitFee': uf, 'totalFee': tf});
+
+            // 总造价清单还要做单项工程、建设项目的四大项金额汇总
+            if (treeNodeTools.isTotalCostBill(treeNode)){
+                // 公式叶子清单没有暂估费,但总造价清单除外。
+                calcEstimateFee(treeNode);
+                treeNodeTools.initSummaryFee(treeNode);
+                treeNode.data.summaryFees.totalFee = tf;
+                treeNode.data.summaryFees.estimateFee = (treeNode.data.feesIndex && treeNode.data.feesIndex.estimate) ? treeNode.data.feesIndex.estimate.totalFee:0;
+                let bill_safe = cbTools.findBill(fixedFlag.SAFETY_CONSTRUCTION);
+                treeNode.data.summaryFees.safetyFee = (bill_safe && bill_safe.feesIndex && bill_safe.feesIndex.common)?bill_safe.feesIndex.common.totalFee:0;
+                let bill_charge = cbTools.findBill(fixedFlag.CHARGE);
+                treeNode.data.summaryFees.chargeFee = (bill_charge && bill_charge.feesIndex && bill_charge.feesIndex.common)?bill_charge.feesIndex.common.totalFee:0;
+            }
 
-            function newCommonFee(){
-                treeNodeTools.initFeeField(treeNode, 'common');
-                treeNode.data.feesIndex.common.unitFee = uf;
-                treeNode.data.feesIndex.common.totalFee = tf;
-                treeNode.data.feesIndex.common.tenderUnitFee = tuf;
-                treeNode.data.feesIndex.common.tenderTotalFee = ttf;
-                treeNode.changed = true;
-                // 如果是总造价清单,还要做单项工程、建设项目金额汇总
-                if (treeNodeTools.isEngineeringCostBill(treeNode)){
-                    treeNodeTools.initSummaryFee(treeNode);
-                    treeNode.data.summaryFees.totalFee = tf;
-                    treeNode.data.summaryFees.estimateFee = 0;//treeNode.data.feesIndex.zangu.totalFee;
-                    let bill_safe = cbTools.findBill(fixedFlag.SAFETY_CONSTRUCTION);
-                    treeNode.data.summaryFees.safetyFee = (bill_safe && bill_safe.feesIndex && bill_safe.feesIndex.common)?bill_safe.feesIndex.common.totalFee:0;
-                    let bill_charge = cbTools.findBill(fixedFlag.CHARGE);
-                    treeNode.data.summaryFees.chargeFee = (bill_charge && bill_charge.feesIndex && bill_charge.feesIndex.common)?bill_charge.feesIndex.common.totalFee:0;
-                }
-            };
-
-            if (treeNode.data.feesIndex && treeNode.data.feesIndex.common){
-                if (treeNode.data.feesIndex.common.unitFee != uf ||
-                    treeNode.data.feesIndex.common.totalFee != tf ||
-                    treeNode.data.feesIndex.common.tenderUnitFee != tuf ||
-                    treeNode.data.feesIndex.common.tenderTotalFee != ttf ){
-                    delete treeNode.data.fees;    // 直接删掉再新增。从其它计算方式切换到公式计算方式,会多出其它的费(不光是common)所以这里直接删掉,不用一个个费判断更新,效率更高。
-                    delete treeNode.data.feesIndex;
-                    newCommonFee();
-                }
-            }else{
-                newCommonFee();
-            };
             treeNode.data.calcTemplate = {"calcItems": []};
         }
         // 定额或叶子清单自己的计算程序计算
@@ -1023,6 +1026,8 @@ class CalcProgram {
                 }
                 else{
                     treeNode.data.gljList = me.project.ration_glj.getGljArrByRation(treeNode.data.ID);
+                    // 计算程序里没有暂估费的计算规则,会漏掉,所以这里要专门算。
+                    calcEstimateFee(treeNode);
                 };
 
                 if (treeNode.data.programID == undefined){
@@ -1036,6 +1041,9 @@ class CalcProgram {
                 if (treeNode.data.programID == undefined){
                     treeNode.data.programID = projectInfoObj.projectInfo.property.engineering;
                 }
+
+                // 叶子清单自己的计算程序计算,其暂估费也要汇总算。
+                calcEstimateFee(treeNode);
             };
 
             let template = me.compiledTemplates[treeNode.data.programID];
@@ -1047,7 +1055,7 @@ class CalcProgram {
                 $CE.template = template;
                 $CE.calcBase = me.compiledCalcBases;
 
-                initFees(treeNode);
+                treeNodeTools.initFees(treeNode);
 
                 for (let idx of template.compiledSeq) {
                     let calcItem = template.calcItems[idx];
@@ -1062,12 +1070,9 @@ class CalcProgram {
                     else quantity = parseFloat(quantity).toDecimal(decimalObj.decimal('quantity', treeNode));
                     calcItem.totalFee = (calcItem.unitFee * quantity).toDecimal(decimalObj.decimal('totalPrice', treeNode));
 
-                    checkFee(treeNode, calcItem);
+                    treeNodeTools.checkFeeField(treeNode, calcItem);
                 };
             };
-
-            checkFee(treeNode, estimateFee(treeNode));
-
         };
 
         if (treeNode.changed && !changedArr.includes(treeNode)) changedArr.push(treeNode);

+ 6 - 3
web/building_saas/main/js/models/quantity_detail.js

@@ -164,7 +164,7 @@ var quantity_detail = {
                 let newNode = nodes[0];
                 if(newNode.sourceType === project.Bills.getSourceType()){
                     console.log(newNode.data.quantity);
-                    this.updateBillQuantity(newNode.data.quantity,newNode);
+                    this.updateBillQuantity(newNode.data.quantity,newNode,newNode.data.quantityEXP);
                 }else {//更新定额所使用的值要用还没转换前的
                     this.updateRationQuantity(node.data.r_quantity,newNode,newNode.data.quantityEXP);//to do 加上工程量表达式和含量更新
                 }
@@ -534,7 +534,7 @@ var quantity_detail = {
         quantity_detail.prototype.editMainTreeNodeQuantity=function (value,node,fieldName) {
             var me = this;
             if(isNaN(value)){
-                alert("当前输入的数据类型不正确,请重新输入");
+                alert("当前输入的数据类型不正确,请重新输入");
                 projectObj.mainController.refreshTreeNode([node]);
             }else {
                 value=value?value:0;
@@ -553,9 +553,11 @@ var quantity_detail = {
                 },100);
             }
         };
-        quantity_detail.prototype.updateBillQuantity=function (value,node) {
+        quantity_detail.prototype.updateBillQuantity=function (value,node,quantityEXP) {
+            node.data.quantityEXP = quantityEXP?quantityEXP:value;
             value = scMathUtil.roundForObj(value,getDecimal("quantity",node));
             node.data.quantity = value+"";
+            console.log(value);
             let needUpdateChildren = [];//需更新的子定额
             let gljNodes=[];//当定额工程量改变时需刷新的子工料机
             if(node.children.length>0){//如果有子项则
@@ -584,6 +586,7 @@ var quantity_detail = {
                 }
             }
             if(needUpdateChildren.length>0){
+                node.changed = true;//本身发生了改变,需要存储。
                 project.calcProgram.calcRationsAndSave(needUpdateChildren);
             }else {
                 node.changed = true;

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

@@ -349,6 +349,7 @@ var Ration = {
             if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToBillsQuan')) {
                 let billsNode = this.project.Bills.tree.findNode(ration[this.project.masterField.ration]);
                 let billsQuantity = billsNode.data.quantity ? billsNode.data.quantity : 0;
+                billsQuantity=scMathUtil.roundForObj(billsQuantity,quantity_decimal);
                 ration.contain = 1;
                 ration.quantityEXP="QDL";
                 if (optionsOprObj.getOption(optionsOprObj.optionsTypes.GENERALOPTS, 'rationQuanACToRationUnit')) {

+ 1 - 1
web/building_saas/main/js/models/ration_glj.js

@@ -146,7 +146,7 @@ var ration_glj = {
                             }
                         }
                         nextNodeID = nextNodeID ? nextNodeID : parentNode.tree.rootID();
-                        let newNode = projectObj.project.mainTree.insert(parentNode.getID(), nextNodeID);
+                        let newNode = projectObj.project.mainTree.insert(parentNode.getID(), nextNodeID,data.ID);
                         newNode.source = data;
                         newNode.sourceType = this.getSourceType();
                         newNode.data = data;

+ 12 - 3
web/building_saas/main/js/views/glj_view.js

@@ -758,9 +758,15 @@ var gljOprObj = {
         var ration_glj = projectObj.project.ration_glj;
         node = node ? node : projectObj.project.mainTree.selected;
         if (node.sourceType == ModuleNames.ration) {
-            let ration = node.data;
-            gljList = this.filterGljByRation(ration, ration_glj.datas);
-            this.showInSheet(gljList);
+            if(node.data.type==rationType.gljRation){
+                this.showMixRatio(node);
+            }else {
+                let ration = node.data;
+                gljList = this.filterGljByRation(ration, ration_glj.datas);
+                this.showInSheet(gljList);
+            }
+        }else if(node.sourceType == ModuleNames.ration_glj){
+            this.showMixRatio(node);
         }
     },
     showRationGLJSheetData: function (init) {
@@ -923,6 +929,9 @@ var gljOprObj = {
         let obj ={};
         for(let i = 0;i<valueArray.length;i++){
             if(valueArray[i]!='null'){
+                if(gljKeyArray[i]=='type'){
+                    valueArray[i] = parseInt(valueArray[i]);
+                }
                 obj[gljKeyArray[i]]=valueArray[i];
             }
         }

+ 3 - 0
web/building_saas/main/js/views/main_tree_col.js

@@ -158,6 +158,9 @@ let MainTreeCol = {
         },
         forContain:function (node) {
             return MainTreeCol.readOnly.non_ration(node)&&!MainTreeCol.readOnly.glj(node);
+        },
+        forCode:function (node) {
+            return MainTreeCol.readOnly.glj(node)|| (node.sourceType === projectObj.project.Ration.getSourceType()&&node.data.type===rationType.gljRation);
         }
     },
     cellType: {

+ 61 - 41
web/building_saas/main/js/views/project_view.js

@@ -63,42 +63,10 @@ var projectObj = {
                 return false;
             }
         };
-        let canDelete = function (node,m_selection) {
-            if (node) {
-                if (node.sourceType === that.project.Bills.getSourceType()) {
-                    if(node.data.type == billType.DXFY&&node.data.isAdd!=1){
-                        return false;
-                    }
-                }
-                if(m_selection!=true&&node.sourceType === that.project.ration_glj.getSourceType()){//多选的时候不做这一项判断
-                    return false;
-                }
-                return true;
-            } else {
-                return false;
-            }
-        };
-        let canDelete_m = function (selection) {
-            for(let i =0;i<selection.rowCount;i++){
-                if(tree.items[selection.row+i]==undefined||tree.items[selection.row+i]==null){
-                    return false;
-                }
-                if(i==0&&tree.items[selection.row].sourceType === that.project.ration_glj.getSourceType()){
-                    return false
-                }
-                if(canDelete(tree.items[selection.row+i],true)==false){
-                    return false
-                }
-            }
-            return true
-        };
 
-        let selections = projectObj.mainSpread.getActiveSheet().getSelections();
-        if(selections[0].rowCount==1){//选中单行
-            setButtonValid(canDelete(selected), $('#delete'));
-        }else {
-            setButtonValid(canDelete_m(selections[0]), $('#delete'));
-        }
+
+
+        setButtonValid(ifCanDelete(), $('#delete'));
         setButtonValid(canUpLevel(selected), $('#upLevel'));
         setButtonValid(canDownLevel(selected), $('#downLevel'));
         setButtonValid(selected && (selected.depth() > 0) && selected.canUpMove(), $('#upMove'));
@@ -501,6 +469,7 @@ var projectObj = {
                 that.mainSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, that.amountAreaNumber);
                 that.loadMainSpreadContextMenu();
                 that.loadFocusLocation();
+                that.setRootsStyle();
                 let endTime = +new Date();
                 console.log("加载完成-----"+endTime);
             }
@@ -703,8 +672,7 @@ var projectObj = {
                     name: '删除',
                     icon: 'fa-remove',
                     disabled: function () {
-                        var selected = project.mainTree.selected;
-                        return !selected;
+                        return !ifCanDelete();
                     },
                     callback: function () {
                         $("#delete_row").modal({show:true});//弹出删除提示框;
@@ -834,8 +802,19 @@ var projectObj = {
                 isTotalShowing = true;
             }, 200);
         };
-    },
-    //根据节点获取行style(颜色、字体加粗)
+ },
+    setRootsStyle: function  () {
+        let me = this;
+        let style = new GC.Spread.Sheets.Style();
+        // style.backColor = "#82c7ee";
+        style.font = 'bold 15px Microsoft YaHei';
+        let count = me.project.mainTree.items.length;
+        for (var i = 0; i < count; i++) {
+            if (!me.project.mainTree.items[i].parent)
+                me.mainSpread.getActiveSheet().setStyle(i, -1, style, GC.Spread.Sheets.SheetArea.viewport);
+        }
+},
+ //根据节点获取行style(颜色、字体加粗)
     getNodeColorStyle: function (node) {
         let type, backColor = null, font = null;
         if(!isDef(node)){
@@ -896,8 +875,8 @@ var projectObj = {
             style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
             style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
         }
-        return style;
-    }
+        return style;    
+}
 };
 // 点击合计框中的复制
 $("body").on("click", "#total-tips a", function() {
@@ -1210,3 +1189,44 @@ function isSingleSelect() {//是否选中造价书中的单行
     }
     return false;
 }
+function ifCanDelete() {
+    let selections = projectObj.mainSpread.getActiveSheet().getSelections();
+    let tree = projectObj.project.mainTree;
+    let selected = projectObj.project.mainTree.selected;
+    if(selections[0].rowCount==1){//选中单行
+        return canDelete(selected);
+    }else {
+       return canDelete_m(selections[0]);
+    }
+
+    function canDelete(node,m_selection) {
+        if (node) {
+            if (node.sourceType === projectObj.project.Bills.getSourceType()) {
+                if(node.data.type == billType.DXFY&&node.data.isAdd!=1){
+                    return false;
+                }
+            }
+            if(m_selection!=true&&node.sourceType === projectObj.project.ration_glj.getSourceType()){//多选的时候不做这一项判断
+                return false;
+            }
+            return true;
+        } else {
+            return false;
+        }
+    };
+
+    function canDelete_m(selection) {
+        for(let i =0;i<selection.rowCount;i++){
+            if(tree.items[selection.row+i]==undefined||tree.items[selection.row+i]==null){
+                return false;
+            }
+            if(i==0&&tree.items[selection.row].sourceType === projectObj.project.ration_glj.getSourceType()){
+                return false
+            }
+            if(canDelete(tree.items[selection.row+i],true)==false){
+                return false
+            }
+        }
+        return true
+    };
+}