Procházet zdrojové kódy

单价调整,选择部位,提供显示至、查找定位

MaiXinRong před 2 roky
rodič
revize
d932b84b8c
2 změnil soubory, kde provedl 88 přidání a 1 odebrání
  1. 57 1
      app/public/js/revise_price.js
  2. 31 0
      app/view/revise/price_modal.ejs

+ 57 - 1
app/public/js/revise_price.js

@@ -641,7 +641,7 @@ $(document).ready(() => {
     class ChooseRelaBw {
         constructor() {
             const self = this;
-            this.tree = createNewPathTree('base', {
+            this.tree = createNewPathTree('ledger', {
                 id: 'ledger_id',
                 pid: 'ledger_pid',
                 order: 'order',
@@ -664,6 +664,23 @@ $(document).ready(() => {
                 $('#choose-rela-bw').modal('hide');
             });
         }
+        get locate() {
+            return this._locate;
+        }
+        set locate(value) {
+            if (!this.searchResult || this.searchResult.length === 0) return;
+            this._locate = !value || value >= this.searchResult.length ? 0 : (value < 0 ? this.searchResult.length - 1 : value);
+            SpreadJsObj.locateTreeNode(this.sheet, this.searchResult[this._locate].ledger_id, true);
+        }
+        search(keyword) {
+            this.searchResult = [];
+            for (const node of this.tree.nodes) {
+                const code = node.code || '', name = node.name || '';
+                if (code.indexOf(keyword) >= 0 || name.indexOf(keyword) >= 0) this.searchResult.push(node);
+            }
+            $('#rela-bw-search-result').html(`结果:${this.searchResult.length}`);
+            this.locate = 0;
+        }
         initSpread() {
             if (this.spread) return;
 
@@ -768,6 +785,45 @@ $(document).ready(() => {
                 }
             });
             SpreadJsObj.loadSheetData(this.sheet, SpreadJsObj.DataType.Tree, this.tree);
+
+            (function (select, sheet) {
+                $(select).click(function () {
+                    if (!sheet.zh_tree) return;
+                    const tag = $(this).attr('tag');
+                    const tree = sheet.zh_tree;
+                    setTimeout(() => {
+                        showWaitingView();
+                        switch (tag) {
+                            case "1":
+                            case "2":
+                            case "3":
+                            case "4":
+                            case "5":
+                                tree.expandByLevel(parseInt(tag));
+                                SpreadJsObj.refreshTreeRowVisible(sheet);
+                                break;
+                            case "last":
+                                tree.expandByCustom(() => { return true; });
+                                SpreadJsObj.refreshTreeRowVisible(sheet);
+                                break;
+                            case "leafXmj":
+                                tree.expandToLeafXmj();
+                                SpreadJsObj.refreshTreeRowVisible(sheet);
+                                break;
+                        }
+                        closeWaitingView();
+                    }, 100);
+                });
+            })('a[name=showLevel]', this.sheet);
+            $('#rela-bw-search-keyword').change(function () {
+                self.search(this.value);
+            });
+            $('#rela-bw-search-pre').click(function () {
+                self.locate = self.locate - 1;
+            });
+            $('#rela-bw-search-next').click(function () {
+                self.locate = self.locate + 1;
+            });
         }
         reBind(obj, eventName, fun) {
             obj.unbind(eventName);

+ 31 - 0
app/view/revise/price_modal.ejs

@@ -5,6 +5,37 @@
                 <h5 class="modal-title">选择应用部位</h5>
             </div>
             <div class="modal-body">
+                <div class="mb-2">
+                    <div class="d-inline-block">
+                        <div class="dropdown">
+                            <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                                <i class="fa fa-list-ol"></i> 显示层级
+                            </button>
+                            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
+                                <a class="dropdown-item" name="showLevel" tag="1" href="javascript: void(0);">第一层</a>
+                                <a class="dropdown-item" name="showLevel" tag="2" href="javascript: void(0);">第二层</a>
+                                <a class="dropdown-item" name="showLevel" tag="3" href="javascript: void(0);">第三层</a>
+                                <a class="dropdown-item" name="showLevel" tag="4" href="javascript: void(0);">第四层</a>
+                                <a class="dropdown-item" name="showLevel" tag="5" href="javascript: void(0);">第五层</a>
+                                <a class="dropdown-item" name="showLevel" tag="last" href="javascript: void(0);">最底层</a>
+                                <a class="dropdown-item" name="showLevel" tag="leafXmj" href="javascript: void(0);">只显示项目节</a>
+                            </div>
+                        </div>
+                    </div>
+                    <div class="d-inline-block">
+                        <div class="input-group input-group-sm">
+
+                            <input type="text" class="form-control form-control-sm" placeholder="按项目节编号/名称查找" id="rela-bw-search-keyword">
+                            <div class="input-group-append">
+                                <span class="input-group-text" id="rela-bw-search-result">结果:0</span>
+                            </div>
+                            <div class="input-group-append" >
+                                <button class="btn btn-outline-secondary btn-sm" type="button" title="上一个" id="rela-bw-search-pre"><i class="fa fa-angle-double-left"></i></button>
+                                <button class="btn btn-outline-secondary btn-sm" type="button" title="下一个" id="rela-bw-search-next"><i class="fa fa-angle-double-right"></i></button>
+                            </div>
+                        </div>
+                    </div>
+                </div>
                 <div class="modal-height-500" id="rela-bw-spread">
                 </div>
                 <div class="popover bs-popover-right" role="tooltip" id="choose-confirm" style="display: none">