Jelajahi Sumber

main Tree: edit control & show bills calc program

MaiXinRong 7 tahun lalu
induk
melakukan
c2791ef105

+ 25 - 0
public/web/sheet/sheet_data_helper.js

@@ -97,7 +97,32 @@ var SheetDataHelper = {
             sheet.setStyle(-1, iCol, SheetDataHelper.getSheetCellStyle(colSetting));
             datas.forEach(function (data, iRow) {
                 var cell = sheet.getCell(iRow, iCol, GC.Spread.Sheets.SheetArea.viewport);
+                var getFieldText2 = function () {
+                    var fields = colSetting.data.field.split('.'), iField, value = data;
+                    for (iField = 0; iField < fields.length; iField++) {
+                        if (value[fields[iField]]) {
+                            value = value[fields[iField]];
+                        } else {
+                            return '';
+                        }
+                    }
+                    return value;
+                };
                 cell.value(data[colSetting.data.field]);
+                if (colSetting.data.getText) {
+                    cell.value(colSetting.data.getText(data));
+                } else {
+                    cell.value(getFieldText2());
+                }
+                if (colSetting.readOnly) {
+                    if (Object.prototype.toString.apply(colSetting.readOnly) === "[object Function]") {
+                        cell.locked(colSetting.readOnly(node));
+                    } else {
+                        cell.locked(true);
+                    }
+                } else {
+                    cell.locked(false);
+                }
             });
         });
 

+ 1 - 1
test/tmp_data/bills_grid_setting.js

