ソースを参照

Merge branch 'master' of http://192.168.1.12:3000/SmartCost/ConstructionCost

TonyKang 8 年 前
コミット
68873ada00

+ 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();

+ 1 - 1
web/building_saas/fee_rates/fee_rate.html

@@ -88,7 +88,7 @@
     <div class="modal-dialog" role="document">
         <div class="modal-content">
             <div class="modal-header">
-                <h5 class="modal-title">费率1 重选标准</h5>
+                <h5 class="modal-title"><span id="set-lv-feeRateName">费率1</span>&nbsp;重选标准</h5>
                 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                     <span aria-hidden="true">&times;</span>
                 </button>

+ 1 - 0
web/building_saas/js/global.js

@@ -9,6 +9,7 @@ function autoFlashHeight(){
     $(".main-data-side-d").height($(window).height()-headerHeight-toolsbarHeight-toolsBarHeightD-202);
     $(".main-data-top").height($(window).height()-headerHeight-toolsbarHeight-bottomContentHeight-1);
     $(".main-data-full").height($(window).height()-headerHeight-toolsbarHeight-1);
+    $(".main-data-full-fl").height($(window).height()-headerHeight-toolsbarHeight-37);
     $(".main-data-side-search").height($(window).height()-headerHeight-toolsbarHeight-64);
     $(".side-content").height($(window).height()-headerHeight );
     $(".poj-list").height($(window).height()-headerHeight-toolsbarHeight);

+ 97 - 0
web/building_saas/main/html/calc_program_manage.html

@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+    <meta http-equiv="x-ua-compatible" content="ie=edge">
+</head>
+
+<body>
+    <div class="main">
+        <div class="content">
+            <div class="toolsbar">
+            </div>
+            <div class="container-fluid">
+                <div class="row">
+                  <div class="col-lg-3 p-0">
+                    <div class="main-data-full" id="mainSpread">
+                     </div>
+                   </div>
+                  <div class="col-lg-9 p-0">
+                    <div class="main-data-full" id="detailSpread">
+                    </div>
+                  </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <!--弹出 计算基数-->
+    <div class="modal fade" id="jsjs" data-backdrop="static">
+        <div class="modal-dialog" role="document">
+            <div class="modal-content">
+                <div class="modal-header">
+                  <h5 class="modal-title">计算基础选择</h5>
+                  <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                    <span aria-hidden="true">&times;</span>
+                  </button>
+                </div>
+                <div class="modal-body">
+                  <div class="form-group">
+                    <input class="form-control" value="分部分项工程费+100">
+                    <p class="form-text">
+                      <button class="btn btn-secondary btn-sm">+</button>
+                      <button class="btn btn-secondary btn-sm">-</button>
+                      <button class="btn btn-secondary btn-sm">*</button>
+                      <button class="btn btn-secondary btn-sm">/</button>
+                      <button class="btn btn-secondary btn-sm">(</button>
+                      <button class="btn btn-secondary btn-sm">)</button>
+                    </p>
+                  </div>
+                  <div class=" modal-auto-height">
+                    <table class="table table-sm table-bordered">
+                      <thead>
+                        <tr><th></th><th>计算基础名称</th><th>金额</th></tr>
+                      </thead>
+                      <tbody>
+                        <tr>
+                          <td>1</td><td><button class="btn btn-secondary btn-sm">分部分项工程费</button></td><td>1000.16</td>
+                        </tr>
+                        <tr>
+                          <td>2</td><td><button class="btn btn-secondary btn-sm">分部分项基价直接工程费</button></td><td>600.16</td>
+                        </tr>
+                        <tr>
+                          <td>3</td><td><button class="btn btn-secondary btn-sm">分部分项基价人工费</button></td><td>100.16</td>
+                        </tr>
+                        <tr>
+                          <td>4</td><td><button class="btn btn-secondary btn-sm">分部分项基价材料费</button></td><td>200.16</td>
+                        </tr>
+                        <tr>
+                          <td>5</td><td><button class="btn btn-secondary btn-sm">分部分项基价机械费</button></td><td>300.16</td>
+                        </tr>
+                        <tr>
+                          <td>6</td><td><button class="btn btn-secondary btn-sm">分部分项调整人工费</button></td><td>100.16</td>
+                        </tr>
+                        <tr>
+                          <td>7</td><td><button class="btn btn-secondary btn-sm">分部分项调整机人工费</button></td><td>50.16</td>
+                        </tr>
+                      </tbody>
+                    </table>
+                    <p></p>
+                      <p></p>
+                  </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
+                    <a href="" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
+</body>
+
+<script type="text/javascript" src="/public/web/sheet/sheet_common.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>

+ 9 - 6
web/building_saas/main/html/main.html

@@ -94,6 +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="#baobiao" role="tab" onclick="">报表</a></li>
             </ul>
         </div>
@@ -153,9 +154,6 @@
                                   <li class="nav-item">
                                       <a class="nav-link" id="linkDESM" data-toggle="tab" href="#subSpread" role="tab">定额说明</a>
                                   </li>
-                                  <li class="nav-item">
-                                      <a class="nav-link" id="linkJSCXGL" data-toggle="tab" href="#subSpread" role="tab">计算程序管理</a>
-                                  </li>
                               </ul>
                               <!-- Tab panes -->
                               <div class="tab-content">
@@ -459,6 +457,9 @@
             <div class="tab-pane" id="fee_rates" role="tabpanel">
                 <%include ../../fee_rates/fee_rate.html %>
             </div>
+            <div class="tab-pane" id="calc_program_manage" role="tabpanel">
+                <%include calc_program_manage.html %>
+            </div>
           </div>
 
         </div>
@@ -517,7 +518,6 @@
     <script type="text/javascript" src="/web/building_saas/main/js/calc/ration_calc.js"></script>
     <script type="text/javascript" src="/web/building_saas/main/js/calc/bills_calc.js"></script>
     <script type="text/javascript" src="/public/calc_util.js"></script>
-    <script type="text/javascript" src="/web/building_saas/main/js/models/ration_program.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>
@@ -548,9 +548,7 @@
     <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/ration_programs_manage.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,6 +612,11 @@
             // 获取project
             var projectId = getQueryString('project');
             $("#glj-link").attr("href", "/glj?project=" + projectId);
+
+/*            $("#tab_calc_program").click(function(){
+                location.href = '/web/building_saas/main/html/calc_program.html';
+            });*/
+
             rptTplObj.iniPage();
   		});
   		//-->

