소스 검색

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

MaiXinRong 7 년 전
부모
커밋
80ebdefbbc

+ 35 - 4
web/building_saas/main/js/models/calc_program.js

@@ -9,6 +9,8 @@ class CalcProgram {
     constructor(project){
         this.project = project;
         this.datas = [];
+        this.digit = 2;
+        this.digitDefault = 6;
         this.calc = new Calculation();
         project.registerModule(ModuleNames.calc_program, this);
     };
@@ -62,6 +64,10 @@ class CalcProgram {
 
         // 存储、刷新本结点、所有父结点
         if (this.calc.changed){
+            if (treeNode.parent) {
+                projectObj.converseCalculateBills(treeNode.parent);
+            };
+
             let data = {ID: treeNode.data.ID, projectID: projectObj.project.ID(), fees: treeNode.data.fees};
             let newDta = {'updateType': 'ut_update', 'updateData': data};
             let newDataArr = [];
@@ -69,11 +75,36 @@ class CalcProgram {
             projectObj.project.pushNow('', treeNode.sourceType, newDataArr);
             projectObj.mainController.refreshTreeNode([treeNode]);
 
-            if (treeNode.parent) {
-                projectObj.converseCalculateBills(treeNode.parent);
-            }
-
             this.calc.changed = false;
         };
+    };
+
+    gatherCalcItems(treeNode){
+        let me = this;
+        let rst = [];
+        if (treeNode.sourceType === this.project.Bills.getSourceType()) {
+            let rations = this.project.Ration.getRationsByNode(treeNode);
+            for (let ft of feeType) {
+                let ftObj = {};
+                ftObj.type = ft.type;
+                ftObj.name = ft.name;
+                let uf = 0, tf = 0, tuf = 0, ttf = 0;
+                for (let ration of rations) {
+                    if (ration.feesIndex && ration.feesIndex[ft.type]) {
+                        uf = (uf + parseFloat(ration.feesIndex[ft.type].unitFee)).toDecimal(me.digitDefault);
+                        tf = (tf + parseFloat(ration.feesIndex[ft.type].totalFee)).toDecimal(me.digitDefault);
+                        tuf = (tuf + parseFloat(ration.feesIndex[ft.type].tenderUnitFee)).toDecimal(me.digitDefault);
+                        ttf = (ttf + parseFloat(ration.feesIndex[ft.type].tenderTotalFee)).toDecimal(me.digitDefault);
+                    };
+                };
+                ftObj.unitFee = uf;
+                ftObj.totalFee = tf;
+                ftObj.tenderUnitFee = tuf;
+                ftObj.tenderTotalFee = ttf;
+
+                rst.push(ftObj);
+            };
+        };
+        return rst;
     }
 }

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

@@ -107,7 +107,7 @@ var Ration = {
             return newData;
         };
 
-        ration.prototype.getBillsSortRation = function (billsID) {
+        ration.prototype.getBillsSortRation = function (billsID) {     // 该方法只适用于叶子清单
             var rations = this.datas.filter(function (data) {
                 return data[project.masterField.ration] === billsID;
             });
@@ -117,6 +117,40 @@ var Ration = {
             return rations;
         };
 
+        // CSL, 2017-11-13 取任何清单(父清单、叶子清单)下的所有定额
+        ration.prototype.getRationsByNode = function (billNode) {
+            let rations = [];
+            let sBills = 'bills';
+            if (billNode.sourceType != sBills) return rations;
+
+            let IDs = [];
+            function getSubBillsIDs(node) {
+                if (!node) return;
+                if (node.sourceType != sBills) return;
+                if (!node.children || node.children.length == 0 || node.children[0].sourceType != sBills)
+                    IDs.push(node.data.ID)
+                else
+                    getSubBillsIDs(node.children[0]);
+                getSubBillsIDs(node.nextSibling);
+            };
+
+            if (billNode.source.children.length == 0)
+                IDs.push(billNode.data.ID)
+            else
+                getSubBillsIDs(billNode.children[0]);
+
+            for (let id of IDs){
+                let subRations = this.datas.filter(function (data) {
+                    return data[project.masterField.ration] === id;
+                });
+                rations.push(...subRations);
+            };
+            rations.sort(function (x, y) {
+                return x.serialNo - y.serialNo;
+            });
+            return rations;
+        };
+
         ration.prototype.getInsertRationData = function (billsID, preRation) {
             var br = this.getBillsSortRation(billsID);
             var updateData = [];

+ 11 - 3
web/building_saas/main/js/views/calc_program_view.js

@@ -206,9 +206,9 @@ let calcProgramObj = {
             {headerName: "计算基数", headerWidth: CP_Col_Width.dispExprUser, dataCode: "dispExprUser", dataType: "String"},
             {headerName: "费率", headerWidth: CP_Col_Width.feeRate, dataCode: "feeRate", dataType: "Number"},   // precision: 3
             {headerName:"费用类别", headerWidth:CP_Col_Width.displayFieldName, dataCode:"displayFieldName", dataType: "String", hAlign: "center"},
-            {headerName: "基数说明", headerWidth: CP_Col_Width.statement, dataCode: "statement", dataType: "String"},
             {headerName: "单价", headerWidth: CP_Col_Width.unitFee, dataCode: "unitFee", dataType: "Number"},  // execRst
             {headerName: "合价", headerWidth: CP_Col_Width.totalFee, dataCode: "totalFee", dataType: "Number"},
+            {headerName: "基数说明", headerWidth: CP_Col_Width.statement, dataCode: "statement", dataType: "String"},
             {headerName: "备注", headerWidth: CP_Col_Width.memo, dataCode: "memo", dataType: "String"}
         ],
         view: {
@@ -241,8 +241,16 @@ let calcProgramObj = {
             sheetCommonObj.showData(me.sheet, me.setting, me.datas);
         }
         else if (isBill) {
-            SheetDataHelper.loadSheetHeader(calcProgramSetting, me.sheet);
-            SheetDataHelper.loadSheetData(calcProgramSetting, me.sheet, baseCalcField);
+            if (isBillPriceCalc){    // 清单单价计算模式下的父级清单:汇总定额的计算程序的费用类别
+                let gatherCalcItems = projectObj.project.calcProgram.gatherCalcItems(treeNode);
+
+                sheetCommonObj.initSheet(me.sheet, me.setting, gatherCalcItems.length);
+                sheetCommonObj.showData(me.sheet, me.setting, gatherCalcItems);
+            }
+            else{
+                SheetDataHelper.loadSheetHeader(calcProgramSetting, me.sheet);
+                SheetDataHelper.loadSheetData(calcProgramSetting, me.sheet, baseCalcField);
+            };
         }
     },