浏览代码

章节合计

MaiXinRong 5 年之前
父节点
当前提交
cf57598ceb
共有 6 个文件被更改,包括 332 次插入52 次删除
  1. 67 0
      app/public/js/gcl_gather.js
  2. 74 0
      app/public/js/ledger_gather.js
  3. 1 1
      app/public/js/stage.js
  4. 94 10
      app/public/js/stage_gather.js
  5. 45 16
      app/view/ledger/gather.ejs
  6. 51 25
      app/view/stage/gather.ejs

+ 67 - 0
app/public/js/gcl_gather.js

@@ -399,11 +399,78 @@ const gclGatherModel = (function () {
         }
         }
     }
     }
 
 
+    function _getCalcChapter(chapter) {
+        const gclChapter = [], otherChapter = [];
+        let serialNo = 1;
+        for (const c of chapter) {
+            const cc = { code: c.code, name: c.name, cType: 1 };
+            cc.serialNo = serialNo++;
+            cc.filter = '^' + c.code.substr(0, c.code.length - 2) + '[0-9]{2}-';
+            gclChapter.push(cc);
+        }
+        gclChapter.push({ name: '未计入章节清单合计', cType: 21, serialNo: serialNo++, });
+        otherChapter.push({ name: '清单小计(A)', cType: 11, serialNo: serialNo++ });
+        otherChapter.push({ name: '非清单项费用(B)', cType: 31, serialNo: serialNo++ });
+        otherChapter.push({ name: '合计(C=A+B)', cType: 41, serialNo: serialNo });
+        return [gclChapter, otherChapter];
+    }
+
+    function _gatherChapterFields(chapter, data, fields) {
+        for (const f of fields) {
+            chapter[f] = ZhCalc.add(chapter[f], data[f]);
+        }
+    }
+
+    function _getGclChapter(chapter, data) {
+        for (const c of chapter) {
+            if (c.filter) {
+                const reg = new RegExp(c.filter);
+                if (reg.test(data.b_code)) {
+                    return c;
+                }
+            } else {
+                return c;
+            }
+        }
+    }
+
+    function gatherChapterData(chapter, fields) {
+        const [gclChapter, otherChapter] = _getCalcChapter(chapter);
+        for (const d of gsTree.datas) {
+            if (d.children && d.children.length > 0) continue;
+
+            for (const c of otherChapter) {
+                if (c.cType === 41) {
+                    gatherfields(c, d, fields);
+                } else if (c.cType === 31 && (!d.b_code || d.b_code === '')) {
+                    gatherfields(c, d, fields);
+                } else if (c.cType === 11 && (d.b_code)) {
+                    gatherfields(c, d, fields);
+                }
+            }
+            if (d.b_code) {
+                const c = _getGclChapter(gclChapter, d);
+                gatherfields(c, d, fields);
+            }
+        }
+        for (const d of deal) {
+            for (const c of otherChapter) {
+            if (c.cType === 41 || c.cType === 11) {
+                c.deal_bills_tp = ZhCalc.add(c.deal_bills_tp, d.total_price);
+            }
+        }
+            const c = _getGclChapter(gclChapter, d);
+            c.deal_bills_tp = ZhCalc.add(c.deal_bills_tp, d.total_price);
+        }
+        return gclChapter.concat(otherChapter);
+    }
+
     return {
     return {
         loadLedgerData,
         loadLedgerData,
         loadPosData,
         loadPosData,
         loadDealBillsData,
         loadDealBillsData,
         gatherGclData,
         gatherGclData,
         checkDiffer,
         checkDiffer,
+        gatherChapterData,
     };
     };
 })();
 })();

+ 74 - 0
app/public/js/ledger_gather.js

@@ -76,6 +76,26 @@ $(document).ready(() => {
         }
         }
     });
     });
 
 
