Pārlūkot izejas kodu

部位台账,查找定位

MaiXinRong 5 gadi atpakaļ
vecāks
revīzija
78405052bb
4 mainītis faili ar 202 papildinājumiem un 17 dzēšanām
  1. 83 4
      app/public/js/ledger_search.js
  2. 86 0
      app/public/js/stage_bwtz.js
  3. 32 13
      app/view/stage/bwtz.ejs
  4. 1 0
      config/web.js

+ 83 - 4
app/public/js/ledger_search.js

@@ -1,7 +1,7 @@
 'use strict';
 
 /**
- * 台账搜索相关(多个页面均使用:台账分解、台账审批、台账修订)
+ * 台账搜索相关(多个页面均使用:台账分解、台账审批、台账修订、部位台账、期-部位台账
  *
  * 搜索基于spreadjs,请放在gc.spread.sheets.all.10.0.1.min.js/spreadjs_zh.js之后
  *
@@ -105,7 +105,7 @@
             searchObj.locateNext();
         });
         return searchObj;
-    }
+    };
     $.billsSearch = function (setting) {
         if (!setting.selector || !setting.searchSpread || !setting.resultSpreadSetting) return;
         if (!setting.searchRangeStr) setting.searchRangeStr = '项目节编号/清单编号/名称';
@@ -114,6 +114,10 @@
         obj.html(
             '                        <div class="sjs-bar">\n' +
             '                            <div class="input-group input-group-sm pb-1">\n' +
+            '                                <div class="input-group-prepend">\n' +
+            (setting.searchOver ? '                                    <div class="input-group-text"><input type="radio" name="searchType" id="over"> 超计</div>\n' : '') +
+            (setting.searchEmpty ? '                                    <div class="input-group-text"><input type="radio" name="searchType" id="empty"> 漏计</div>\n' : '') +
+            '                                </div>' +
             '                                <input id="searchKeyword" type="text" class="form-control" placeholder="可查找 ' + setting.searchRangeStr + '" aria-label="Recipient\'s username" aria-describedby="button-addon2">\n' +
             '                                <div class="input-group-append">\n' +
             '                                    <button class="btn btn-outline-secondary" type="button"">搜索</button>\n' +
@@ -130,7 +134,7 @@
         const searchSheet = setting.searchSpread.getActiveSheet();
         let searchResult = [];
         const searchBills = function () {
-            const keyword = $('input', obj).val();
+            const keyword = $('#searchKeyword', obj).val();
             searchResult = [];
             const sortData = SpreadJsObj.getSortData(searchSheet);
             for (const node of sortData) {
@@ -144,11 +148,86 @@
             }
             SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
         };
+        const calculateCompletePercent = function (searchResult) {
+            if (!searchResult) return;
+            for (const sr of searchResult) {
+                const base = ZhCalc.add(sr.total_price, sr.end_qc_tp);
+                sr.complete_percent = base !== 0 ? ZhCalc.mul(ZhCalc.div(sr.end_gather_tp, base), 100, 2) : 0;
+            }
+        };
+        const searchOver = function () {
+            searchResult = [];
+            const sortData = SpreadJsObj.getSortData(searchSheet);
+            for (const node of sortData) {
+                if (node.children && node.children.length > 0) continue;
+                if (node.end_gather_qty) {
+                    if (!node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty))) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                } else if (node.end_gather_tp) {
+                    if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp))) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                }
+            }
+            calculateCompletePercent(searchResult);
+            SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
+        };
+        const searchEmpty = function () {
+            searchResult = [];
+            const sortData = SpreadJsObj.getSortData(searchSheet);
+            for (const node of sortData) {
+                if (node.children && node.children.length > 0) continue;
+                if (node.quantity) {
+                    if (!node.end_gather_qty || checkZero(node.end_gather_qty)) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                } else if (node.total_price) {
+                    if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                }
+            }
+            calculateCompletePercent(searchResult);
+            SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
+        };
+        const searchLess = function () {
+            searchResult = [];
+            const sortData = SpreadJsObj.getSortData(searchSheet);
+            for (const node of sortData) {
+                if (node.children && node.children.length > 0) continue;
+                if (node.quantity) {
+                    if (ZhCalc.sub(ZhCalc.add(node.quantity, node.end_qc_qty), node.end_gather_qty) > 0) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                } else if (node.total_price) {
+                    if (ZhCalc.sub(ZhCalc.add(node.total_price, node.end_qc_tp), node.end_gather_tp) > 0) {
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        searchResult.push(data);
+                    }
+                }
+            }
+            calculateCompletePercent(searchResult);
+            SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
+        }
 
         $('input', this.obj).bind('keydown', function (e) {
             if (e.keyCode == 13) searchBills();
         });
         $('button', this.obj).bind('click', () => {searchBills()});
+        $('#over', this.obj).bind('change', () => {searchOver()});
+        $('#empty', this.obj).bind('change', () => {searchLess()});
         resultSpread.getActiveSheet().bind(spreadNS.Events.CellDoubleClick, function (e, info) {
             const sheet = info.sheet;
             const data = sheet.zh_data;
@@ -163,5 +242,5 @@
             }
         });
         return {spread: resultSpread};
-    }
+    };
 })(jQuery);

+ 86 - 0
app/public/js/stage_bwtz.js

@@ -8,7 +8,10 @@
  * @version
  */
 
