소스 검색

查找定位,部位明细,根据原型修改

MaiXinRong 5 년 전
부모
커밋
4b90127151
3개의 변경된 파일26개의 추가작업 그리고 8개의 파일을 삭제
  1. 20 4
      app/public/js/ledger.js
  2. 2 2
      app/public/js/stage.js
  3. 4 2
      app/view/ledger/explode.ejs

+ 20 - 4
app/public/js/ledger.js

@@ -731,12 +731,25 @@ $(document).ready(function() {
                         }
                     }
                 }
-                $('#pos-search-hint').html(' ' + resultArr.length + '个匹配').show();
+                $('#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();
@@ -767,7 +780,7 @@ $(document).ready(function() {
                 }
             }
         };
-        return {search, locateNext, locatePre};
+        return {search, searchAndLocate, locateNext, locatePre};
     })();
     // 台账模式加载部位明细数据
     if (checkTzMeasureType()) {
@@ -786,8 +799,11 @@ $(document).ready(function() {
             posOperationObj.loadCurPosData();
             SpreadJsObj.resetTopAndSelect(posSpread.getActiveSheet());
         });
-        $('#pos-keyword').bind('input propertychange', function () {
-            posSearch.search(this.value);
+        // $('#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();

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

@@ -1351,8 +1351,8 @@ $(document).ready(() => {
                 const curRow = sel ? sel.row : 0;
                 const pos = resultArr[0];
                 if (pos.index !== curRow) {
-                    sheet.setSelection(next.index, sel ? sel.col : 0, 1, 1);
-                    sheet.showRow(next.index, spreadNS.VerticalPosition.center);
+                    sheet.setSelection(pos.index, sel ? sel.col : 0, 1, 1);
+                    sheet.showRow(pos.index, spreadNS.VerticalPosition.center);
                 }
             }
         };

+ 4 - 2
app/view/ledger/explode.ejs

@@ -77,11 +77,13 @@
                                 <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" id="button-addon3">
+                                        <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 class="small" id="pos-search-hint" style="vertical-align: bottom; display: none"></div>
                                     </div>
                                 </div>
                             </li>