+    function generateChapterHtml(data) {
+        const html = [];
+        if (data) {
+            for (const d of data) {
+                html.push('<tr>');
+                if (d.code) {
+                    html.push('<td>', d.code, '</td>');
+                    html.push('<td>', d.name, '</td>');
+                } else {
+                    html.push('<td colspan="2">', d.name, '</td>');
+                }
+                html.push('<td class="text-right">', d.deal_bills_tp ? d.deal_bills_tp : '', '</td>');
+                html.push('<td class="text-right">', d.total_price ? d.total_price : '', '</td>');
+                html.push('<td class="text-right">', d.compare_tp ? d.compare_tp : '', '</td>');
+                html.push('</tr>');
+            }
+        }
+        $('#chapter-list').html(html.join(''));
+    }
+
     postData(window.location.pathname + '/load', {}, function (data) {
     postData(window.location.pathname + '/load', {}, function (data) {
         gclGatherModel.loadLedgerData(data.bills);
         gclGatherModel.loadLedgerData(data.bills);
         gclGatherModel.loadPosData(data.pos);
         gclGatherModel.loadPosData(data.pos);
@@ -88,8 +108,55 @@ $(document).ready(() => {
         }
         }
         SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData);
         SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData);
         loadLeafXmjData(0);
         loadLeafXmjData(0);
+
+        const chapterData = gclGatherModel.gatherChapterData(chapter, ['total_price']);
+        for (const c of chapterData) {
+            c.compare_tp = ZhCalc.sub(c.deal_bills_tp, c.total_price);
+        }
+        generateChapterHtml(chapterData);
     }, null, true);
     }, null, true);
 
 
+    // 展开收起附件
+    $('a', '.right-nav').bind('click', function () {
+        const tab = $(this), tabPanel = $(tab.attr('content'));
+        const showTools = function (show) {
+            const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
+            if (show) {
+                right.show();
+                autoFlashHeight();
+                /**
+                 * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
+                 * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
+                 * 故需要通过最终的parent.width再计算一次left.width
+                 *
+                 * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
+                 * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
+                 *
+                 */
+                    //left.css('width', parent.width() - right.outerWidth());
+                    //left.css('width', parent.width() - right.outerWidth());
+                const percent = 100 - right.outerWidth() /parent.width() * 100;
+                left.css('width', percent + '%');
+            } else {
+                right.hide();
+                left.css('width', '100%');
+            }
+        };
+        if (!tab.hasClass('active')) {
+            $('a', '.side-menu').removeClass('active');
+            $('.tab-content .tab-select-show').removeClass('active');
+            tab.addClass('active');
+            tabPanel.addClass('active');
+            showTools(tab.hasClass('active'));
+        } else {
+            tab.removeClass('active');
+            tabPanel.removeClass('active');
+            showTools(tab.hasClass('active'));
+        }
+        gclSpread.refresh();
+        leafXmjSpread.refresh();
+    });
+
     $.subMenu({
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
@@ -117,4 +184,11 @@ $(document).ready(() => {
             leafXmjSpread.refresh();
             leafXmjSpread.refresh();
         }
         }
     });
     });
+    $.divResizer({
+        select: '#right-spr',
+        callback: function () {
+            gclSpread.refresh();
+            leafXmjSpread.refresh();
+        }
+    });
 });
 });

+ 1 - 1
app/public/js/stage.js

@@ -1793,7 +1793,7 @@ $(document).ready(() => {
                                 updateData.unit = data.unit;
                                 updateData.unit = data.unit;
                                 updateData.unit_price = data.unit_price;
                                 updateData.unit_price = data.unit_price;
                             }
                             }
