Przeglądaj źródła

Merge branch 'master' into olym

caiaolin 8 lat temu
rodzic
commit
5767dfac53

+ 1 - 0
modules/reports/models/rpt_cfg.js

@@ -1,5 +1,6 @@
 /**
  * Created by Tony on 2017/6/14.
+ * 把报表相关的配置(字体、边框、格式等都放在一条记录中,方便整理,毕竟用户的报表格式基本是固定的,无需怎样调整)
  */
 let mongoose = require('mongoose');
 let Schema = mongoose.Schema;

+ 1 - 0
modules/reports/models/rpt_mapping_field.js

@@ -1,5 +1,6 @@
 /**
  * Created by Tony on 2017/7/11.
+ * 为后台报表模板选择指标用
  */
 let mongoose = require('mongoose');
 let MapFieldSchema = new mongoose.Schema({

+ 1 - 0
modules/reports/models/rpt_template.js

@@ -1,5 +1,6 @@
 /**
  * Created by Tony on 2016/12/23.
+ * 仅仅是存放报表模板的地方,由谁来引用是TreeNodeSchema的事情
  */
 let mongoose = require('mongoose');
 let Schema = mongoose.Schema;

+ 1 - 0
modules/reports/models/tpl_tree_node.js

@@ -1,5 +1,6 @@
 /**
  * Created by Tony on 2017/5/31.
+ * 不同的用户会有一套自己的模板结构列表
  */
 let mongoose = require('mongoose');
 let Schema = mongoose.Schema;

+ 8 - 0
modules/reports/rpt_component/jpc_bill_tab.js

@@ -20,6 +20,14 @@ JpcBillTabSrv.prototype.createNew = function(){
         let me = this;
         JpcFieldHelper.findAndPutDataFieldIdx(rptTpl, rptTpl[JV.NODE_BILL_INFO][JV.NODE_BILL_CONTENT][JV.PROP_BILL_FIELDS], null, me.disp_fields_idx);
     };
+    JpcBillTabResult.paging = function(rptTpl) {
+        let me = this, rst = 0;
+        let detail_fields = rptTpl[JV.NODE_FIELD_MAP][JV.NODE_DETAIL_FIELDS];
+        if (detail_fields && detail_fields.length > 0) {
+            rst = detail_fields[0].length;
+        }
+        return rst;
+    };
     JpcBillTabResult.outputAsSimpleJSONPage = function (rptTpl, dataObj, page, bands, controls, $CURRENT_RPT) {
         let me = this, rst = [], tabRstLst = [];
         //1 calculate the band position

+ 1 - 1
modules/reports/rpt_component/jpc_ex.js

@@ -148,7 +148,7 @@ JpcExSrv.prototype.createNew = function(){
         } else if (me.crossTab) {
             me.totalPages = me.crossTab.preSetupPages(rptTpl, defProperties);
         } else if (me.billTab) {
-            //me.totalPages = billTab.paging();
+            me.totalPages = me.billTab.paging();
         }
     };
     JpcResult.executeFormulas = function(runType, $CURRENT_TEMPLATE, $CURRENT_DATA, $CURRENT_RPT) {

+ 18 - 19
public/calc_util.js

@@ -4,11 +4,11 @@
  */
 
 let executeObj = {
-    ration: null,
+    treeNode: null,
     at: function(ID) {
         let me = executeObj,
             rst = 0;
-        rst = me.ration.data.calcTemplate.compiledTemplate[ID].unitFee;
+        rst = me.treeNode.data.calcTemplate.compiledTemplate[ID].unitFee;
         rst = parseFloat(rst);
         return rst;
     },
@@ -18,7 +18,7 @@ let executeObj = {
 
         if (base != null) {
             let price = 0, tmpSum = 0;
-            for (let glj of me.ration.data.gljList) {
+            for (let glj of me.treeNode.data.gljList) {
                 if (base.gljTypes.indexOf(glj.type) >= 0) {
                     if (base.calcType == baseCalc){ price = glj["basePrice"];}
                     else if (base.calcType == adjustCalc){price = glj["adjustPrice"];}
@@ -159,17 +159,17 @@ class Calculation {
         }
     };
 
-    calculate($RATION){         // 参数$RATION也可以是清单
+    calculate($treeNode){
         let me = this;
-        let template = $RATION.data.calcTemplate;
+        let template = $treeNode.data.calcTemplate;
 
-        if ($RATION && template.hasCompiled) {
+        if ($treeNode && template.hasCompiled) {
             let $CE = executeObj;
-            $CE.ration = $RATION;
+            $CE.treeNode = $treeNode;
 
-            if (!$RATION.fees) {
-                $RATION.fees = [];
-                $RATION.feesIndex = {};
+            if (!$treeNode.fees) {
+                $treeNode.fees = [];
+                $treeNode.feesIndex = {};
             };
 
             for (let idx of template.compiledSeq) {
@@ -182,11 +182,13 @@ class Calculation {
                     calcItem.feeRate = feeRate;
                 };
                 calcItem.unitFee = eval(calcItem.compiledExpr) * feeRate * 0.01;   // 如果eval()对清单树有影响,就换成小麦的Expression对象再试
-                calcItem.totalFee = calcItem.unitFee * 3;     // AAAAAA 测试值,因目前定额无数量(保存不上) $RATION.data.Quantity
+                let quantity = $treeNode.data.quantity;
+                if (!quantity) quantity = 0;
+                calcItem.totalFee = calcItem.unitFee * quantity;
 
                 // 费用同步到定额
                 // 引入小麦的字段检测后,快速切换定额出现计算卡顿现象,过多的循环造成。这里把她的代码拆出来,减少微循环。
-                if (!$RATION.feesIndex[calcItem.fieldName]){
+                if (!$treeNode.feesIndex[calcItem.fieldName]){
                     let fee = {
                         'fieldName': calcItem.fieldName,
                         'unitFee': calcItem.unitFee,
@@ -194,17 +196,14 @@ class Calculation {
                         'tenderUnitFee': 0,
                         'tenderTotalFee': 0
                     };
-                    $RATION.fees.push(fee);
-                    $RATION.feesIndex[calcItem.fieldName] = fee;
+                    $treeNode.fees.push(fee);
+                    $treeNode.feesIndex[calcItem.fieldName] = fee;
                 }
                 else{
-                    $RATION.feesIndex[calcItem.fieldName].unitFee = calcItem.unitFee;
-                    $RATION.feesIndex[calcItem.fieldName].totalFee = calcItem.totalFee;
+                    $treeNode.feesIndex[calcItem.fieldName].unitFee = calcItem.unitFee;
+                    $treeNode.feesIndex[calcItem.fieldName].totalFee = calcItem.totalFee;
                 }
             }
         }
     }
 }
-
-
-//module.exports = new calculation();

+ 2 - 2
web/building_saas/main/html/calc_program_manage.html

@@ -91,7 +91,7 @@
 </body>
 
 <script type="text/javascript" src="/public/web/sheet/sheet_common.js"></script>
-<script type="text/javascript" src="/web/building_saas/main/js/models/ration_program.js"></script>
-<script type="text/javascript" src="/web/building_saas/main/js/views/ration_programs_manage.js"></script>
+<script type="text/javascript" src="/web/building_saas/main/js/models/calc_program.js"></script>
+<script type="text/javascript" src="/web/building_saas/main/js/views/calc_program_manage.js"></script>
 
 </html>

+ 3 - 4
web/building_saas/main/html/main.html

@@ -94,7 +94,7 @@
                 <li class="nav-item"><a class="active" data-toggle="tab" href="#zaojiashu" role="tab">造价书</a></li>
                 <li class="nav-item"><a href="#" id="glj-link">工料机</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#fee_rates" id="tab_fee_rate" role="tab" onclick="">费率</a></li>
-                <li class="nav-item"><a data-toggle="tab" href="#calc_program_manage" id="tab_calc_program_manage" role="tab" onclick="">计算程序管理</a></li>
+                <li class="nav-item"><a data-toggle="tab" href="#calc_program_manage" id="tab_calc_program_manage" role="tab" onclick="">计算程序</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#baobiao" role="tab" onclick="">报表</a></li>
             </ul>
         </div>
@@ -548,7 +548,6 @@
     <script type="text/javascript" src="/web/building_saas/main/js/rpt/rpt_main.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/rpt/rpt_cfg_const.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/glj_view.js"></script>
-    <script type="text/javascript" src="/web/building_saas/main/js/views/ration_calc_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/sub_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/fee_rate_view.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/views/sub_fee_rate_views.js"></script>
@@ -614,9 +613,9 @@
             var projectId = getQueryString('project');
             $("#glj-link").attr("href", "/glj?project=" + projectId);
 
-            $("#tab_calc_program").click(function(){
+/*            $("#tab_calc_program").click(function(){
                 location.href = '/web/building_saas/main/html/calc_program.html';
-            });
+            });*/
 
             rptTplObj.iniPage();
   		});

+ 5 - 5
web/building_saas/main/js/models/ration_program.js

@@ -3592,7 +3592,7 @@ let calcLabourCoes = [
     }
 ];
 
-class RationProgram {
+class CalcProgram {
     constructor(project){
         this.project = project;
         this.calc = new Calculation();
@@ -3608,9 +3608,9 @@ class RationProgram {
        this.calc.compile(calcTemplate, calcFeeRates, calcLabourCoes);
     };
 
-    calculate(ration){
-        ration.data.gljList = this.project.ration_glj.getGljArrByRation(ration.data.ID);
-        ration.data.calcTemplate = calcTemplates[0];  // AAAAAA = getCalcTemplate($RATION.calcTemplateID);
-        this.calc.calculate(ration);
+    calculate(treeNode){
+        treeNode.data.gljList = this.project.ration_glj.getGljArrByRation(treeNode.data.ID);
+        treeNode.data.calcTemplate = calcTemplates[0];  // AAAAAA = getCalcTemplate($RATION.calcTemplateID);
+        this.calc.calculate(treeNode);
     };
 }

+ 2 - 2
web/building_saas/main/js/models/fee_rate.js

@@ -142,8 +142,8 @@ var FeeRate = {
         FeeRate.prototype.synchronizeFeeRate = function () {
             var node = project.mainTree.selected;
             if(node){
-                if (node.sourceType==='ration'&&rationCalcView.sheet) {
-                    rationCalcView.showData(node);
+                if (node.sourceType==='ration' && calcProgramObj.sheet) {
+                    calcProgramObj.showData(node);
                 }
             }
         };

web/building_saas/main/js/views/ration_programs_manage.js → web/building_saas/main/js/views/calc_program_manage.js


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

@@ -1,7 +1,10 @@
 /**
  * Created by Mai on 2017/7/28.
+ * Modified by CSL on 2017/08/21.
+ * 整合清单、定额的计算程序,代码合并、类合并、剔除多余单元。
  */
 
+
 let calcProgramSetting ={
     "emptyRows":0,
     "headRows":1,
@@ -203,8 +206,52 @@ let calcProgramSetting ={
 };
 
 let calcProgramObj = {
-    showBillsCalcProgram: function (node, calcProgram, sheet) {
-        SheetDataHelper.loadSheetHeader(calcProgramSetting, sheet);
-        SheetDataHelper.loadSheetData(calcProgramSetting, sheet, calcProgram);
+    sheet: null,
+    treeNode: null,
+
+    setting: {
+        header: [
+            {headerName: "费用代号", headerWidth: 75, dataCode: "code", dataType: "String", hAlign: "left"},
+            {headerName: "费用名称", headerWidth: 200, dataCode: "name", dataType: "String"},
+            {headerName: "计算基数", headerWidth: 200, dataCode: "dispExpr", dataType: "String"},
+            {headerName: "基数说明", headerWidth: 400, dataCode: "statement", dataType: "String"},
+            {headerName: "费率", headerWidth: 80, dataCode: "feeRate", dataType: "Number"},   // precision: 3
+            {headerName: "单价", headerWidth: 100, dataCode: "unitFee", dataType: "Number"},  // execRst
+            {headerName: "合价", headerWidth: 100, dataCode: "totalFee", dataType: "Number"},
+            {headerName: "备注", headerWidth: 120, dataCode: "memo", dataType: "String"}
+        ],
+        view: {
+            comboBox: [],
+            lockColumns: [0, 1, 2, 3, 4, 5, 6, 7]
+        }
+    },
+
+    initSheet: function (sheet) {
+        var me = this;
+        me.sheet = sheet;
+        sheetCommonObj.initSheet(me.sheet, me.setting, 20);
+    },
+
+    showData: function (treeNode) {
+        var me = this;
+        me.treeNode = treeNode;
+        if (treeNode.sourceType === projectObj.project.Ration.getSourceType()) {
+            projectObj.project.calcProgram.calculate(treeNode);
+            me.datas = me.treeNode.data.calcTemplate.calcItems;
+            //me.sheet.setRowCount(me.datas.length);
+            sheetCommonObj.initSheet(me.sheet, me.setting, me.datas.length);
+            sheetCommonObj.showData(me.sheet, me.setting, me.datas);
+        }
+        else if (treeNode.sourceType === projectObj.project.Bills.getSourceType()) {
+            SheetDataHelper.loadSheetHeader(calcProgramSetting, me.sheet);
+            SheetDataHelper.loadSheetData(calcProgramSetting, me.sheet, baseCalcField);
+        }
+    },
+
+    clearData: function (){
+        var me = this;
+        me.treeNode = null;
+        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
     }
 };
+

+ 7 - 9
web/building_saas/main/js/views/project_view.js

@@ -150,14 +150,12 @@ var projectObj = {
 
                     // CSL.2017.07.25
                     if (SubActiveSheetNameIs('JSCX')) {
-                        if (node.sourceType === that.project.Bills.getSourceType()) {
-                            calcProgramObj.showBillsCalcProgram(node.source, baseCalcField, rationCalcView.sheet);
-                        } else if (node.sourceType==='ration') {
-                            rationCalcView.showData(node);
+                        if (node.sourceType === that.project.Bills.getSourceType() || node.sourceType === that.project.Ration.getSourceType()) {
+                            calcProgramObj.showData(node);
                         } else {
-                            rationCalcView.clearData();
-                        }
-                    }
+                            calcProgramObj.clearData();
+                        };
+                    };
                 });
 
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
@@ -168,8 +166,8 @@ var projectObj = {
 
             }
         });
-        this.project.rationProgram = new RationProgram(this.project);
-        this.project.rationProgram.compileAllTemps();
+        this.project.calcProgram = new CalcProgram(this.project);
+        this.project.calcProgram.compileAllTemps();
     },
     loadMainSpreadContextMenu: function () {
         var project = this.project, spread = this.mainSpread, controller = this.mainController;

+ 0 - 48
web/building_saas/main/js/views/ration_calc_view.js

@@ -1,48 +0,0 @@
-/**
- * Created by CSL on 2017-07-17.
- */
-
-let rationCalcView = {
-    sheet: null,
-    treeNode: null,
-
-    setting: {
-        header: [
-            {headerName: "费用代号", headerWidth: 75, dataCode: "code", dataType: "String", hAlign: "left"},
-            {headerName: "费用名称", headerWidth: 200, dataCode: "name", dataType: "String"},
-            {headerName: "计算基数", headerWidth: 200, dataCode: "dispExpr", dataType: "String"},
-            {headerName: "基数说明", headerWidth: 400, dataCode: "statement", dataType: "String"},
-            {headerName: "费率", headerWidth: 80, dataCode: "feeRate", dataType: "Number"},   // precision: 3
-            {headerName: "单价", headerWidth: 100, dataCode: "unitFee", dataType: "Number"},  // execRst
-            {headerName: "合价", headerWidth: 100, dataCode: "totalFee", dataType: "Number"},
-            {headerName: "备注", headerWidth: 120, dataCode: "memo", dataType: "String"}
-        ],
-        view: {
-            comboBox: [],
-            lockColumns: [0, 1, 2, 3, 4, 5, 6, 7]
-        }
-    },
-
-    initSheet: function (sheet) {
-        var me = this;
-        me.sheet = sheet;
-        sheetCommonObj.initSheet(me.sheet, me.setting, 20);
-    },
-
-    showData: function (treeNode) {
-        var me = this;
-        me.treeNode = treeNode;
-        projectObj.project.rationProgram.calculate(treeNode);
-        me.datas = me.treeNode.data.calcTemplate.calcItems;
-        //me.sheet.setRowCount(me.datas.length);
-        sheetCommonObj.initSheet(me.sheet, me.setting, me.datas.length);
-        sheetCommonObj.showData(me.sheet, me.setting, me.datas);
-    },
-
-    clearData: function (){
-        var me = this;
-        me.treeNode = null;
-        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
-    }
-
-}

+ 5 - 7
web/building_saas/main/js/views/sub_view.js

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