Browse Source

standard bills search

MaiXinRong 8 years ago
parent
commit
8b08c194c5

+ 13 - 3
web/building_saas/main/html/main.html

@@ -197,9 +197,19 @@
                                       <div class="p-1 row">
                                           <select class="form-control form-control-sm col-6" id="stdBillsLibSelect">
                                           </select>
-                                          <div class="input-group col-6">
-                                              <div class="input-group-addon form-control-sm"><i class="fa fa-search" aria-hidden="true"></i></div>
-                                              <input type="text" class="form-control form-control-sm" placeholder="搜索清单">
+                                          <div class="input-group col-6" id="stdBillsSearch">
+                                              <input type="text" class="form-control form-control-sm" placeholder="搜索清单" value="1-1-2">
+                                              <span class="input-group-btn">
+                                                  <button class="btn btn-secondary btn-sm" type="button"><i class="fa fa-search" aria-hidden="true"></i></button>
+                                              </span>
+                                          </div>
+                                          <!--搜索结果窗体-->
+                                          <div class="side-search-box col-12 p-2" id="stdBillsSearchResult" style="display: none;">
+                                              <div class="d-flex justify-content-between">
+                                                  <span id = 'stdBillsSearchResultCount'>搜索结果:5</span>
+                                                  <a class="btn btn-secondary btn-sm" href="javascript:void(0);" id="nextStdBills">查找下一条</a>
+                                                  <a title="关闭搜索" class="btn btn-link btn-sm" href="javascript:void(0);" id="closeSearchStdBills"><i class="fa fa-remove" aria-hidden="true"></i></a>
+                                              </div>
                                           </div>
                                       </div>
                                   </div>

+ 38 - 1
web/building_saas/main/js/views/std_bills_lib.js

@@ -402,6 +402,43 @@ var LoadStdBills = (function () {
         }
     });
 
+    $('#stdBillsSearch>span>button').click(function () {
+        var keyword = $('#stdBillsSearch>input').val();
+        var result = stdBillsTree.items.filter(function (item) {
+            var codeIs = item.data.code ? item.data.code.indexOf(keyword) !== -1 : false;
+            var nameIs = item.data.name ? item.data.name.indexOf(keyword) !== -1 : false;
+            return codeIs || nameIs;
+        });
+        result.sort(function (x, y) {
+            return x.serialNo - y.serialNo;
+        });
+        if (result.length !== 0) {
+            var sel = stdBillsSpread.getActiveSheet().getSelections();
+            stdBillsTreeController.setTreeSelected(result[0]);
+            stdBillsSpread.getActiveSheet().setSelection(result[0].serialNo(), sel[0].col, 1, 1);
+
+            $('#nextStdBills').show();
+            $('#nextStdBills').click(function () {
+                var cur = stdBillsTree.selected, resultIndex = result.indexOf(cur), sel = stdBillsSpread.getActiveSheet().getSelections();
+                if (resultIndex === result.length - 1) {
+                    stdBillsTreeController.setTreeSelected(result[0]);
+                    stdBillsSpread.getActiveSheet().setSelection(result[0].serialNo(), sel[0].col, 1, 1);
+                } else {
+                    stdBillsTreeController.setTreeSelected(result[resultIndex + 1]);
+                    stdBillsSpread.getActiveSheet().setSelection(result[resultIndex + 1].serialNo(), sel[0].col, 1, 1);
+                }
+            });
+        } else {
+            $('#nextStdBills').hide();
+        }
+        $('#stdBillsSearchResultCount').text('搜索结果:' + result.length);
+        $('#closeSearchStdBills').click(function () {
+            $('#stdBillsSearchResult').hide();
+        });
+        $('#stdBillsSearchResult').show();
+    });
+
+
     return LoadData;
 })();
 
@@ -410,4 +447,4 @@ $('#stdBillsLibSelect').change(function () {
     if (this.children.length !== 0) {
         LoadStdBills(select.val());
     }
-});
+});

+ 7 - 4
web/building_saas/main/js/views/std_ration_lib.js

@@ -220,9 +220,9 @@ $('#rationSearch').click(function () {
         for (i = 0; i < result.length; i++) {
             html.push('<tr>');
             html.push('<td>', i+1, '</td>');
-            html.push('<td>', result[i].code, '</td>');
-            html.push('<td>', result[i].name,  '</td>');
-            html.push('<td>', result[i].unit, '</td>');
+            html.push('<td>', result[i].code ? result[i].code : '', '</td>');
+            html.push('<td>', result[i].name ? result[i].name : '',  '</td>');
+            html.push('<td>', result[i].unit ? result[i].unit : '', '</td>');
             html.push('<td>', result[i].basePrice ? result[i].basePrice : '', '</td>');
             html.push('</tr>');
         }
@@ -230,11 +230,14 @@ $('#rationSearch').click(function () {
         html.push('</table>');
         html.push('</div>');
         return html.join('');
-    }
+    };
     CommonAjax.postRationLib('/rationRepository/api/findRation', {'user_id': userID, 'rationLibId': rationLibID, 'keyword': keyword}, function (result) {
         var resultObj = $('#rationSearchResult');
         resultObj.empty();
         resultObj.append(getResultHtml(result));
+        $(resultObj, 'a').click(function () {
+            resultObj.hide();
+        })
         resultObj.show();
     });
 });