-                            updateData.doc_code = info.editingText;
+                            updateData.doc_code = info.editingText === null ? '' : info.editingText;
                             postData(window.location.pathname + '/detail/save', updateData, function (result) {
                             postData(window.location.pathname + '/detail/save', updateData, function (result) {
                                 stageIm.loadUpdateDetailData(result);
                                 stageIm.loadUpdateDetailData(result);
                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);
                                 SpreadJsObj.reLoadRowData(info.sheet, info.row);

+ 94 - 10
app/public/js/stage_gather.js

@@ -8,6 +8,32 @@
  * @version
  * @version
  */
  */
 
 
+function generateChapterHtml(data) {
+    const html = [];
+    if (data) {
+        for (const d of data) {
+            html.push('<tr>');
+            if (d.code) {
+                html.push('<td>', d.code, '</td>');
+                html.push('<td>', d.name, '</td>');
+            } else {
+                html.push('<td colspan="2">', d.name, '</td>');
+            }
+            html.push('<td class="text-right">', d.deal_bills_tp ? d.deal_bills_tp : '', '</td>');
+            html.push('<td class="text-right">', d.total_price ? d.total_price : '', '</td>');
+            html.push('<td class="text-right">', d.contract_tp ? d.contract_tp : '', '</td>');
+            html.push('<td class="text-right">', d.qc_tp ? d.qc_tp : '', '</td>');
+            html.push('<td class="text-right">', d.gather_tp ? d.gather_tp : '', '</td>');
+            html.push('<td class="text-right">', d.end_contract_tp ? d.end_contract_tp : '', '</td>');
+            html.push('<td class="text-right">', d.end_qc_tp ? d.end_qc_tp : '', '</td>');
+            html.push('<td class="text-right">', d.end_gather_tp ? d.end_gather_tp : '', '</td>');
+            html.push('<td class="text-right">', d.end_final_tp ? d.end_final_tp : '', '</td>');
+            html.push('</tr>');
+        }
+    }
+    $('#chapter-list').html(html.join(''));
+}
+
 $(document).ready(function () {
 $(document).ready(function () {
     let per = _.toNumber(getLocalCache('StageGatherOverPercent'));
     let per = _.toNumber(getLocalCache('StageGatherOverPercent'));
     if (per && !_.isNaN(per)) {
     if (per && !_.isNaN(per)) {
@@ -46,16 +72,6 @@ $(document).ready(function () {
         }
         }
     });
     });
 
 
-    // 上下窗口resizer
-    $.divResizer({
-        select: '#main-resize',
-        callback: function () {
-            gclSpread.refresh();
-            let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
-            $(".sp-wrap").height(bcontent-40);
-            leafXmjSpread.refresh();
-        }
-    });
     // 解析清单汇总数据
     // 解析清单汇总数据
     gclGatherModel.loadLedgerData(ledger, curLedgerData, preLedgerData);
     gclGatherModel.loadLedgerData(ledger, curLedgerData, preLedgerData);
     gclGatherModel.loadPosData(pos, curPosData, prePosData);
     gclGatherModel.loadPosData(pos, curPosData, prePosData);
@@ -111,4 +127,72 @@ $(document).ready(function () {
         setLocalCache('StageGatherOverPercent', this.value);
         setLocalCache('StageGatherOverPercent', this.value);
         checkOverRange();
         checkOverRange();
     });
     });
+    const chapterData = gclGatherModel.gatherChapterData(chapter, ['total_price', 'contract_tp', 'qc_tp', 'pre_contract_tp', 'pre_qc_tp']);
+    for (const c of chapterData) {
+        c.gather_tp = ZhCalc.add(c.contract_tp, c.qc_tp);
+        c.end_contract_tp = ZhCalc.add(c.contract_tp, c.pre_contract_tp);
+        c.end_qc_tp = ZhCalc.add(c.qc_tp, c.pre_qc_tp);
+        c.end_gather_tp = ZhCalc.add(c.end_contract_tp, c.end_qc_tp);
+        c.end_final_tp = ZhCalc.add(c.end_qc_tp, c.total_price);
+    }
+    generateChapterHtml(chapterData);
+
+    // 展开收起附件
+    $('a', '.right-nav').bind('click', function () {
+        const tab = $(this), tabPanel = $(tab.attr('content'));
+        const showTools = function (show) {
+            const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
+            if (show) {
+                right.show();
+                autoFlashHeight();
+                /**
+                 * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
+                 * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
+                 * 故需要通过最终的parent.width再计算一次left.width
+                 *
+                 * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
+                 * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
+                 *
+                 */
+                    //left.css('width', parent.width() - right.outerWidth());
+                    //left.css('width', parent.width() - right.outerWidth());
+                const percent = 100 - right.outerWidth() /parent.width() * 100;
+                left.css('width', percent + '%');
+            } else {
+                right.hide();
+                left.css('width', '100%');
+            }
+        };
+        if (!tab.hasClass('active')) {
+            $('a', '.side-menu').removeClass('active');
+            $('.tab-content .tab-select-show').removeClass('active');
+            tab.addClass('active');
+            tabPanel.addClass('active');
+            showTools(tab.hasClass('active'));
+        } else {
+            tab.removeClass('active');
+            tabPanel.removeClass('active');
+            showTools(tab.hasClass('active'));
+        }
+        gclSpread.refresh();
+        leafXmjSpread.refresh();
+    });
+
+    // 上下窗口resizer
+    $.divResizer({
+        select: '#main-resize',
+        callback: function () {
+            gclSpread.refresh();
+            let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
+            $(".sp-wrap").height(bcontent-40);
+            leafXmjSpread.refresh();
+        }
+    });
+    $.divResizer({
+        select: '#right-spr',
+        callback: function () {
+            gclSpread.refresh();
+            leafXmjSpread.refresh();
+        }
+    });
 });
 });

