Browse Source

1. 台账分解,审批中,审批通过,签约清单不可双击添加
2. 台账分解,查找定位初始化调整
3. 台账分解,收起的节点,查找时也应显示
4. 台账分解,定位收起的节点,应展开所有父项

MaiXinRong 6 years ago
parent
commit
ba39718cbb

+ 2 - 2
app/controller/ledger_controller.js

@@ -274,7 +274,7 @@ module.exports = app => {
                     throw '当前未打开标段';
                 }
                 const tenderData = await ctx.service.tender.getDataById(tenderId);
-                if (!tenderData || tenderData.user_id !== ctx.session.sessionUser.accountId || this._ledgerReadOnly(tenderData)) {
+                if (!tenderData || tenderData.user_id !== ctx.session.sessionUser.accountId || this._ledgerReadOnly()) {
                     throw '标段数据错误';
                 }
                 const data = JSON.parse(ctx.request.body.data);
@@ -388,7 +388,7 @@ module.exports = app => {
         async addFromDealBills(ctx) {
             try {
                 if (ctx.tender.ledgerReadOnly) {
-                    throw '数据错误';
+                    throw '标段数据错误';
                 }
                 const data = JSON.parse(ctx.request.body.data);
                 if ((isNaN(data.id) || data.id <= 0) || !data.type || !data.dealBills) {

+ 1 - 1
app/middleware/tender_check.js

@@ -46,7 +46,7 @@ module.exports = options => {
                 throw '您无权查看该项目';
             }
             tender.ledgerReadOnly = this.session.sessionUser.accountId !== tender.data.user_id ||
-                tender.ledger_status === auditConst.status.checking || tender.ledger_status === auditConst.status.checked;
+                tender.data.ledger_status === auditConst.status.checking || tender.data.ledger_status === auditConst.status.checked;
             this.tender = tender;
             yield next;
         } catch (err) {

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

@@ -1151,7 +1151,7 @@ $(document).ready(function() {
                             {title: '单价', field: 'unit_price', hAlign: 2, width: 50, readOnly: true},
                             {title: '数量', field: 'quantity', hAlign: 2, width: 50, readOnly: true},
                         ],
-                        emptyRows: 3,
+                        emptyRows: 0,
                         headRows: 1,
                         headRowHeight: [40],
                         defaultRowHeight: 21,
@@ -1220,7 +1220,8 @@ $(document).ready(function() {
             this.spreadSetting = spreadSetting;
             this.spread = SpreadJsObj.createNewSpread(this.obj);
             SpreadJsObj.initSheet(this.spread.getActiveSheet(), this.spreadSetting);
-            this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
+            if (!readOnly) {
+                this.spread.bind(spreadNS.Events.CellDoubleClick, function (e, info) {
                 const dealSheet = info.sheet;
                 const mainSheet = ledgerSpread.getActiveSheet();
 
@@ -1248,20 +1249,21 @@ $(document).ready(function() {
                     treeOperationObj.refreshOperationValid(mainSheet);
                 });
             });
+            }
             SpreadJsObj.forbiddenSpreadContextMenu(selector, this.spread);
             $('#upload-deal-bills').click(function () {
-                const file = $('#deal-bills-file')[0];
-                const formData = new FormData();
-                formData.append('file', file.files[0]);
-                postDataWithFile(self.url+'/upload-excel', formData, function (data) {
-                    self.data = data;
-                    //self.calculateData();
-                    SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
-                    $('#upload-deal').modal('hide');
-                }, function () {
-                    $('#upload-deal').modal('hide');
+                    const file = $('#deal-bills-file')[0];
+                    const formData = new FormData();
+                    formData.append('file', file.files[0]);
+                    postDataWithFile(self.url+'/upload-excel', formData, function (data) {
+                        self.data = data;
+                        //self.calculateData();
+                        SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', data);
+                        $('#upload-deal').modal('hide');
+                    }, function () {
+                        $('#upload-deal').modal('hide');
+                    });
                 });
-            });
         }
         loadData () {
             const self = this;
@@ -1461,7 +1463,9 @@ $(document).ready(function() {
                     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);
+                        const data = JSON.parse(JSON.stringify(node));
+                        data.visible = true;
+                        this.searchResult.push(data);
                     }
                 }
                 SpreadJsObj.loadSheetData(self.spread.getActiveSheet(), 'data', this.searchResult);
@@ -1474,7 +1478,7 @@ $(document).ready(function() {
                 const curBills = data[info.row];
                 if (!curBills) { return }
 
-                SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), curBills.ledger_id);
+                SpreadJsObj.locateTreeNode(ledgerSpread.getActiveSheet(), curBills.ledger_id, true);
             });
         }
     }

+ 35 - 0
app/public/js/path_tree.js

@@ -326,6 +326,24 @@ const createNewPathTree = function (type, setting) {
         getParent (node) {
             return this.getItems(node[this.setting.pid]);
         };
+        getAllParents (node) {
+            const parents = [];
+            if (node.full_path && node.full_path !== '') {
+                const parentIds = node.full_path.split('.');
+                for (const id of parentIds) {
+                    if (id !== node[this.setting.id]) {
+                        parents.push(this.getItems(id));
+                    }
+                }
+            } else {
+                let vP = this.getParent(node);
+                while (vP) {
+                    parents.push(vP);
+                    vP = this.getParent(vP);
+                }
+            }
+            return parents;
+        }
 
         /**
          * 查找node的前兄弟节点
@@ -511,6 +529,23 @@ const createNewPathTree = function (type, setting) {
                 return n.level < level;
             });
         }
+
+        /**
+         * 自动展开节点node
+         * @param node
+         * @returns {*}
+         */
+        autoExpandNode(node) {
+            const parents = this.getAllParents(node);
+            const reload = [];
+            for (const p of parents) {
+                if (!p.expanded) {
+                    reload.push(p);
+                    this.setExpanded(p, true);
+                }
+            }
+            return reload;
+        }
     }
 
     class MeasureTree extends BaseTree {

+ 8 - 1
app/public/js/spreadjs_rela/spreadjs_zh.js

@@ -582,11 +582,18 @@ const SpreadJsObj = {
      * @param {GC.Spread.Sheets.Worksheet} sheet - 需要定位的sheet
      * @param {Number} id - 定位节点的id
      */
-    locateTreeNode: function (sheet, id) {
+    locateTreeNode: function (sheet, id, autoExpand = false) {
         const tree = sheet.zh_tree;
         if (!tree) { return }
         const node = tree.getItems(id);
         if (!node) { return }
+        if (autoExpand && !node.visible) {
+            const parents = tree.autoExpandNode(node);
+            if (parents && parents.length > 0) {
+                SpreadJsObj.reLoadNodesData(sheet, parents);
+                SpreadJsObj.refreshTreeRowVisible(sheet);
+            }
+        }
         const index = tree.nodes.indexOf(node);
         const sels = sheet.getSelections();
         sheet.setSelection(index, sels[0].col, 1, 1);

+ 1 - 0
app/view/ledger/explode.ejs

@@ -151,6 +151,7 @@
     </div>
 </div>
 <script type="text/javascript">
+    const readOnly = <%- ctx.tender.ledgerReadOnly %>;
     const tender = JSON.parse('<%- JSON.stringify(tender) %>');
     const tenderInfo = JSON.parse('<%- JSON.stringify(tenderInfo) %>');
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');