+ 0 - 18
web/building_saas/main/html/ration_pm.html

@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head lang="en">
-    <meta charset="UTF-8">
-    <title>计算程序管理</title>
-    <script src="/lib/jquery/jquery.min.js"></script>
-    <link rel="stylesheet" href="/lib/spreadjs/sheets/css/gc.spread.sheets.excel2013lightGray.10.0.1.css" type="text/css">
-    <script type="text/javascript" src="/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
-    <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>
-</head>
-<body>
-<div id="mainSpread" style="width:30%;height:400px;position:absolute;"></div>
-<div id="detailSpread" style="width:100%;height:400px;position:absolute;bottom:5px;"></div>
-
-</body>
-</html>

+ 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);
                 }
             }
         };

+ 3 - 1
web/building_saas/main/js/views/ration_programs_manage.js

@@ -71,7 +71,9 @@ let rationPM = {
 };
 
 $(document).ready(function(){
-    rationPM.buildSheet();
+    $('#tab_calc_program_manage').on('shown.bs.tab', function (e) {
+        rationPM.buildSheet();
+    });
 });
 
 

+ 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;
+        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);
+    },
+
+    clearData: function (){
+        var me = this;
+        me.treeNode = null;
+        sheetCommonObj.cleanSheet(me.sheet, me.setting, -1);
+    },
+
+    showBillsCalcProgram: function (node, calcProgram) {
+        var me = this;
+        SheetDataHelper.loadSheetHeader(calcProgramSetting, me.sheet);
+        SheetDataHelper.loadSheetData(calcProgramSetting, me.sheet, calcProgram);
     }
 };
+

+ 4 - 8
web/building_saas/main/js/views/fee_rate_view.js

@@ -117,7 +117,8 @@ var feeRateObject={
         if(this.mainViews){
             this.mainViews.refresh()
         }else {
-            setTimeout("feeRateObject.createSpreadView()",100);
+            feeRateObject.createSpreadView();
+            //setTimeout("feeRateObject.createSpreadView()",100);
         }
     },
     updateBySelect:function (rate,selectMap,mapID) {
@@ -356,11 +357,9 @@ $('#pop-lv').popover({
     }
 );
 
-
-$('#tab_fee_rate').bind('click', function () {
+$('#tab_fee_rate').on('shown.bs.tab', function (e) {
     feeRateObject.reFreshRateViews();
     feeRateObject.loadPageContent();
-    //feeRateObject.loadFeeRateSelection();
 });
 
 $('#setNewFeeRate').bind('click', function () {
@@ -371,6 +370,7 @@ $('#setNewFeeRate').bind('click', function () {
         listString+="<li>"+u.name+"</li>"
     })
     $("#usageProjectList").html(listString);
+    $("#set-lv-feeRateName").text(feeRateFile.name);
 
     feeRateObject.getFeeRateStandards(function (data) {
         $('#standardSelect').empty();
@@ -380,7 +380,6 @@ $('#setNewFeeRate').bind('click', function () {
         })
         $('#standardSelect').val(feeRateFile.libID);
     });
-
 });
 $('#changeConfirm').bind('click', function (){
     var newVal=$('#standardSelect').val();
@@ -441,11 +440,8 @@ $('#changeFeeRateConfirm').bind('click',function (){
     }else {
         feeRateObject.changeFeeRateFileFromOthers();
     }
-
 })
 
-
-
 $('#changFeeRateFile').bind('click',function (){
     $("input[name='chaneg-lv-Radio']")[0].checked=true;
     $("#fromProject").show();

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

@@ -151,11 +151,11 @@ 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);
+                            calcProgramObj.showBillsCalcProgram(node.source, baseCalcField);
+                        } else if (node.sourceType=== that.project.Ration.getSourceType()) {
+                            calcProgramObj.showData(node);
                         } else {
-                            rationCalcView.clearData();
+                            calcProgramObj.clearData();
                         }
                     }
                 });
@@ -168,8 +168,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 - 9
web/building_saas/main/js/views/sub_view.js

@@ -58,15 +58,15 @@ $("#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);
+        calcProgramObj.showBillsCalcProgram(sel.source, baseCalcField);
+    } else if (sel.sourceType=== projectObj.project.Ration.getSourceType()) {
+        calcProgramObj.showData(sel);
     } else {
-        rationCalcView.clearData();
+        calcProgramObj.clearData();
     }
 });
 
@@ -82,10 +82,6 @@ $("#linkDESM").click(function(){
     subSpread.getActiveSheet().setValue(0, 0, "定额说明");
 });
 
-$("#linkJSCXGL").click(function(){
-    location.href = '/web/building_saas/main/html/ration_pm.html';
-});
-
 function SubActiveSheetNameIs(sheetName){
     let rst = subSpread.getActiveSheet().name() == sheetName;
     return rst;