+
+
 $(document).ready(() => {
+    let xmjSearch;
     const preUrl = window.location.pathname.split('/').slice(0, 6).join('/');
     autoFlashHeight();
     const xmjSpread = SpreadJsObj.createNewSpread($('#xmj-spread')[0]);
@@ -85,6 +88,89 @@ $(document).ready(() => {
             unitSpread.refresh();
         }
     });
+    $.divResizer({
+        select: '#right-spr',
+        callback: function () {
+            xmjSpread.refresh();
+            unitSpread.refresh();
+            if (xmjSearch) {
+                xmjSearch.spread.refresh();
+            }
+        }
+    });
+    $('a', '.side-menu').bind('click', function (e) {
+        e.preventDefault();
+        const tab = $(this), tabPanel = $(tab.attr('content'));
+        const showSideTools = 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 {
+                left.width(parent.width());
+                right.hide();
+            }
+        };
+        // 展开工具栏、切换标签
+        if (!tab.hasClass('active')) {
+            const close = $('.active', '#side-menu').length === 0;
+            $('a', '#side-menu').removeClass('active');
+            tab.addClass('active');
+            $('.tab-content .tab-pane').removeClass('active');
+            tabPanel.addClass('active');
+            showSideTools(tab.hasClass('active'));
+            if (tab.attr('content') === '#search' && !xmjSearch) {
+                if (!xmjSearch) {
+                    xmjSearch = $.billsSearch({
+                        selector: '#search',
+                        searchSpread: xmjSpread,
+                        searchRangeStr: '项目节编号/名称',
+                        searchOver: true,
+                        searchEmpty: true,
+                        resultSpreadSetting: {
+                            cols: [
+                                {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true},
+                                {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@', readOnly: true},
+                                {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@', readOnly: true},
+                                {title: '金额', field: 'total_price', hAlign: 2, width: 80, readOnly: true},
+                                {title: '完成率(%)', field: 'complete_percent', hAlign: 2, width: 70},
+                            ],
+                            emptyRows: 0,
+                            headRows: 1,
+                            headRowHeight: [32],
+                            defaultRowHeight: 21,
+                            headerFont: '12px 微软雅黑',
+                            font: '12px 微软雅黑',
+                            selectedBackColor: '#fffacd',
+                        },
+                        afterLocated: function () {
+                            unitTreeObj.loadCurUnitData();
+                        }
+                    });
+                }
+                xmjSearch.spread.refresh();
+            }
+        } else { // 收起工具栏
+            tab.removeClass('active');
+            tabPanel.removeClass('active');
+            showSideTools(tab.hasClass('active'));
+        }
+        xmjSpread.refresh();
+        unitSpread.refresh();
+    });
     // 显示层次
     (function (select, sheet) {
         $(select).click(function () {

+ 32 - 13
app/view/stage/bwtz.ejs

@@ -42,23 +42,42 @@
             </div>
         </div>
     </div>
-    <div class="content-wrap">
+    <div class="content-wrap pr-46">
         <div class="c-header p-0"></div>
-        <div class="c-body">
-            <div class="sjs-height-1" id="xmj-spread">
-            </div>
-            <div class="bcontent-wrap" id="main-bottom">
-                <div id="main-resize" class="resize-y" r-Type="height" div1="#xmj-spread" div2="#main-bottom" store-id="stage-bwtz" 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="#jldyjlqd" role="tab">计量单元/计量清单</a>
-                        </li>
-                    </ul>
+        <div class="row w-100 sub-content">
+            <div class="c-body" id="left-view" style="width: 100%">
+                <div class="sjs-height-1" id="xmj-spread">
                 </div>
-                <div class="sp-wrap" id="unit-spread">
+                <div class="bcontent-wrap" id="main-bottom">
+                    <div id="main-resize" class="resize-y" r-Type="height" div1="#xmj-spread" div2="#main-bottom" store-id="stage-bwtz" 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="#jldyjlqd" role="tab">计量单元/计量清单</a>
+                            </li>
+                        </ul>
+                    </div>
+                    <div class="sp-wrap" id="unit-spread">
+                    </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 id="search" class="tab-pane">
+                    </div>
+                </div>
+            </div>
+        </div>
+        <!--右侧菜单-->
+        <div class="side-menu">
+            <!--右侧菜单-->
+            <ul class="nav flex-column right-nav">
+                <li class="nav-item">
+                    <a class="nav-link" href="javascript: void(0);" role="tab" content="#search">查找定位</a>
+                </li>
+            </ul>
         </div>
     </div>
 </div>

+ 1 - 0
config/web.js

@@ -331,6 +331,7 @@ const JsFiles = {
                     "/public/js/div_resizer.js",
                     "/public/js/spreadjs_rela/spreadjs_zh.js",
                     "/public/js/shares/sjs_setting.js",
+                    "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
                     "/public/js/shares/bills_pos_convert.js",