Browse Source

还原代码

MaiXinRong 2 years ago
parent
commit
ade17d7025
2 changed files with 8 additions and 10 deletions
  1. 1 1
      app/public/js/change_revise.js
  2. 7 9
      app/service/change_ledger.js

+ 1 - 1
app/public/js/change_revise.js

@@ -353,7 +353,7 @@ $(document).ready(() => {
                 && first.level > 2 && ((!posRange || posRange.length === 0) || tree.isLastSibling(last)) && upPower && first.formc);
             const preNodePosRange = preNode ? pos.getLedgerPos(preNode.id) : [];
             setObjEnable($('a[name=base-opr][type=down-level]'), valid && first && sameParent
-                && first.level > 1 && preNode && (!preNodePosRange || preNodePosRange.length === 0) && !preNode.used && first.formc);
+                && first.level > 1 && preNode && (preNode.children.length > 0 || (preNode.children.length === 0 && preNode.formc && (!preNodePosRange || preNodePosRange.length === 0))) && !preNode.used && first.formc);
             setObjEnable($('#cut'), valid);
             setObjEnable($('#paste'), valid);
         },

+ 7 - 9
app/service/change_ledger.js

@@ -1129,10 +1129,9 @@ module.exports = app => {
                     this.clearParentingData(updateData2);
                     await this.transaction.update(this.tableName, updateData2);
                     await this._deleteChangeAuditListData(mid, [pre]);
+                } else if (!pre.ccid && pre.is_leaf === 1) {
+                    throw '原台账节点为子项时不能降级成为它的子项';
                 }
-                // else if (!pre.ccid && pre.is_leaf === 1) {
-                //     throw '原台账节点为子项时不能降级成为它的子项';
-                // }
                 await this.transaction.commit();
                 this.transaction = null;
             } catch (err) {
@@ -1373,10 +1372,9 @@ module.exports = app => {
                             quantity: null, unit_price: null, total_price: null, deal_qty: null, deal_tp: null
                         },
                         { where: {tender_id: tenderId, ledger_id: selectData.ledger_id} });
+                } else if (!selectData.ccid && children.length === 0) {
+                    throw '原台账节点为子项时不能添加它的子项';
                 }
-                // else if (!selectData.ccid && children.length === 0) {
-                //     throw '原台账节点为子项时不能添加它的子项';
-                // }
                 await this.transaction.commit();
             } catch (err) {
                 this.transaction.rollback();
@@ -1494,9 +1492,9 @@ module.exports = app => {
                                 const ledgerChildren = await this.getChildrenByParentId(this.ctx.service.ledger.tableName, tenderId, parent.ledger_id);
                                 children = this._.orderBy(this._.concat(ledgerChildren, children), [this.setting.order], ['asc']);
                             }
-                            // if (children.length === 0 && !parent.ccid) {
-                            //     throw '原台账节点为子项时不能添加它的子项';
-                            // }
+                            if (children.length === 0 && !parent.ccid) {
+                                throw '原台账节点为子项时不能添加它的子项';
+                            }
                             isNew = true;
                             const newData = this._filterStdData(stdNode);
                             newData.is_leaf = (i === len - 1);