|
@@ -1081,7 +1081,6 @@ module.exports = app => {
|
|
|
if (!count) count = 1;
|
|
|
this.newBills = false;
|
|
|
const selects = await this.getDataByKidAndCount(mid, kid, count);
|
|
|
- // const newBills = this.newBills;
|
|
|
if (!selects) throw '降级节点数据错误';
|
|
|
const first = selects[0], last = selects[count - 1];
|
|
|
const pre = await this.getDataByParentAndOrder(mid, first[this.setting.pid], first[this.setting.order] - 1);
|
|
@@ -1112,11 +1111,15 @@ module.exports = app => {
|
|
|
await this._syncDownlevelChildren(s, pre);
|
|
|
}
|
|
|
// 选中节点--前兄弟节点 is_leaf应为false, 清空计算相关字段
|
|
|
- const updateData2 = { id: pre.id };
|
|
|
- updateData2[this.setting.isLeaf] = false;
|
|
|
- this.clearParentingData(updateData2);
|
|
|
- await this.transaction.update(this.tableName, updateData2);
|
|
|
- await this._deleteChangeAuditListData(mid, [pre]);
|
|
|
+ if (pre.ccid) {
|
|
|
+ const updateData2 = { id: pre.id };
|
|
|
+ updateData2[this.setting.isLeaf] = false;
|
|
|
+ this.clearParentingData(updateData2);
|
|
|
+ await this.transaction.update(this.tableName, updateData2);
|
|
|
+ await this._deleteChangeAuditListData(mid, [pre]);
|
|
|
+ } else if (!pre.ccid && pre.is_leaf === 1) {
|
|
|
+ throw '原台账节点为子项时不能降级成为它的子项';
|
|
|
+ }
|
|
|
await this.transaction.commit();
|
|
|
this.transaction = null;
|
|
|
} catch (err) {
|
|
@@ -1346,7 +1349,7 @@ module.exports = app => {
|
|
|
this.transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
const result = await this.transaction.insert(this.tableName, data);
|
|
|
- if (children.length === 0 && this.newBills) {
|
|
|
+ if (children.length === 0 && selectData.ccid) {
|
|
|
await this.transaction.update(this.tableName,
|
|
|
{
|
|
|
is_leaf: false,
|
|
@@ -1354,6 +1357,8 @@ 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 '原台账节点为子项时不能添加它的子项';
|
|
|
}
|
|
|
await this.transaction.commit();
|
|
|
} catch (err) {
|