Browse Source

计算精度。

chenshilong 7 years ago
parent
commit
c4796bc3fa

+ 1 - 1
public/web/sheet/sheet_common.js

@@ -131,7 +131,7 @@ var sheetCommonObj = {
                     if(setting.header[col].hasOwnProperty('tofix')){
                         val =scMathUtil.roundToString(val,setting.header[col].tofix);
                     }
-                    if(setting.header[col].hasOwnProperty('decimalField')){
+                    else if(setting.header[col].hasOwnProperty('decimalField')){
                         var decimal = getDecimal(setting.header[col].decimalField);
                         val =scMathUtil.roundToString(val,decimal);
                         sheet.setFormatter(-1, col,getFormatter(decimal), GC.Spread.Sheets.SheetArea.viewport);

+ 3 - 1
web/building_saas/main/js/models/calc_program.js

@@ -846,10 +846,12 @@ class CalcProgram {
 
                     let feeRate = calcItem.feeRate;
                     if (!feeRate) feeRate = 100;    // 100%
+                    feeRate = feeRate.toDecimal(decimalObj.feeRate);
                     calcItem.unitFee = (eval(calcItem.compiledExpr) * feeRate * 0.01).toDecimal(decimalObj.decimal('unitPrice', treeNode));   // 如果eval()对清单树有影响,就换成小麦的Expression对象再试
 
                     let quantity = treeNode.data.quantity;
-                    if (!quantity) quantity = 0;
+                    if (!quantity) quantity = 0
+                    else quantity = parseFloat(quantity).toDecimal(decimalObj.decimal('quantity', treeNode));
                     calcItem.totalFee = (calcItem.unitFee * quantity).toDecimal(decimalObj.decimal('totalPrice', treeNode));
 
                     checkFee(treeNode, calcItem);

+ 7 - 196
web/building_saas/main/js/views/calc_program_view.js

@@ -4,197 +4,6 @@
  * 整合清单、定额的计算程序,代码合并、类合并、剔除多余单元。
  */
 
-
-let calcProgramSetting ={
-    "emptyRows":0,
-    "headRows":1,
-    "headRowHeight":[
-        35
-    ],
-    "cols":[
-        {
-            "width":75,
-            "readOnly": true,
-            "head":{
-                "titleNames":["序号"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"serialNo",
-                "vAlign":1,
-                "hAlign":1,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":75,
-            "readOnly": false,
-            "head":{
-                "titleNames":["费用代号"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"code",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":200,
-            "readOnly":false,
-            "head":{
-                "titleNames":["名称"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"name",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":280,
-            "readOnly":false,
-            "head":{
-                "titleNames":["计算基数"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"dispExpr",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":220,
-            "readOnly":false,
-            "head":{
-                "titleNames":["基数说明"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"statement",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":80,
-            "readOnly": false,
-            "head":{
-                "titleNames":["费率"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"feeRate",
-                "vAlign":1,
-                "hAlign":2,
-                "font":"Arial"
-            }
-        },
-        {
-            "width": 100,
-            "readOnly":true,
-            "head":{
-                "titleNames":["单价"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"unitFee",
-                "vAlign":1,
-                "hAlign":2,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":100,
-            "readOnly":true,
-            "head":{
-                "titleNames":["合价"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"totalFee",
-                "vAlign":1,
-                "hAlign":2,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":80,
-            "readOnly": true,
-            "head":{
-                "titleNames":["费用类别"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"type",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        },
-        {
-            "width":120,
-            "readOnly":false,
-            "head":{
-                "titleNames":["备注"],
-                "spanCols":[1],
-                "spanRows":[1],
-                "vAlign":[1],
-                "hAlign":[1],
-                "font":["Arial"]
-            },
-            "data":{
-                "field":"memo",
-                "vAlign":1,
-                "hAlign":0,
-                "font":"Arial"
-            }
-        }
-    ]
-};
-
 let calcProgramObj = {
     sheet: null,
     treeNode: null,
@@ -204,8 +13,8 @@ let calcProgramObj = {
             {headerName: "费用代号", headerWidth: CP_Col_Width.code, dataCode: "code", dataType: "String", hAlign: "left"},
             {headerName: "费用名称", headerWidth: CP_Col_Width.name, dataCode: "name", dataType: "String"},
             {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.unitFee, dataCode: "unitFee", dataType: "Number"},  // execRst
+            {headerName: "费率", headerWidth: CP_Col_Width.feeRate, dataCode: "feeRate", dataType: "Number"},
+            {headerName: "单价", headerWidth: CP_Col_Width.unitFee, dataCode: "unitFee", dataType: "Number"},
             {headerName: "合价", headerWidth: CP_Col_Width.totalFee, dataCode: "totalFee", dataType: "Number"},
             {headerName:"费用类别", headerWidth:CP_Col_Width.displayFieldName, dataCode:"displayFieldName", dataType: "String", hAlign: "center"},
             {headerName: "基数说明", headerWidth: CP_Col_Width.statement, dataCode: "statement", dataType: "String"},
@@ -222,6 +31,11 @@ let calcProgramObj = {
     initSheet: function (sheet) {
         var me = this;
         me.sheet = sheet;
+        for (let col of me.setting.header){
+            if (col.headerName == '费率') col.tofix = decimalObj.feeRate;
+            if (col.headerName == '单价') col.tofix = decimalObj.ration.unitPrice;
+            if (col.headerName == '合价') col.tofix = decimalObj.ration.totalPrice;
+        };
         sheetCommonObj.initSheet(me.sheet, me.setting, 1);
     },
 
@@ -235,9 +49,6 @@ let calcProgramObj = {
         me.datas = treeNode.data.calcTemplate ? treeNode.data.calcTemplate.calcItems : [];
         sheetCommonObj.initSheet(me.sheet, me.setting, me.datas.length);
         sheetCommonObj.showData(me.sheet, me.setting, me.datas);
-
-        // SheetDataHelper.loadSheetHeader(calcProgramSetting, me.sheet);
-        //  SheetDataHelper.loadSheetData(calcProgramSetting, me.sheet, baseCalcField);
     },
 
     clearData: function (){

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

@@ -150,7 +150,8 @@ let MainTreeCol = {
                 node.sourceType === projectObj.project.Ration.getSourceType() ||
                 (projectObj.project.calcProgram.isLeafBill(node) && projectObj.project.property.billsCalcMode === leafBillGetFeeType.billsPrice)
             ) {
-                var names = new GC.Spread.Sheets.CellTypes.ComboBox();
+                // var names = new GC.Spread.Sheets.CellTypes.ComboBox();
+                var names = sheetCommonObj.getDynamicCombo();
                 names.items(projectObj.project.calcProgram.compiledTemplateNames);
                 return names;
             }
@@ -159,7 +160,7 @@ let MainTreeCol = {
         // CSL, 2017-11-28
         subType: function (node) {
             if (node.data.type == rationType.volumePrice || node.data.type == rationType.gljRation||node.sourceType === projectObj.project.ration_glj.getSourceType()){
-                let VPType = sheetCommonObj.getDynamicCombo();;
+                let VPType = sheetCommonObj.getDynamicCombo();
 
                 if (node.data.type == rationType.volumePrice)
                     VPType.itemHeight(5).items(["人工","材料","机械","主材","设备"])

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

@@ -37,7 +37,7 @@ decimalObj.decimal = function (field, node) {
             else if(node.sourceType === projectObj.project.Ration.getSourceType()){
                 return returnV(this['ration'][field], this.process);
             }
-            else if(node.sourceType === projectObj.project.GLJ.getSourceType()){
+            else if(node.sourceType === projectObj.project.ration_glj.getSourceType()){
                 return returnV(this['glj'][field], this.process);
             }
         }