MaiXinRong 8 лет назад
Родитель
Сommit
fc6234d066

+ 2 - 62
test/tmp_data/bills_grid_setting.js

@@ -4,72 +4,12 @@
 var BillsGridSetting ={
     "emptyRows":3,
     "headRows":1,
-    "treeCol": 2,
+    "treeCol": 0,
     "headRowHeight":[
         47
     ],
     "cols":[
         {
-            "width":50,
-            "readOnly":false,
-            "head":{
-                "titleNames":[
-                    "ID"
-                ],
-                "spanCols":[
-                    1
-                ],
-                "spanRows":[
-                    1
-                ],
-                "vAlign":[
-                    1
-                ],
-                "hAlign":[
-                    1
-                ],
-                "font":[
-                    "Comic Sans MS"
-                ]
-            },
-            "data":{
-                "field":"ID",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":50,
-            "readOnly":false,
-            "head":{
-                "titleNames":[
-                    "serialNo"
-                ],
-                "spanCols":[
-                    1
-                ],
-                "spanRows":[
-                    1
-                ],
-                "vAlign":[
-                    1
-                ],
-                "hAlign":[
-                    1
-                ],
-                "font":[
-                    "Comic Sans MS"
-                ]
-            },
-            "data":{
-                "field":"serialNo",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
             "width":150,
             "readOnly":false,
             "head":{
@@ -643,4 +583,4 @@ var BillsGridSetting ={
             }
         }
     ]
-};
+};

+ 209 - 0
test/tmp_data/test_bills_calc/bills_calc_base.js

@@ -0,0 +1,209 @@
+let BillsCalcBase = [
+    {
+        'classKey': 'FBFX',
+        'className': '分部分项',
+        'type': 'bills',
+        'subBase': [
+            {
+                'subKey': 'GCF',
+                'subName': '工程费',
+                'dispName': '分部分项--工程费'
+            },{
+                'subKey': 'DEJJRGF',
+                'subName': '定额基价人工费',
+                'dispName': '分部分项--定额基价人工费'
+            },{
+                'subKey': 'DEJJCLF',
+                'subName': '定额基价材料费',
+                'dispName': '分部分项--定额基价材料费'
+            },{
+                'subKey': 'DEJJJXF',
+                'dispName': '分部分项--定额基价机械费'
+            },{
+                'subKey': 'TZRGF',
+                'dispName': '分部分项--调整人工费'
+            },{
+                'subKey': 'TZJSRGF',
+                'dispName': '分部分项--调整机上人工费'
+            },{
+                'subKey': 'ZCF',
+                'dispName': '分部分项--主材费'
+            },{
+                'subKey': 'SBF',
+                'dispName': '分部分项--定额基价设备费'
+            },{
+                'subKey': 'WJJCLF',
+                'dispName': '分部分项--未计价材料费'
+            },{
+                'subKey': 'RGGR',
+                'dispName': '分部分项--人工工日'
+            },{
+                'subKey': 'GCLQDZDJJZJGCF',
+                'dispName': '分部分项--工程量清单中的基价直接工程费'
+            },{
+                'subKey': 'GCLQDZDJJRGF',
+                'dispName': '分部分项--工程量清单中的基价人工费'
+            }
+        ]
+    },{
+        'className': 'CSXM',
+        'type': 'bills',
+        'className': '措施项目',
+        'subBase': [
+            {
+                'subKey': 'CSXMF',
+                'dispName': '措施项目费'
+            },{
+                'subKey': 'ZZCSXMF',
+                'dispName': '组织措施项目费'
+            },{
+                'subKey': 'ZZCSXMDEJJZJGCF',
+                'dispName': '组织措施项目定额基价直接工程费'
+            },{
+                'subKey': 'ZZCSXMDEJJRGF',
+                'dispName': '组织措施项目定额基价人工费'
+            },{
+                'subKey': 'ZZCSXMDEJJCLF',
+                'dispName': '组织措施项目定额基价材料费'
+            },{
+                'subKey': 'ZZCSXMDEJJJXF',
+                'dispName': '组织措施项目定额基价机械费'
+            },{
+                'subKey': 'JSCSXMF',
+                'dispName': '技术措施项目费'
+            },{
+                'subKey': 'JSCSXMDEJJZJGCF',
+                'dispName': '技术措施项目定额基价直接工程费'
+            },{
+                'subKey': 'JSCSXMDEJJRGF',
+                'dispName': '技术措施项目定额基价人工费'
+            },{
+                'subKey': 'JSCSXMDEJJCLF',
+                'dispName': '技术措施项目定额基价材料费'
+            },{
+                'subKey': 'JSCSXMDEJJJXF',
+                'dispName': '技术措施项目定额基价机械费'
+            },{
+                'subKey': 'JSCSXMTZRGF',
+                'dispName': '技术措施项目调整人工费'
+            },{
+                'subKey': 'JSCSXMTZJSRGF',
+                'dispName': '技术措施项目调整机上人工费'
+            },{
+                'subKey': 'JSCSXMZCF',
+                'dispName': '技术措施项目主材费'
+            },{
+                'subKey': 'JSCSXMSBF',
+                'dispName': '技术措施项目设备费'
+            },{
+                'subKey': 'JSCSXMWJJCLF',
+                'dispName': '技术措施项目未计价材料费'
+            },{
+                'subKey': 'JSCSXMQDZDDEJJZJGCF',
+                'dispName': '技术措施项目清单中的定额基价直接工程费'
+            },{
+                'subKey': 'JSCSXMQDZDDEJJRGF',
+                'dispName': '技术措施项目清单中的定额基价人工费'
+            }
+        ]
+    },{
+        'classKey': 'QTXM',
+        'className': '其他项目',
+        'subBase': [
+            {
+                'subKey': 'QTXMF',
+                'dispName': '其他项目费'
+            },{
+                'subKey': 'GF',
+                'dispName': '规费'
+            },{
+                'subKey': 'SJ',
+                'dispName': '税金'
+            },{
+                'subKey': 'SQGCZJ',
+                'dispName': '税前工程造价'
+            }
+        ]
+    },{
+        'classKey': 'FBF',
+        'className': '分包费',
+        'subBase': [
+            {
+                'subKey': 'FBF',
+                'dispName': '分包费'
+            },{
+                'subKey': 'FBJJZJGCF',
+                'dispName': '分包基价直接工程费'
+            },{
+                'subKey': 'FBJJRGF',
+                'dispName': '分包基价人工费'
+            },{
+                'subKey': 'FBJJCLF',
+                'dispName': '分包基价材料费'
+            },{
+                'subKey': 'FBJJJXF',
+                'dispName': '分包基价机械费'
+            },{
+                'subKey': 'FBJJZCF',
+                'dispName': '分包基价主材费'
+            },{
+                'subKey': 'FBJJSBF',
+                'dispName': '分包基价设备费'
+            },{
+                'subKey': 'FBJJRGGR',
+                'dispName': '分包基价人工工日'
+            }
+        ]
+    },{
+
+        'classKey': 'RCJ',
+        'type': 'projectGLJ',
+        'className': '人材机',
+        'subBase': [
+            {
+                'subKey': 'RGJC',
+                'dispName': '人工价差'
+            },{
+                'subKey': 'CLJC',
+                'dispName': '材料价差'
+            },{
+                'subKey': 'JXJC',
+                'dispName': '机械价差'
+            },{
+                'subKey': 'JGRGF',
+                'dispName': '甲供人工费'
+            },{
+                'subKey': 'JGCLF',
+                'dispName': '甲供材料费'
+            },{
+                'ubKey': 'JGJXF',
+                'dispName': '甲供机械费'
+            },{
+                'ubKey': 'JGZCF',
+                'dispName': '甲供主材费'
+            },{
+                'ubKey': 'JGSBF',
+                'dispName': '甲供设备费'
+            },{
+                'subKey': 'JDRGF',
+                'dispName': '甲定人工费'
+            },{
+                'subKey': 'JDCLF',
+                'dispName': '甲供材料费'
+            },{
+                'ubKey': 'JDJXF',
+                'dispName': '甲供机械费'
+            },{
+                'ubKey': 'JDZCF',
+                'dispName': '甲供主材费'
+            },{
+                'ubKey': 'JDSBF',
+                'dispName': '甲供设备费'
+            }
+        ]
+    },{
+        'className': '结算价'
+    },{
+        'className': '变量表'
+    }
+];

+ 93 - 0
test/tmp_data/test_ration_calc/ration_calc_base.js

@@ -0,0 +1,93 @@
+/**
+ * Created by Mai on 2017/7/21.
+ */
+
+const baseCalc = 0, adjustCalc = 1, budgetCalc = 2, offerCalc = 3;
+
+const gljType = {
+    // 人工
+    LABOUR: 1,
+    // ==============材料类型=================
+    // 普通材料
+    GENERAL_MATERIAL: 201,
+    // 混凝土
+    CONCRETE: 202,
+    // 砂浆
+    MORTAR: 203,
+    // 配合比
+    MIX_RATIO: 204,
+    // 商品混凝土
+    COMMERCIAL_CONCRETE: 205,
+    // 商品砂浆
+    COMMERCIAL_MORTAR: 206,
+    // ==============材料类型=================
+    // ==============机械类型=================
+    // 普通机械
+    GENERAL_MACHINE: 301,
+    // 机械组成物
+    MACHINE_COMPOSITION: 302,
+    // ==============机械类型=================
+    // 主材
+    MAIN_MATERIAL: 4,
+    // 设备
+    EQUIPMENT: 5
+};
+
+let rationCalcBase = [
+    {
+        'dispName': '定额基价人工费',
+        'calcFun': 'base',
+        'calcType': baseCalc,
+        'gljTypes': [gljType.LABOUR]
+    },{
+        'dispName': '定额基价材料费',
+        'calcFun': 'base',
+        'calcType': baseCalc,
+        'gljTypes': [gljType.GENERAL_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO, gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR]
+    },{
+        'dispName': '定额基价机械费',
+        'calcFun': 'base',
+        'calcType': baseCalc,
+        'gljTypes': [gljType.GENERAL_MACHINE]
+    },{
+        'dispName': '定额基价机上人工费',
+        'calcFun': 'base',
+        'calcType': baseCalc,
+        'gljTypes': [gljType.MACHINE_COMPOSITION]
+    },{
+        'dispName': '定额基价人工费(调整后)',
+        'calcFun': 'adjust',
+        'calcType': adjustCalc,
+        'gljTypes': [gljType.LABOUR]
+    },{
+        'dispName': '定额基价机上人工费(调整后)',
+        'calcFun': 'adjust',
+        'calcType': adjustCalc,
+        'gljTypes': [gljType.MACHINE_COMPOSITION]
+    },{
+        'dispName': '市场价格人工费',
+        'calcFun': 'budget',
+        'calcType': budgetCalc,
+        'gljTypes': [gljType.LABOUR]
+    },{
+        'dispName': '市场价格材料费',
+        'calcFun': 'budget',
+        'calcType': budgetCalc,
+        'gljTypes': [gljType.GENERAL_MATERIAL, gljType.CONCRETE, gljType.MORTAR, gljType.MIX_RATIO, gljType.COMMERCIAL_CONCRETE, gljType.COMMERCIAL_MORTAR]
+    },{
+        'dispName': '市场价格机械费',
+        'calcFun': 'budget',
+        'calcType': budgetCalc,
+        'gljTypes': [gljType.GENERAL_MACHINE]
+    },{
+        'dispName': '主材费',
+        'calcFun': 'budget',
+        'calcType': budgetCalc,
+        'gljTypes': [gljType.MAIN_MATERIAL]
+    },{
+        'dispName': '设备费',
+        'calcFun': 'budget',
+        'calcType': budgetCalc,
+        'gljTypes': [gljType.EQUIPMENT]
+    }
+];

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

@@ -490,7 +490,7 @@
 
     <script type="text/javascript" src="/public/web/id_tree.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/cache_tree.js"></script>
-    <script type="text/javascript" src="/web/building_saas/main/js/models/bills_calc.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/calc/bills_calc.js"></script>
     <!-- Controller -->
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_controller.js"></script>
     <script type="text/javascript" src="/public/web/tree_sheet/tree_sheet_helper.js"></script>

+ 0 - 10
web/building_saas/main/js/models/bills_calc.js

@@ -32,10 +32,6 @@ let billsPriceCalcFields = [
     {'type': 'machine', 'unitFeeFlag': billsPriceUnitFeeFlag, 'totalFeeFlag': sumTotalFeeFlag},
 ];
 
-Number.prototype.toDecimal = function (ADigit) {
-    return parseFloat(this.toFixed(ADigit));
-};
-
 let nodeCalcObj = {
     node: null,
     digit: 2,
@@ -95,8 +91,6 @@ let nodeCalcObj = {
         let result = 0, child;
         for (child of this.node.children) {
             result += this.getFee(child.data, this.field.totalFee);
-            //result += child.data.feesIndex[this.field.type].totalFee;
-            //result += this.getFeeSplit(child.data, this.field.totalFeeSplit);
         }
         return result;
     },
@@ -111,8 +105,6 @@ let nodeCalcObj = {
     },
     totalFee: function () {
         return this.getFee(this.node.data, this.field.unitFee) * this.getFee(this.node.data, 'quantity');
-        //return this.node.data.feesIndex[this.field.type].unitFee * this.node.data.quantity;
-        //return this.getFeeSplit(this.node.data, this.field.unitFeeSplit) * this.getFee(this.node.data, 'quantity');
     },
     rationContentUnitFee: function () {
         let result = 0, child, qty = this.getFee(this.node.data, 'quantity');
@@ -121,8 +113,6 @@ let nodeCalcObj = {
         }
         for (child of this.node.children) {
             result += (this.getFee(child.data, this.field.unitFee) * this.getFee(child.data, 'quantity') / qty).toDecimal(this.digit);
-            //result += (child.data.feesIndex[this.field.type].unitFee * child.data.quantity / qty).toDecimal(this.digit);
-            //result += (this.getFeeSplit(child.data, this.field.unitFeeSplit) * this.getFee(child.data, 'quantity') / qty).toDecimal(this.digit);
         }
         return result;
     }

+ 57 - 0
web/building_saas/main/js/calc/calc_fees.js

@@ -0,0 +1,57 @@
+/**
+ * Created by Mai on 2017/7/21.
+ */
+
+let calcFees = {
+    findFee: function (data, fieldName) {
+        if (!data.fees) {
+            data.fees = [];
+        }
+        for (let fee of data.fees) {
+            if (fee.fieldName === fieldName) {
+                return fee;
+            }
+        }
+        return null;
+    },
+    AddFee: function (data, fieldName) {
+        let fee = {
+            'fieldName': fieldName,
+            'unitFee': 0,
+            'totalFee': 0,
+            'tenderUnitFee': 0,
+            'tenderTotalFee': 0
+        };
+        data.fees.push(fee);
+        data.feesIndex[fieldName] = fee;
+    },
+    checkFields: function (data, fields) {
+        for (let field of fields) {
+            if (!this.findFee(data, field.type)) {
+                this.AddFee(data, field.type);
+            }
+        }
+    },
+    getFee: function (data, fullField) {
+        let fields = fullField.split('.'), value = data;
+        for (let field of fields) {
+            if (value[field]) {
+                value = value[field];
+            } else {
+                return 0;
+            }
+        }
+        return value;
+    },
+    getFeeSplit: function (data, fullFields) {
+        let value = data;
+        for (let field of fullFields) {
+            if (value[field]) {
+                value = value[field];
+            } else {
+                return 0;
+            }
+        }
+        return value;
+    }
+}

+ 120 - 0
web/building_saas/main/js/calc/ration_calc.js

@@ -0,0 +1,120 @@
+/**
+ * Created by Mai on 2017/7/13.
+ */
+
+let rationCalcFields = [
+    {
+        type: 'baseDirect', code: "1", name: "基价直接工程费",
+        dispExpr: "1.1+1.2+1.3+1.4", expression: "@('1.1') + @('1.2') + @('1.3') + @('1.4')", compiledExpr: "",
+        statement: "基价人工费+基价材料费+基价机械费+未计价材料费"
+    },{
+        type: 'baseLabour', code: "1.1", name: "基价人工费",
+        dispExpr: "1.1.1+1.1.2", expression: "@('1.1.1') + @('1.1.2')", compiledExpr: "",
+        statement: "定额基价人工费+定额人工单价(基价)调整"
+    },{
+        type: 'rationBaseLabour', code: "1.1.1", name: "定额基价人工费",
+        dispExpr: "定额基价人工费", expression: "base('定额基价人工费').toFixed(2)", compiledExpr: "",
+        statement: "定额基价人工费"
+    },{
+        type: 'rationAdjustLabour', code: "1.1.2", name: "定额人工单价(基价)调整",
+        dispExpr: "1.1.1*[1.89-1]", expression: "@('1.1.1') * fee('3')", compiledExpr: "",
+        statement: "定额基价人工费*[定额人工单价(基价)调整系数-1]"
+    },{
+        type: 'baseMaterial', code: "1.2", name: "基价材料费",
+        dispExpr: "定额基价材料费", expression: "base('定额基价材料费')", compiledExpr: "",
+        statement: "定额基价材料费"
+    },{
+        type: 'baseMachine', code: "1.3", name: "基价机械费",
+        dispExpr: "1.3.1+1.3.2", expression: "@('1.3.1') + @('1.3.2')", compiledExpr: "",
+        statement: "定额基价机械费+定额机上人工单价(基价)调整"
+    },{
+        type: 'rationBaseMachine', code: "1.3.1", name: "定额基价机械费",
+        dispExpr: "定额基价机械费", expression: "base('定额基价机械费')", compiledExpr: "",
+        statement: "定额基价机械费"
+    },{
+        type: 'rationBaseMachineLabour', code: "1.3.1.1", name: "其中:定额基价机上人工费",
+        dispExpr: "定额基价机上人工费", expression: "base('定额基价机上人工费')", compiledExpr: "",
+        statement: "定额基价机上人工费"
+    },{
+        type: 'rationBaseMachineLabourFixed', code: "1.3.2", name: "定额机上人工单价(基价)调整",
+        dispExpr: "1.3.1.1*[1.89-1]", expression: "@('1.3.1.1') * fee('30')", compiledExpr: "",
+        statement: "定额基价机上人工费*[定额人工单价(基价)调整系数-1]"
+    },{
+        type: 'unPriceMaterial', code: "1.4", name: "未计价材料费",
+        dispExpr: "主材费+设备费", expression: "base('主材费') + base('设备费')", compiledExpr: "",
+        statement: "主材费+设备费"
+    },{
+        type: 'management', code: "2", name: "企业管理费",
+        dispExpr: "1.1.1", expression: "@('1.1.1')", compiledExpr: "",
+        statement: "定额基价人工费"
+    },{
+        type: 'profit', code: "3", name: "利润",
+        dispExpr: "1.1.1", expression: "@('1.1.1')", compiledExpr: "",
+        statement: "定额基价人工费"
+    },{
+        type: 'risk', code: "4", name: "风险因素",
+        dispExpr: "", expression: "0", compiledExpr: "",
+        statement: ""
+    },{
+        type: 'gljDiff', code: "5", name: "人材机价差",
+        dispExpr: "5.1+5.2+5.3", expression: "@('5.1') + @('5.2') + @('5.3')", compiledExpr: "",
+        statement: "人工费价差+材料费价差+机械费价差"
+    },{
+        type: 'labourDiff', code: "5.1", name: "人工费价差",
+        dispExpr: "信息价或市场价格-调整后的定额人工费(基价)", expression: "base('市场价格人工费') - base('定额基价人工费(调整后)')", compiledExpr: "",
+        statement: "市场价格人工费-调整后的定额人工费(基价)"
+    },{
+        type: 'materialDiff', code: "5.2", name: "材料费价差",
+        dispExpr: "信息价或市场价格-定额基价材料费", expression: "base('市场价格材料费') - base('定额基价材料费(调整后)')", compiledExpr: "",
+        statement: "市场价格材料费-定额基价材料费"
+    },{
+        type: 'machineDiff', code: "5.3", name: "机械费价差",
+        dispExpr: "信息价或市场价格-调整后的定额基价机械费(基价)", expression: "base('市场价格机械费') - base('定额基价机械费(调整后)')", compiledExpr: "",
+        statement: "市场价格机械费-调整后的定额基价机械费(基价)"
+    },{
+        type: 'common', code: "6", name: "综合单价",
+        dispExpr: "1+2+3+4+5", expression: "@('1') + @('2') + @('3') + @('4') + @('5')", compiledExpr: "",
+        statement: "基价直接工程费+企业管理费+利润+风险因素+人材机价差"
+    }
+];
+
+let rationCalcObj = {
+    calcGljs: [],
+    calcFields: null,
+    base: function () {
+
+    },
+    adjust: function () {
+        
+    },
+    budget: function () {
+
+    },
+    calculate () {
+        let result = {};
+
+    }
+};
+
+class RationCalc {
+    constructor (project) {
+        this.project = project;
+    };
+
+    calculate (ration) {
+        rationCalcObj.calcGljs = this.project.ration_glj.getGljArrByRation(ration.ID);
+        rationCalcObj.calcFields = rationCalcFields;
+        let virData = rationCalcObj.calculate();
+        calcFees.checkFields(ration, rationCalcFields);
+        for (let field of rationCalcFields) {
+            ration.feesIndex[field.type].unitFee = virData[field.type].unitFee;
+            ration.feesIndex[field.type].totalFee = virData[field.type].totalFee;
+        }
+    }
+
+    calculateAll () {
+        for (let rationData of project.ration.data) {
+            this.calculate(rationData);
+        }
+    };
+}

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

@@ -41,6 +41,12 @@ var ration_glj = {
             this.datas = datas;
         };
 
+        ration_glj.prototype.getGljArrByRation = function (rationID) {
+            return this.datas.filter(function (data) {
+                return data.rationID = rationID;
+            })
+        }
+
         // 提交数据后返回数据处理
         ration_glj.prototype.doAfterUpdate = function(err, data){
             if(!err){
@@ -202,7 +208,6 @@ var ration_glj = {
             }
         }
 
-
         ration_glj.prototype.updataOrdelete=function(row){
             var updateData = null;
             if(row.rationItemQuantity==0){