@@ -377,7 +377,7 @@ var BillsGridSetting ={
         },
         {
             "width":120,
-            "readOnly":'readOnly.volumePrice',
+            "readOnly":'readOnly.forCalcBase',
             "head":{
                 "titleNames":[
                     "计算基数"

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

@@ -525,6 +525,7 @@
     <script type="text/javascript" src="/web/building_saas/main/js/views/std_ration_lib.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/models/quantity_detail.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view_contextMenu.js"></script>
+    <script type="text/javascript" src="/web/building_saas/main/js/views/calc_program_view.js"></script>
     <!-- reports -->
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <script type="text/javascript" src="/public/web/ztree_common.js"></script>

+ 6 - 7
web/building_saas/main/js/calc/bills_calc.js

@@ -220,7 +220,6 @@ class BillsCalcHelper {
     constructor (project, CalcFlag) {
         this.project = project;
         this.CalcFlag = CalcFlag;
-        this.digit = 2;
         switch (this.CalcFlag) {
             case rationContent:
                 this.calcField = rationContentCalcFields;
@@ -250,7 +249,7 @@ class BillsCalcHelper {
     };
     calcRationLeaf (node, fields) {
         nodeCalcObj.node = node;
-        nodeCalcObj.digit = this.digit;
+        nodeCalcObj.digit = this.project.Decimal.unitFee;
         calcFees.checkFields(node.data, fields);
         let nodeCalc = nodeCalcObj, virData= null;
 
@@ -266,10 +265,10 @@ class BillsCalcHelper {
             nodeCalcObj.field = field;
             switch (field.unitFeeFlag) {
                 case rationContentUnitFeeFlag:
-                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(this.digit);
+                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.rationContentUnitFee().toDecimal(this.project.Decimal.common.unitFee);
                     break;
                 case averageQtyUnitFeeFlag:
-                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(this.digit);
+                    node.data.feesIndex[field.type].unitFee = nodeCalcObj.averageQty().toDecimal(this.project.Decimal.common.unitFee);
                     break;
                  case billsPriceUnitFeeFlag:
                      node.data.feesIndex[field.type].unitFee = virData[field.type];
@@ -279,10 +278,10 @@ class BillsCalcHelper {
             }
             switch (field.totalFeeFlag) {
                 case sumTotalFeeFlag:
-                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.digit);
+                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
                     break;
                 case totalFeeFlag:
-                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.totalFee().toDecimal(this.digit);
+                    node.data.feesIndex[field.type].totalFee = nodeCalcObj.totalFee().toDecimal(this.project.Decimal.common.totalFee);
                     break;
                 default:
                     node.data.feesIndex[field.type].totalFee = 0;
@@ -297,7 +296,7 @@ class BillsCalcHelper {
         calcFees.checkFields(node.data, fields);
         for (let field of fields) {
             nodeCalcObj.field = field;
-            node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.digit);
+            node.data.feesIndex[field.type].totalFee = nodeCalcObj.sumTotalFee().toDecimal(this.project.Decimal.common.totalFee);
         }
     };
     calcNodes (nodes) {

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

@@ -76,7 +76,7 @@ var PROJECT = {
             this.VolumePrice = VolumePrice.createNew(this);
             this.Decimal = {
                 common: {
-                    quantity: 2,
+                    quantity: 3,
                     unitFee: 2,
                     totalFee: 2
                 }

+ 210 - 0
web/building_saas/main/js/views/calc_program_view.js

@@ -0,0 +1,210 @@
+/**
+ * Created by Mai on 2017/7/28.
+ */
+
+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",
+                "getText": function (record) {
+                    if (record.type) {
+                        for (let ft of feeType) {
+                            if (ft.type === record.type) {
+                                return ft.name;
+                            }
+                        }
+                    }
+                    return '';
+                }
+            }
+        },
+        {
+            "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 = {
+    showBillsCalcProgram: function (node, calcProgram, sheet) {
+        SheetDataHelper.loadSheetHeader(calcProgramSetting, sheet);
+        SheetDataHelper.loadSheetData(calcProgramSetting, sheet, calcProgram);
+    }
+};

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

@@ -26,8 +26,21 @@ let MainTreeCol = {
         volumePrice: function (node) {
             return node.sourceType === projectObj.project.VolumePrice.getSourceType();
         },
+        non_bills: function (node) {
+            return node.sourceType !== projectObj.project.Bills.getSourceType();
+        },
+        non_ration: function (node) {
+            return node.sourceType !== projectObj.project.Ration.getSourceType();
+        },
+        non_volumePrice: function (node) {
+            return node.sourceType !== projectObj.project.Ration.getSourceType();
+        },
         billsParent: function (node) {
             return node.sourceType === projectObj.project.Bills.getSourceType() && node.source.children.length > 0;
+        },
+        forCalcBase: function (node) {
+            // to do according to billsParentType
+            return MainTreeCol.readOnly.billsParent && MainTreeCol.readOnly.non_bills;
         }
     },
     getEvent: function (eventName) {

+ 3 - 3
web/building_saas/main/js/views/project_view.js

@@ -18,7 +18,7 @@ var projectObj = {
                 alert('当前输入的数据类型不正确,请重新输入。');
             }
         } else {
-            value = info.editingText;
+            value = editingText;
         }
         return value;
     },
@@ -57,7 +57,7 @@ var projectObj = {
         if (colSetting.data.wordWrap) {
             info.sheet.autoFitRow(info.row);
         }
-        if (value) {
+        if (value && value != calcFees.getFee(node.data, fieldName)) {
             if (node.sourceType === project.Bills.getSourceType()) {
                 project.Bills.updateField(node.source, fieldName, value);
             } else if (node.sourceType === project.Ration.getSourceType()) {
@@ -149,7 +149,7 @@ var projectObj = {
                     // CSL.2017.07.25
                     if (SubActiveSheetNameIs('JSCX')) {
                         if (node.sourceType === that.project.Bills.getSourceType()) {
-                            rationCalcView.clearData();
+                            calcProgramObj.showBillsCalcProgram(node.source, baseCalcField, rationCalcView.sheet);
                         } else if (node.sourceType==='ration') {
                             rationCalcView.showData(node);
                         } else {

+ 6 - 4
web/building_saas/main/js/views/sub_view.js

@@ -60,12 +60,14 @@ $("#linkJSCX").click(function(){        // 计算程序
     subSpread.setActiveSheetIndex(4);
     rationCalcView.initSheet(subSpread.getSheet(4));
     let sel = projectObj.mainController.tree.selected;
-    if (sel != null && sel.sourceType == 'ration'){
+
+    if (sel.sourceType === projectObj.project.Bills.getSourceType()) {
+        calcProgramObj.showBillsCalcProgram(sel.source, baseCalcField, rationCalcView.sheet);
+    } else if (sel.sourceType==='ration') {
         rationCalcView.showData(sel);
-    }
-    else{
+    } else {
         rationCalcView.clearData();
-    };
+    }
 });
 
 $("#linkFXSM").click(function(){