Browse Source

修订页面:
1. 侧栏可展开收起,侧栏可调大小
2. 项目节,初次使用,加载标准数据
3. 工程量清单,初次使用,加载标准数据

MaiXinRong 5 years ago
parent
commit
2869a5a085
2 changed files with 162 additions and 20 deletions
  1. 148 0
      app/public/js/revise.js
  2. 14 20
      app/view/ledger/revise_info.ejs

+ 148 - 0
app/public/js/revise.js

@@ -25,6 +25,154 @@ $(document).ready(() => {
             posSpread.refresh();
         }
     });
+
+    let stdChapter, stdBills;
+    $.divResizer({
+        select: '#revise-right-spr',
+        callback: function () {
+            billsSpread.refresh();
+            if (posSpread) {
+                posSpread.refresh();
+            }
+            if (stdChapter) {
+                stdChapter.spread.refresh();
+            }
+            if (stdBills) {
+                stdBills.spread.refresh();
+            }
+        }
+    });
+    // 展开收起标准清单
+    $('a', '#side-menu').bind('click', function (e) {
+        e.preventDefault();
+        const tab = $(this), tabPanel = $(tab.attr('content'));
+        const showSideTools = function (show) {
+            const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
+            if (show) {
+                right.show();
+                autoFlashHeight();
+                /**
+                 * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
+                 * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
+                 * 故需要通过最终的parent.width再计算一次left.width
+                 *
+                 * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
+                 * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
+                 *
+                 */
+                    //left.css('width', parent.width() - right.outerWidth());
+                    //left.css('width', parent.width() - right.outerWidth());
+                const percent = 100 - right.outerWidth() /parent.width() * 100;
+                left.css('width', percent + '%');
+            } else {
+                left.width(parent.width());
+                right.hide();
+            }
+        };
+        // 展开工具栏、切换标签
+        if (!tab.hasClass('active')) {
+            const close = $('.active', '#side-menu').length === 0;
+            $('a', '#side-menu').removeClass('active');
+            tab.addClass('active');
+            $('.tab-content .tab-pane').removeClass('active');
+            tabPanel.addClass('active');
+            showSideTools(tab.hasClass('active'));
+            if (tab.attr('content') === '#std-chapter') {
+                if (!stdChapter) {
+                    stdChapter = new stdLib($('#std-chapter-spread')[0], 'chapter', {
+                        id: 'chapter_id',
+                        pid: 'pid',
+                        order: 'order',
+                        level: 'level',
+                        rootId: -1,
+                        keys: ['id', 'list_id', 'chapter_id'],
+                    }, {
+                        cols: [
+                            {title: '项目节编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                            {title: '名称', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
+                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+                        ],
+                        treeCol: 0,
+                        emptyRows: 0,
+                        headRows: 1,
+                        headRowHeight: [40],
+                        defaultRowHeight: 21,
+                    });
+                    stdChapter.loadLib(1);
+                }
+                stdChapter.spread.refresh();
+            } else if (tab.attr('content') === '#std-bills') {
+                if (!stdBills) {
+                    stdBills = new stdLib($('#std-bills-spread')[0], 'bills', {
+                        id: 'bill_id',
+                        pid: 'pid',
+                        order: 'order',
+                        level: 'level',
+                        rootId: -1,
+                        keys: ['id', 'list_id', 'bill_id']
+                    }, {
+                        cols: [
+                            {title: '清单编号', field: 'code', hAlign: 0, width: 120, formatter: '@', readOnly: true, cellType: 'tree'},
+                            {title: '名称', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
+                            {title: '单位', field: 'unit', hAlign: 1, width: 50, formatter: '@', readOnly: true}
+                        ],
+                        treeCol: 0,
+                        emptyRows: 0,
+                        headRows: 1,
+                        headRowHeight: [40],
+                        defaultRowHeight: 21,
+                    });
+                    stdBills.loadLib(1);
+                }
+                stdBills.spread.refresh();
+            }
+        }
+        billsSpread.refresh();
+        if (posSpread) {
+            posSpread.refresh();
+        }
+    });
+    class stdLib {
+        constructor(obj, stdType, treeSetting, spreadSetting) {
+            this.obj = obj;
+            this.url = '/std/' + stdType;
+            this.treeSetting = treeSetting;
+            treeSetting.preUrl = this.url;
+            this.spreadSetting = spreadSetting;
+            this.spread = SpreadJsObj.createNewSpread(this.obj);
+            SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
+            this.spread.getActiveSheet().bind(GC.Spread.Sheets.Events.CellDoubleClick, function (e, info) {
+                const stdSheet = info.sheet;
+                const mainSheet = ledgerSpread.getActiveSheet();
+                if (!stdSheet.zh_setting || !stdSheet.zh_tree || !mainSheet.zh_tree) { return; }
+
+                const stdTree = stdSheet.zh_tree;
+                const stdNode = stdTree.nodes[info.row];
+                const mainTree = mainSheet.zh_tree;
+                const sel = mainSheet.getSelections()[0];
+                const mainNode = mainTree.nodes[sel.row];
+                if (!stdNode) { return; }
+
+                mainTree.postData('/tender/' + getTenderId() + '/ledger/add-by-std', mainNode, {
+                    tender_id: mainNode.tender_id,
+                    stdType: stdType,
+                    stdLibId: stdNode.list_id,
+                    stdNode: stdTree.getNodeKey(stdNode)
+                }, function (result) {
+                    treeOperationObj.refreshTree(mainSheet, result);
+                    treeOperationObj.refreshOperationValid(mainSheet);
+                });
+            });
+            this.pathTree = createNewPathTree('base', this.treeSetting);
+        }
+        loadLib (listId) {
+            const self = this;
+            postData(this.url+'/get-data', {list_id: listId}, function (data) {
+                self.pathTree.loadDatas(data);
+                SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'tree', self.pathTree);
+            });
+        }
+    }
     // 修订详情 保存
     $('#save').click(function () {
         const content = $('textarea').val();

+ 14 - 20
app/view/ledger/revise_info.ejs

@@ -51,7 +51,7 @@
         <!--核心内容(两栏)-->
         <div class="row w-100 sub-content">
             <!--左栏-->
-            <div class="c-body col-8">
+            <div class="c-body" id="left-view" style="width: 100%">
                 <!--0号台帐模式-->
                 <div class="sjs-height-1" style="overflow: hidden" id="bills-spread">
                 </div>
@@ -80,9 +80,10 @@
                 </div>
             </div>
             <!--右栏-->
-            <div class="c-body col">
+            <div class="c-body" id="right-view" style="display: none; width: 33%;">
+                <div class="resize-x" id="revise-right-spr" r-Type="width" div1="#left-view" div2="#right-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>
                 <div class="tab-content">
-                    <div id="xdcontent" class="tab-pane active">
+                    <div id="xd-content" class="tab-pane">
                         <div class="sjs-bar-1">
                             <div class="d-flex"><a href="javascirpt: void(0);" class="btn btn-sm btn-outline-success mb-1 ml-auto" id="save">保存</a></div>
                         </div>
@@ -101,25 +102,18 @@
                             </div>
                         </div>
                     </div>
-                    <div id="xiangmujie" class="tab-pane">
+                    <div id="std-chapter" class="tab-pane">
                         <div class="sjs-bar-2">
                             <select class="form-control form-control-sm"><option>0号计量台帐部位参考(项目节)</option></select>
                         </div>
-                        <div class="sjs-sh-2">
-                            <table class="table table-bordered">
-                                <tr><th></th><th>项目节编号</th><th>名称</th><th>单位</th></tr>
-                            </table>
+                        <div id="std-chapter-spread" class="sjs-sh-2">
                         </div>
                     </div>
-                    <div id="qingdan" class="tab-pane">
+                    <div id="std-bills" class="tab-pane">
                         <div class="sjs-bar-3">
                             <select class="form-control form-control-sm"><option>0号计量台帐部位参考(项目节)</option></select>
                         </div>
-                        <div class="sjs-sh-3">
-                            <table class="table table-bordered">
-                                <tr><th></th><th>清单编号</th><th>名称</th><th>单位</th></tr>
-                            </table>
-                        </div>
+                        <div id="std-bills-spread" class="sjs-sh-3">
                     </div>
                 </div>
             </div>
@@ -127,15 +121,15 @@
         <!--右侧菜单-->
         <div class="side-menu">
             <!--右侧菜单-->
-            <ul class="nav flex-column right-nav">
+            <ul class="nav flex-column right-nav" id="side-menu">
                 <li class="nav-item">
-                    <a class="nav-link active" data-toggle="tab" href="#xdcontent" role="tab">修订详情</a>
+                    <a class="nav-link" content="#xd-content" href="javascript: void(0);">修订详情</a>
                 </li>
                 <li class="nav-item">
-                    <a class="nav-link" data-toggle="tab" href="#xiangmujie" role="tab">项目节</a>
+                    <a class="nav-link" content="#std-chapter" href="javascript: void(0);">项目节</a>
                 </li>
                 <li class="nav-item">
-                    <a class="nav-link" data-toggle="tab" href="#qingdan" role="tab">工程量清单</a>
+                    <a class="nav-link" content="#std-bills" href="javascript: void(0);">工程量清单</a>
                 </li>
             </ul>
         </div>
@@ -145,6 +139,6 @@
     const readOnly = <%- readOnly %>;
     const billsSpreadSetting = JSON.parse('<%- JSON.stringify(ledgerSpread) %>');
     const posSpreadSetting = JSON.parse('<%- JSON.stringify(posSpread) %>');
-    const bills = JSON.parse('<% JSON.stringify(reviseBills) %>');
-    const pos = JSON.parse('<% JSON.stringify(revisePos) %>');
+    const bills = JSON.parse('<%- JSON.stringify(reviseBills) %>');
+    const pos = JSON.parse('<%- JSON.stringify(revisePos) %>');
 </script>