فهرست منبع

台账分解、计量台账,查找定位,回车搜索

MaiXinRong 6 سال پیش
والد
کامیت
a15f63528a
2فایلهای تغییر یافته به همراه75 افزوده شده و 66 حذف شده
  1. 19 15
      app/public/js/ledger.js
  2. 56 51
      app/public/js/stage.js

+ 19 - 15
app/public/js/ledger.js

@@ -1505,21 +1505,12 @@ $(document).ready(function() {
             this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
             this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
             SpreadJsObj.forbiddenSpreadContextMenu('#search-result', this.spread);
             SpreadJsObj.forbiddenSpreadContextMenu('#search-result', this.spread);
-            $('#searchLedger', this.obj).bind('click', function () {
-                const keyword = $('input', self.obj).val();
-                this.searchResult = [];
-                const sortData = SpreadJsObj.getSortData(ledgerSpread.getActiveSheet());
-                for (const node of sortData) {
-                    if ((node.code && node.code.indexOf(keyword) > -1) ||
-                        node.b_code && node.b_code.indexOf(keyword) > -1 ||
-                        node.name && node.name.indexOf(keyword) > -1) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        this.searchResult.push(data);
-                    }
+            $('input', this.obj).bind('keydown', function (e) {
+                if (e.keyCode == 13) {
+                    self.search();
                 }
                 }
-                SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
             });
             });
+            $('#searchLedger', this.obj).bind('click', () => {self.search()});
             this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
             this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
                 const sheet = info.sheet;
                 const sheet = info.sheet;
                 const data = sheet.zh_data;
                 const data = sheet.zh_data;
@@ -1531,6 +1522,21 @@ $(document).ready(function() {
                 SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), curBills.ledger_id, true);
                 SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), curBills.ledger_id, true);
             });
             });
         }
         }
+        search () {
+            const keyword = $('input', this.obj).val();
+            this.searchResult = [];
+            const sortData = SpreadJsObj.getSortData(ledgerSpread.getActiveSheet());
+            for (const node of sortData) {
+                if ((node.code && node.code.indexOf(keyword) > -1) ||
+                    node.b_code && node.b_code.indexOf(keyword) > -1 ||
+                    node.name && node.name.indexOf(keyword) > -1) {
+                    const data = JSON.parse(JSON.stringify(node));
+                    data.visible = true;
+                    this.searchResult.push(data);
+                }
+            }
+            SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'data', this.searchResult);
+        }
     }
     }
 
 
     $('#searchAccount').click(() => {
     $('#searchAccount').click(() => {
@@ -1743,8 +1749,6 @@ $(document).ready(function() {
     })('a[name=showLevel]', ledgerSpread.getActiveSheet());
     })('a[name=showLevel]', ledgerSpread.getActiveSheet());
 });
 });
 
 
-
-
 // 检查上报情况
 // 检查上报情况
 function checkAuditorFrom () {
 function checkAuditorFrom () {
     if ($('#auditors li').length === 0) {
     if ($('#auditors li').length === 0) {

+ 56 - 51
app/public/js/stage.js

@@ -1157,58 +1157,12 @@ $(document).ready(() => {
             };
             };
             this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
             this.spread = SpreadJsObj.createNewSpread($('#search-result', this.obj)[0]);
             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
-
-            $('#searchLedger', this.obj).bind('click', function () {
-                const keyword = $('#keyword', self.obj).val();
-                if (keyword !== '') {
-                    $('#over', obj)[0].checked = false;
-                    $('#empty', obj)[0].checked = false;
-                    this.searchResult = [];
-                    const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
-                    for (const node of sortData) {
-                        if ((node.code && node.code.indexOf(keyword) > -1) ||
-                            node.b_code && node.b_code.indexOf(keyword) > -1 ||
-                            node.name && node.name.indexOf(keyword) > -1) {
-                            this.searchResult.push(node);
-                        }
-                    }
-                    SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
-                }
-            });
-            $('#over', this.obj).bind('change', function () {
-                this.searchResult = [];
-                const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
-                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(node.quantity)) {
-                            this.searchResult.push(node);
-                        }
-                    } else if (node.end_gather_tp) {
-                        if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(node.total_price)) {
-                            this.searchResult.push(node);
-                        }
-                    }
-                }
-                SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
-            });
-            $('#empty', this.obj).bind('change', function () {
-                this.searchResult = [];
-                const sortData = SpreadJsObj.getSortData(self.mainSpread.getActiveSheet());
-                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)) {
-                            this.searchResult.push(node);
-                        }
-                    } else if (node.total_price) {
-                        if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
-                            this.searchResult.push(node);
-                        }
-                    }
-                }
-                SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
+            $('#keyword', this.obj).bind('keydown', function(e) {
+                if (e.keyCode == 13) self.searchText();
             });
             });
+            $('#searchLedger', this.obj).bind('click', () => {self.searchText()});
+            $('#over', this.obj).bind('change', () => {self.searchOver()});
+            $('#empty', this.obj).bind('change', () => {self.searchEmpty()});
             this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
             this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
                 const sheet = info.sheet;
                 const sheet = info.sheet;
                 const data = sheet.zh_data;
                 const data = sheet.zh_data;
@@ -1220,6 +1174,57 @@ $(document).ready(() => {
                 SpreadJsObj.locateTreeNode(self.mainSpread.getActiveSheet(), curBills.ledger_id);
                 SpreadJsObj.locateTreeNode(self.mainSpread.getActiveSheet(), curBills.ledger_id);
             });
             });
         }
         }
+        searchText() {
+            const keyword = $('#keyword', this.obj).val();
+            if (keyword !== '') {
+                $('#over', this.obj)[0].checked = false;
+                $('#empty', this.obj)[0].checked = false;
+                this.searchResult = [];
+                const sortData = SpreadJsObj.getSortData(this.mainSpread.getActiveSheet());
+                for (const node of sortData) {
+                    if ((node.code && node.code.indexOf(keyword) > -1) ||
+                        node.b_code && node.b_code.indexOf(keyword) > -1 ||
+                        node.name && node.name.indexOf(keyword) > -1) {
+                        this.searchResult.push(node);
+                    }
+                }
+                SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'data', this.searchResult);
+            }
+        }
+        searchOver() {
+            this.searchResult = [];
+            const sortData = SpreadJsObj.getSortData(this.mainSpread.getActiveSheet());
+            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(node.quantity)) {
+                        this.searchResult.push(node);
+                    }
+                } else if (node.end_gather_tp) {
+                    if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(node.total_price)) {
+                        this.searchResult.push(node);
+                    }
+                }
+            }
+            SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'data', this.searchResult);
+        }
+        searchEmpty() {
+            this.searchResult = [];
+            const sortData = SpreadJsObj.getSortData(this.mainSpread.getActiveSheet());
+            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)) {
+                        this.searchResult.push(node);
+                    }
+                } else if (node.total_price) {
+                    if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
+                        this.searchResult.push(node);
+                    }
+                }
+            }
+            SpreadJsObj.loadSheetData(this.spread.getActiveSheet(), 'data', this.searchResult);
+        }
     }
     }
     let searchLedger;
     let searchLedger;
     $.divResizer({
     $.divResizer({