Browse Source

点击项目管理树结点,汇总计算单项工程、建设项目各项金额。

chenshilong 7 years ago
parent
commit
3d6e286a74
2 changed files with 38 additions and 46 deletions
  1. 14 14
      web/building_saas/pm/html/project-management.html
  2. 24 32
      web/building_saas/pm/js/pm_main.js

+ 14 - 14
web/building_saas/pm/html/project-management.html

@@ -123,15 +123,15 @@
                     <thead>
                     <tr>
                         <th rowspan="2"></th>
-                        <th rowspan="2">序号</th>
-                        <th rowspan="2">单位工程名称</th>
-                        <th rowspan="2">金额(元)</th>
-                        <th colspan="3">其中</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle;">序号</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle;">单位工程名称</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle;">金额(元)</th>
+                        <th colspan="3" style="text-align:center;vertical-align:middle;">其中</th>
                     </tr>
                     <tr>
-                        <th>暂估价(元)</th>
-                        <th>安全文明施工费(元)</th>
-                        <th>规费(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">暂估价(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">安全文明施工费(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">规费(元)</th>
                     </tr>
                     </thead>
                     <tbody></tbody>
@@ -168,15 +168,15 @@
                     <thead>
                     <tr>
                         <th rowspan="2"></th>
-                        <th rowspan="2">序号</th>
-                        <th rowspan="2">单位工程名称</th>
-                        <th rowspan="2">金额(元)</th>
-                        <th colspan="3">其中</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle">序号</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle">单位工程名称</th>
+                        <th rowspan="2" style="text-align:center;vertical-align:middle">金额(元)</th>
+                        <th colspan="3" style="text-align:center;vertical-align:middle">其中</th>
                     </tr>
                     <tr>
-                        <th>暂估价(元)</th>
-                        <th>安全文明施工费(元)</th>
-                        <th>规费(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">暂估价(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">安全文明施工费(元)</th>
+                        <th style="text-align:center;vertical-align:middle;">规费(元)</th>
                     </tr>
                     </thead>
                     <tbody>

+ 24 - 32
web/building_saas/pm/js/pm_main.js

@@ -1658,46 +1658,38 @@ function setDataToSideBar() {
         return;
     }*/
     if(selectedItem.children.length > 0){
-
-/*        function calcNode(node) {
-            let sum_tf = 0, sum_ef = 0, sum_sf = 0, sum_cf = 0;
-
-            if (node.children.length > 0){
-                for (let cNode of node.children){
-                     calcNode(cNode);
+        // CSL, 2018-01-11 汇总单项工程、建设项目。
+        function calcNode(node){
+            if (node.data.projType == projectType.project || node.data.projType == projectType.engineering){
+                node.data.summaryFees = {totalFee: 0, estimateFee: 0, safetyFee: 0, chargeFee: 0};
+                for (let child of node.children){
+                    calcNode(child);
+                    node.data.summaryFees.totalFee = parseFloat(node.data.summaryFees.totalFee) + parseFloat(child.data.summaryFees.totalFee);
+                    node.data.summaryFees.estimateFee = parseFloat(node.data.summaryFees.estimateFee) + parseFloat(child.data.summaryFees.estimateFee);
+                    node.data.summaryFees.safetyFee = parseFloat(node.data.summaryFees.safetyFee) + parseFloat(child.data.summaryFees.safetyFee);
+                    node.data.summaryFees.chargeFee = parseFloat(node.data.summaryFees.chargeFee) + parseFloat(child.data.summaryFees.chargeFee);
                 };
+            }else{
+                if (!node.data.summaryFees)
+                    node.data.summaryFees = {totalFee: 0, estimateFee: 0, safetyFee: 0, chargeFee: 0};
             };
+        };
 
-            if (node.data.projType == projectType.tender){
-
-            }
-
-        }*/
         // 建设项目相关
         let counter = 1;
         let html = '';
-        let sum_tf = 0, sum_ef = 0, sum_sf = 0, sum_cf = 0;
+
+        calcNode(selectedItem);
         for(let tmp of selectedItem.children) {
-            let tf = 0, ef = 0, sf = 0, cf = 0;
-            if (tmp.data.summaryFees){
-                tf = parseFloat(tmp.data.summaryFees.totalFee);
-                ef = parseFloat(tmp.data.summaryFees.estimateFee);
-                sf = parseFloat(tmp.data.summaryFees.safetyFee);
-                cf = parseFloat(tmp.data.summaryFees.chargeFee);
-                sum_tf = sum_tf + tf;
-                sum_ef = sum_ef + ef;
-                sum_sf = sum_sf + sf;
-                sum_cf = sum_cf + cf;
-            };
 
             html += '<tr>' +
                 '<td>'+ counter +'</td>' +
                 '<td>'+ counter +'</td>' +
                 '<td>'+ tmp.data.name +'</td>' +
-                '<td>'+ tf + '</td>' +
-                '<td>'+ ef + '</td>' +
-                '<td>'+ sf + '</td>' +
-                '<td>'+ cf + '</td>' +
+                '<td style="text-align:right">'+ tmp.data.summaryFees.totalFee + '</td>' +
+                '<td style="text-align:right">'+ tmp.data.summaryFees.estimateFee + '</td>' +
+                '<td style="text-align:right">'+ tmp.data.summaryFees.safetyFee + '</td>' +
+                '<td style="text-align:right">'+ tmp.data.summaryFees.chargeFee + '</td>' +
                 '</tr>';
 
         }
@@ -1706,10 +1698,10 @@ function setDataToSideBar() {
             '<td>'+ (counter + 1) +'</td>' +
             '<td> </td>' +
             '<td>合计</td>' +
-            '<td>'+ sum_tf + '</td>' +
-            '<td>'+ sum_ef + '</td>' +
-            '<td>'+ sum_sf + '</td>' +
-            '<td>'+ sum_cf + '</td>' +
+            '<td style="text-align:right">'+ selectedItem.data.summaryFees.totalFee + '</td>' +
+            '<td style="text-align:right">'+ selectedItem.data.summaryFees.estimateFee + '</td>' +
+            '<td style="text-align:right">'+ selectedItem.data.summaryFees.safetyFee + '</td>' +
+            '<td style="text-align:right">'+ selectedItem.data.summaryFees.chargeFee + '</td>' +
             '</tr>';
         $(target + '-table tbody').html(html);
     }