Explorar o código

修复变更部位台账一些bug

laiguoran %!s(int64=3) %!d(string=hai) anos
pai
achega
7427a90d44
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      app/service/change_ledger.js

+ 9 - 0
app/service/change_ledger.js

@@ -1472,6 +1472,15 @@ module.exports = app => {
                             name: stdNode.name,
                         }) || await this.ctx.service.ledger.getDataByCondition({tender_id: tenderId, ledger_pid: parent ? parent.ledger_id : rootId, code: stdNode.code, name: stdNode.name });
                         if (!node) {
+                            let children = await this.getChildrenByParentId(this.tableName, tenderId, parent.ledger_id);
+                            if (!this.newBills) {
+                                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 '原台账节点为子项时不能添加它的子项';
+                            }
+                            // console.log(parent);
                             isNew = true;
                             const newData = this._filterStdData(stdNode);
                             newData.is_leaf = (i === len - 1);