Forráskód Böngészése

部位明细搜索,统一代码,并应用到台账审批、台账修订

MaiXinRong 5 éve
szülő
commit
5baa6233ea

+ 1 - 77
app/public/js/ledger.js

@@ -736,71 +736,7 @@ $(document).ready(function() {
 
     treeOperationObj.refreshOperationValid(ledgerSpread.getActiveSheet());
 
-    const posSearch = (function () {
-        let resultArr = [];
-        const search = function (keyword) {
-            if (keyword && keyword !== '') {
-                resultArr = [];
-                const sortData = posSpread.getActiveSheet().zh_data;
-                if (sortData) {
-                    for (let i = 0, iLength = sortData.length; i < iLength; i++) {
-                        const sd = sortData[i];
-                        if (sd.name && sd.name.indexOf(keyword) > -1) {
-                            resultArr.push({index: i, data: sd});
-                        }
-                    }
-                }
-                $('#pos-search-hint').html('结果:' + resultArr.length);
-            } else {
-                resultArr = [];
-                $('#pos-search-hint').hide();
-            }
-        };
-        const searchAndLocate = function (keyword) {
-            search(keyword);
-            if (resultArr.length > 0) {
-                const sheet = posSpread.getActiveSheet();
-                const sel = sheet.getSelections()[0];
-                const curRow = sel ? sel.row : 0;
-                const pos = resultArr[0];
-                if (pos.index !== curRow) {
-                    sheet.setSelection(pos.index, sel ? sel.col : 0, 1, 1);
-                    sheet.showRow(pos.index, spreadNS.VerticalPosition.center);
-                }
-            }
-        };
-        const locateNext = function () {
-            if (resultArr.length > 0) {
-                const sheet = posSpread.getActiveSheet();
-                const sel = sheet.getSelections()[0];
-                const curRow = sel ? sel.row : 0;
-                let next = _.find(resultArr, function (d) {
-                    return d.index > curRow;
-                });
-                if (!next) next = resultArr[0];
-                if (next.index !== curRow) {
-                    sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
-                    sheet.showRow(next.index, spreadNS.VerticalPosition.center);
-                }
-            }
-        };
-        const locatePre = function () {
-            if (resultArr.length > 0) {
-                const sheet = posSpread.getActiveSheet();
-                const sel = sheet.getSelections()[0];
-                const curRow = sel ? sel.row : 0;
-                let next = _.findLast(resultArr, function (d) {
-                    return d.index < curRow;
-                });
-                if (!next) next = resultArr[resultArr.length - 1];
-                if (next.index !== curRow) {
-                    sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
-                    sheet.showRow(next.index, spreadNS.VerticalPosition.center);
-                }
-            }
-        };
-        return {search, searchAndLocate, locateNext, locatePre};
-    })();
+    const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
     // 台账模式加载部位明细数据
     if (checkTzMeasureType()) {
         $.divResizer({
@@ -818,18 +754,6 @@ $(document).ready(function() {
             posOperationObj.loadCurPosData();
             SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
         });
-        // $('#pos-keyword').bind('input propertychange', function () {
-        //     posSearch.search(this.value);
-        // });
-        $('#pos-keyword').bind('keydown', function(e){
-            if (e.keyCode == 13) posSearch.searchAndLocate(this.value);
-        });
-        $('#search-pre-pos').click(function () {
-            posSearch.locatePre();
-        });
-        $('#search-next-pos').click(function () {
-            posSearch.locateNext();
-        });
     }
     // 绑定部位明细编辑事件
     const posOperationObj = {

+ 3 - 1
app/public/js/ledger_audit.js

@@ -47,6 +47,7 @@ $(document).ready(() => {
     });
     const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]);
 
+    const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
@@ -93,9 +94,10 @@ $(document).ready(() => {
         });
     }
 
-    ledgerSpread.bind(GC.Spread.Sheets.Events.SelectionChanged, function (e, info) {
+    ledgerSpread.bind(spreadNS.Events.SelectionChanged, function (e, info) {
         loadCurPosData();
         SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
+        posSearch.search($('#pos-keyword').val());
     });
     ledgerSpread.bind(spreadNS.Events.TopRowChanged, function (e, info) {
         SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);

+ 106 - 0
app/public/js/ledger_search.js

@@ -0,0 +1,106 @@
+'use strict';
+
+/**
+ * 台账搜索相关(多个页面均使用:台账分解、台账审批、台账修订)
+ *
+ * 搜索基于spreadjs,请放在gc.spread.sheets.all.10.0.1.min.js/spreadjs_zh.js之后
+ *
+ * @author Mai
+ * @date
+ * @version
+ */
+
+(function($){
+    $.posSearch = function (setting) {
+        if (!setting.selector || !setting.searchSpread) return;
+        const searchHtml =
+            '                                <div class="mt-1 ml-2">\n' +
+            '                                    <div class="input-group input-group-sm">\n' +
+            '                                        <input type="text" class="form-control" placeholder="输入名称查找" id="pos-keyword">\n' +
+            '                                        <div class="input-group-append">\n' +
+            '                                            <span class="input-group-text" id="pos-search-hint">结果:0</span>\n' +
+            '                                        </div>\n' +
+            '                                        <div class="input-group-append" >\n' +
+            '                                            <button class="btn btn-outline-secondary" type="button" title="上一个" id="search-pre-pos"><i class="fa fa-angle-double-left"></i></button>\n' +
+            '                                            <button class="btn btn-outline-secondary" type="button" title="下一个" id="search-next-pos"><i class="fa fa-angle-double-right"></i></button>\n' +
+            '                                        </div>\n' +
+            '                                    </div>\n' +
+            '                                </div>\n';
+        $(setting.selector).html(searchHtml);
+        const sheet = setting.searchSpread.getActiveSheet();
+        const searchObj = (function () {
+            let resultArr = [];
+            const search = function (keyword) {
+                if (keyword && keyword !== '') {
+                    resultArr = [];
+                    const sortData = sheet.zh_data;
+                    if (sortData) {
+                        for (let i = 0, iLength = sortData.length; i < iLength; i++) {
+                            const sd = sortData[i];
+                            if (sd.name && sd.name.indexOf(keyword) > -1) {
+                                resultArr.push({index: i, data: sd});
+                            }
+                        }
+                    }
+                } else {
+                    resultArr = [];
+                }
+                $('#pos-search-hint').html('结果:' + resultArr.length);
+            };
+            const searchAndLocate = function (keyword) {
+                search(keyword);
+                if (resultArr.length > 0) {
+                    const sel = sheet.getSelections()[0];
+                    const curRow = sel ? sel.row : 0;
+                    const pos = resultArr[0];
+                    if (pos.index !== curRow) {
+                        sheet.setSelection(pos.index, sel ? sel.col : 0, 1, 1);
+                        sheet.showRow(pos.index, spreadNS.VerticalPosition.center);
+                    }
+                }
+            };
+            const locateNext = function () {
+                if (resultArr.length > 0) {
+                    const sel = sheet.getSelections()[0];
+                    const curRow = sel ? sel.row : 0;
+                    let next = _.find(resultArr, function (d) {
+                        return d.index > curRow;
+                    });
+                    if (!next) next = resultArr[0];
+                    if (next.index !== curRow) {
+                        sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
+                        sheet.showRow(next.index, spreadNS.VerticalPosition.center);
+                    }
+                }
+            };
+            const locatePre = function () {
+                if (resultArr.length > 0) {
+                    const sel = sheet.getSelections()[0];
+                    const curRow = sel ? sel.row : 0;
+                    let next = _.findLast(resultArr, function (d) {
+                        return d.index < curRow;
+                    });
+                    if (!next) next = resultArr[resultArr.length - 1];
+                    if (next.index !== curRow) {
+                        sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
+                        sheet.showRow(next.index, spreadNS.VerticalPosition.center);
+                    }
+                }
+            };
+            return {search, searchAndLocate, locateNext, locatePre};
+        })();
+        // $('#pos-keyword').bind('input propertychange', function () {
+        //     posSearch.search(this.value);
+        // });
+        $('#pos-keyword').bind('keydown', function(e){
+            if (e.keyCode == 13) searchObj.searchAndLocate(this.value);
+        });
+        $('#search-pre-pos').click(function () {
+            searchObj.locatePre();
+        });
+        $('#search-next-pos').click(function () {
+            searchObj.locateNext();
+        });
+        return searchObj;
+    }
+})(jQuery);

+ 4 - 4
app/public/js/revise.js

@@ -23,7 +23,7 @@ $(document).ready(() => {
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
-        key: 'ledger.memu.1.0.0',
+        key: 'revise.info.memu.1.0.0',
         callback: function (info) {
             if (info.mini) {
                 $('.panel-title').addClass('fluid');
@@ -37,6 +37,7 @@ $(document).ready(() => {
             posSpread.refresh();
         }
     });
+    const posSearch = $.posSearch({selector: '#pos-search', searchSpread: posSpread});
 
     // 初始化 清单树结构
     const treeSetting = {
@@ -154,9 +155,8 @@ $(document).ready(() => {
             if (info.newSelections[0].row !== info.oldSelections[0].row) {
                 billsTreeSpreadObj.refreshOperationValid(info.sheet);
                 posSpreadObj.loadCurPosData();
-                SpreadJsObj.saveTopAndSelect(posSheet, ckBillsSpread);
-                SpreadJsObj.resetTopAndSelect(billsSheet);
-                //posSearch.search($('#pos-keyword').val());
+                SpreadJsObj.saveTopAndSelect(billsSheet, ckBillsSpread);
+                posSearch.search($('#pos-keyword').val());
             }
         },
         /**

+ 2 - 0
app/view/ledger/audit.ejs

@@ -53,6 +53,8 @@
                             <li class="nav-item">
                                 <a class="nav-link active" href="javascript:void(0)">部位明细</a>
                             </li>
+                            <li class="nav-item" id="pos-search">
+                            </li>
                         </ul>
                     </div>
                     <div class="sp-wrap" id="pos-spread">

+ 1 - 13
app/view/ledger/explode.ejs

@@ -74,19 +74,7 @@
                             <li class="nav-item">
                                 <a class="nav-link active" href="javascript:void(0)">部位明细</a>
                             </li>
-                            <li class="nav-item">
-                                <div class="mt-1 ml-2">
-                                    <div class="input-group input-group-sm">
-                                        <input type="text" class="form-control" placeholder="输入名称查找" id="pos-keyword">
-                                        <div class="input-group-append" >
-                                            <span class="input-group-text" id="pos-search-hint">结果:0</span>
-                                        </div>
-                                        <div class="input-group-append" >
-                                            <button class="btn btn-outline-secondary" type="button" title="上一个" id="search-pre-pos"><i class="fa fa-angle-double-left"></i></button>
-                                            <button class="btn btn-outline-secondary" type="button" title="下一个" id="search-next-pos"><i class="fa fa-angle-double-right"></i></button>
-                                        </div>
-                                    </div>
-                                </div>
+                            <li class="nav-item" id="pos-search">
                             </li>
                         </ul>
                     </div>

+ 3 - 11
app/view/revise/info.ejs

@@ -2,6 +2,7 @@
 <div class="panel-content">
     <div class="panel-title">
         <div class="title-main  d-flex">
+            <% include ../tender/tender_sub_mini_menu.ejs %>
             <!--工具-->
             <% if ((revise.status === audit.status.uncheck || revise.status === audit.status.checkNo) && revise.uid === ctx.session.sessionUser.accountId) { %>
             <div>
@@ -76,18 +77,9 @@
                     <div class="bc-bar mb-1">
                         <ul class="nav nav-tabs">
                             <li class="nav-item">
-                                <a class="nav-link active" href="#">部位明细</a>
+                                <a class="nav-link active" href="javascript:void(0)">部位明细</a>
                             </li>
-                            <li class="nav-item">
-                                <div class="mt-1 ml-2">
-                                    <div class="input-group input-group-sm">
-                                        <input type="text" class="form-control" placeholder="输入名称查找">
-                                        <div class="input-group-append" id="button-addon3">
-                                            <button class="btn btn-outline-secondary" type="button" title="上一个"><i class="fa fa-angle-double-left"></i></button>
-                                            <button class="btn btn-outline-secondary" type="button" title="下一个"><i class="fa fa-angle-double-right"></i></button>
-                                        </div>
-                                    </div>
-                                </div>
+                            <li class="nav-item" id="pos-search">
                             </li>
                         </ul>
                     </div>

+ 3 - 0
config/web.js

@@ -104,6 +104,7 @@ const JsFiles = {
                     "/public/js/sub_menu.js",
                     "/public/js/div_resizer.js",
                     "/public/js/spreadjs_rela/spreadjs_zh.js",
+                    "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
                     "/public/js/ledger_tree_col.js",
@@ -120,6 +121,7 @@ const JsFiles = {
                     "/public/js/sub_menu.js",
                     "/public/js/div_resizer.js",
                     "/public/js/spreadjs_rela/spreadjs_zh.js",
+                    "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
                     "/public/js/ledger_audit.js",
@@ -135,6 +137,7 @@ const JsFiles = {
                     "/public/js/sub_menu.js",
                     "/public/js/div_resizer.js",
                     "/public/js/spreadjs_rela/spreadjs_zh.js",
+                    "/public/js/ledger_search.js",
                     "/public/js/zh_calc.js",
                     "/public/js/path_tree.js",
                     "/public/js/revise.js",