+ 45 - 16
app/view/ledger/gather.ejs

@@ -12,27 +12,56 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
-    <div class="content-wrap">
-        <div class="c-header p-0"></div>
-        <div class="c-body">
-            <div class="sjs-height-1" id="gcl-spread">
-            </div>
-            <div class="bcontent-wrap">
-                <div id="main-resize" class="resize-y" r-Type="height" div1="#gcl-spread" div2="#main-bottom" store-id="ledger-gather" store-version="1.0.0" min="100"></div>
-                <div class="bc-bar mb-1">
-                    <ul class="nav nav-tabs">
-                        <li class="nav-item">
-                            <a class="nav-link active" data-toggle="tab" href="#xmujie" role="tab">所属项目节</a>
-                        </li>
-                    </ul>
+    <div class="content-wrap row pr-46">
+        <div class="c-header p-0 col-12">
+        </div>
+        <div class="row w-100 sub-content">
+            <div class="c-body" id="left-view" style="width: 100%">
+                <div class="sjs-height-1" id="gcl-spread">
+                </div>
+                <div class="bcontent-wrap" id="main-bottom">
+                    <div id="main-resize" class="resize-y" r-Type="height" div1="#gcl-spread" div2="#main-bottom" store-id="ledger-gather" store-version="1.0.0" min="100"></div>
+                    <div class="bc-bar mb-1">
+                        <ul class="nav nav-tabs">
+                            <li class="nav-item">
+                                <a class="nav-link active" data-toggle="tab" href="#xmujie" role="tab">所属项目节</a>
+                            </li>
+                        </ul>
+                    </div>
+                    <div class="tab-content">
+                        <div class="tab-pane active" id="xmujie">
+                            <div class="sp-wrap" id="leaf-xmj-spread">
+                            </div>
+                        </div>
+                    </div>
                 </div>
                 </div>
+            </div>
+            <div class="c-body" id="right-view" style="display: none; width: 33%;">
+                <div class="resize-x" id="right-spr" r-Type="width" div1="#left-view" div2="#right-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>
                 <div class="tab-content">
                 <div class="tab-content">
-                    <div class="tab-pane active" id="xmujie">
-                        <div class="sp-wrap" id="leaf-xmj-spread">
+                    <div id="chapter" class="tab-pane active">
+                        <div class="side-bar-1"></div>
+                        <div class="sjs-sh-1">
+                            <table class="table table-bordered">
+                                <tr><th>章节</th><th>章节名称</th><th>签约金额</th><th>台帐金额</th><th>签约-台帐</th></tr>
+                                <tbody id="chapter-list"></tbody>
+                            </table>
                         </div>
                         </div>
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
         </div>
         </div>
+        <!--右侧菜单-->
+        <div class="side-menu">
+            <!--右侧菜单-->
+            <ul class="nav flex-column right-nav" id="side-menu">
+                <li class="nav-item">
+                    <a class="nav-link" content="#chapter" href="javascript: void(0);">章节合计</a>
+                </li>
+            </ul>
+        </div>
     </div>
     </div>
-</div>
+</div>
+<script>
+    chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
+</script>

+ 51 - 25
app/view/stage/gather.ejs

@@ -43,40 +43,65 @@
             </div>
             </div>
         </div>
         </div>
     </div>
     </div>
-    <div class="content-wrap">
-        <div class="c-header p-0"></div>
-        <div class="c-body">
-            <div class="sjs-height-1" id="gcl-spread">
-            </div>
-            <div class="bcontent-wrap" id="main-bottom">
-                <div id="main-resize" class="resize-y" r-Type="height" div1="#gcl-spread" div2="#main-bottom" store-id="stage-gather" store-version="1.0.0" min="100"></div>
-                <div class="bc-bar mb-1">
-                    <ul class="nav nav-tabs">
-                        <li class="nav-item">
-                            <a class="nav-link active" data-toggle="tab" href="#xmujie" role="tab">所属项目节</a>
-                        </li>
-                        <!--<li class="nav-item">-->
-                            <!--<a class="nav-link " data-toggle="tab" href="#biangeng" role="tab">相关变更令</a>-->
-                        <!--</li>-->
-                    </ul>
+    <div class="content-wrap row pr-46">
+        <div class="c-header p-0 col-12"></div>
+        <div class="row w-100 sub-content">
+            <div class="c-body" id="left-view" style="width: 100%">
+                <div class="sjs-height-1" id="gcl-spread">
                 </div>
                 </div>
