|
@@ -66,6 +66,17 @@
|
|
|
<li class="nav-item">
|
|
|
<a class="nav-link text-primary lock-btn-control" doing="false" fcsOnBills="true" canMove="false" id="downMove" href="javascript: void(0);"><i class="fa fa-arrow-down" aria-hidden="true"></i>下移</a>
|
|
|
</li>
|
|
|
+ <li class="nav-item">
|
|
|
+ <div class="search-container">
|
|
|
+ <input type="text" placeholder="输入后按回车查找..." id="searchInput" class="icon-input">
|
|
|
+ <i class="fa fa-search search-icon"></i>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ <li class="nav-item" id="searchResult" style="display: none;">
|
|
|
+ 搜索结果:<span id="searchCount">0</span>
|
|
|
+ <a class="btn btn-primary next-btn" doing="false" canMove="false" id="search-pre" href="javascript: void(0);">上一个</a>
|
|
|
+ <a class="btn btn-primary next-btn" doing="false" canMove="false" id="search-next" href="javascript: void(0);">下一个</a>
|
|
|
+ </li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
</nav>
|
|
@@ -465,6 +476,84 @@
|
|
|
dbController.delete(controller, btnDelete, totalJobs, totalItems);
|
|
|
$('#delAlert').modal('hide');
|
|
|
});
|
|
|
+
|
|
|
+ function isMatch(bill,searchInput){
|
|
|
+ searchInput = searchInput.toLowerCase().trim()
|
|
|
+ const billName = bill.data.name? bill.data.name.toLowerCase():'';
|
|
|
+ const code = bill.data.code? bill.data.code.toLowerCase():'';
|
|
|
+ return billName.includes(searchInput) || code.includes(searchInput);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ function locateBill(bill){
|
|
|
+ if(bill){
|
|
|
+ controller.setTreeSelected(bill);
|
|
|
+ controller.sheet.setSelection(bill.serialNo(), 1, 1, 1);
|
|
|
+ controller.sheet.showRow(bill.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $('#searchInput').on('keypress', function(e) {
|
|
|
+ // 检查是否按下的是 Enter 键(keyCode 13 或 which 13)
|
|
|
+ if (e.which === 13 || e.keyCode === 13) {
|
|
|
+ const searchValue = $(this).val().toLowerCase().trim();
|
|
|
+ if(searchValue){
|
|
|
+ const controller = dbController.controller;
|
|
|
+ let select = null;
|
|
|
+ let count =0
|
|
|
+ for(const bill of controller.tree.items){
|
|
|
+ if(isMatch(bill,searchValue)){
|
|
|
+ if(select===null) select=bill
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ locateBill(select);
|
|
|
+ $('#searchCount').text(count);
|
|
|
+ $('#searchResult').show();
|
|
|
+ }else{
|
|
|
+ $('#searchResult').hide();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ $('#search-next').click(function(){
|
|
|
+ const searchValue = $('#searchInput').val().toLowerCase().trim();
|
|
|
+ if(searchValue){
|
|
|
+ const controller = dbController.controller;
|
|
|
+ const selected = controller.tree.selected;
|
|
|
+ if(selected){
|
|
|
+ const index = controller.tree.items.indexOf(selected)+1;
|
|
|
+ if(index>=controller.tree.items.length) return ;
|
|
|
+ for(let i=index ;i<controller.tree.items.length;i++){
|
|
|
+ if(isMatch(controller.tree.items[i],searchValue)){
|
|
|
+ locateBill(controller.tree.items[i]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#search-pre').click(function(){
|
|
|
+ const searchValue = $('#searchInput').val().toLowerCase().trim();
|
|
|
+ if(searchValue){
|
|
|
+ const controller = dbController.controller;
|
|
|
+ const selected = controller.tree.selected;
|
|
|
+ if(selected){
|
|
|
+ const index = controller.tree.items.indexOf(selected)-1;
|
|
|
+ if(index<0) return ;
|
|
|
+ for(let i=index ;i>=0;i--){
|
|
|
+ if(isMatch(controller.tree.items[i],searchValue)){
|
|
|
+ locateBill(controller.tree.items[i]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
btnDelete.click(function(){
|
|
|
if(btnDelete.attr('doing') === 'false' && btnDelete.attr('fcsOnBills') === 'true'){
|
|
|
$('#delAlert').modal('show');
|