-                <div class="tab-content">
-                    <div class="tab-pane active" id="xmujie">
-                        <div class="sp-wrap" id="leaf-xmj-spread">
+                <div class="bcontent-wrap" id="main-bottom">
+                    <div id="main-resize" class="resize-y" r-Type="height" div1="#gcl-spread" div2="#main-bottom" store-id="stage-gather" store-version="1.0.0" min="100"></div>
+                    <div class="bc-bar mb-1">
+                        <ul class="nav nav-tabs">
+                            <li class="nav-item">
+                                <a class="nav-link active" data-toggle="tab" href="#xmujie" role="tab">所属项目节</a>
+                            </li>
+                            <!--<li class="nav-item">-->
+                            <!--<a class="nav-link " data-toggle="tab" href="#biangeng" role="tab">相关变更令</a>-->
+                            <!--</li>-->
+                        </ul>
+                    </div>
+                    <div class="tab-content">
+                        <div class="tab-pane active" id="xmujie">
+                            <div class="sp-wrap" id="leaf-xmj-spread">
+                            </div>
+                        </div>
+                        <div class="tab-pane" id="biangeng">
+                            <div class="sp-wrap">
+                                <table class="table table-sm table-bordered">
+                                    <tr><th>变更令</th><th>名称</th><th>批复文号</th><th>变更图号</th><th>数量</th></tr>
+                                    <tr><td>BGL01</td><td>XX变更令</td><td></td><td></td><td>100</td></tr>
+                                    <tr><td>BGL02</td><td>YY变更令</td><td></td><td></td><td>80</td></tr>
+                                </table>
+                            </div>
                         </div>
                         </div>
                     </div>
                     </div>
-                    <div class="tab-pane" id="biangeng">
-                        <div class="sp-wrap">
-                            <table class="table table-sm table-bordered">
-                                <tr><th>变更令</th><th>名称</th><th>批复文号</th><th>变更图号</th><th>数量</th></tr>
-                                <tr><td>BGL01</td><td>XX变更令</td><td></td><td></td><td>100</td></tr>
-                                <tr><td>BGL02</td><td>YY变更令</td><td></td><td></td><td>80</td></tr>
+                </div>
+            </div>
+            <div class="c-body" id="right-view" style="display: none; width: 33%;">
+                <div class="resize-x" id="right-spr" r-Type="width" div1="#left-view" div2="#right-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>
+                <div class="tab-content">
+                    <div id="chapter" class="tab-pane active">
+                        <div class="side-bar-1"></div>
+                        <div class="sjs-sh-1" style="overflow: auto">
+                            <table class="table table-bordered" style="width: 1048px">
+                                <tr class="text-center"><th>章节</th><th>章节名称</th><th>签约清单</th><th>台帐金额</th><th>本期合同计量</th><th>本期数量变更</th><th>本期完成计量</th><th>截止本期合同计量</th><th>截止本期数量变更</th><th>截止本期完成计量</th><th>台账+变更令</th></tr>
+                                <tbody id="chapter-list"></tbody>
                             </table>
                             </table>
                         </div>
                         </div>
                     </div>
                     </div>
                 </div>
                 </div>
             </div>
             </div>
         </div>
         </div>
+        <!--右侧菜单-->
+        <div class="side-menu">
+            <!--右侧菜单-->
+            <ul class="nav flex-column right-nav" id="side-menu">
+                <li class="nav-item">
+                    <a class="nav-link" content="#chapter" href="javascript: void(0);">章节合计</a>
+                </li>
+            </ul>
+        </div>
     </div>
     </div>
 </div>
 </div>
 <script>
 <script>
@@ -90,4 +115,5 @@
     const curPosData = JSON.parse('<%- JSON.stringify(curPosData) %>');
     const curPosData = JSON.parse('<%- JSON.stringify(curPosData) %>');
     const prePosData = JSON.parse('<%- JSON.stringify(prePosData) %>');
     const prePosData = JSON.parse('<%- JSON.stringify(prePosData) %>');
     const dealBills = JSON.parse('<%- JSON.stringify(dealBills) %>');
     const dealBills = JSON.parse('<%- JSON.stringify(dealBills) %>');
+    chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
 </script>
 </script>