laiguoran vor 3 Jahren
Ursprung
Commit
4f64a48a26
2 geänderte Dateien mit 15 neuen und 8 gelöschten Zeilen
  1. 10 6
      app/public/js/change_revise.js
  2. 5 2
      app/service/change_ledger.js

+ 10 - 6
app/public/js/change_revise.js

@@ -185,16 +185,21 @@ $(document).ready(() => {
             const posData = pos.getLedgerPos(node.id) || [];
             if (posData.length > 0) {
                 let sgfh_qty = 0;
-                const sgfh_qty_arr = [];
+                let sjcl_qty = 0;
+                let qtcl_qty = 0;
                 for (const np of posData) {
                     sgfh_qty = ZhCalc.add(sgfh_qty, np.sgfh_qty);
-                    sgfh_qty_arr.push(np.sgfh_qty);
+                    sjcl_qty = ZhCalc.add(sjcl_qty, np.sjcl_qty);
+                    qtcl_qty = ZhCalc.add(qtcl_qty, np.qtcl_qty);
                 }
-                // 只针对设计量值判断
-                if (!_.isEqual(node.sgfh_qty, sgfh_qty)) {
+                if (!_.isEqual(node.sgfh_qty, sgfh_qty) || !_.isEqual(node.sjcl_qty, sjcl_qty) || !_.isEqual(node.qtcl_qty, qtcl_qty)) {
                     node.sgfh_qty = sgfh_qty;
-                    node.sgfh_tp = ZhCalc.mul(sgfh_qty, node.unit_price, decimal.tp) || 0;
+                    node.sjcl_qty = sjcl_qty;
+                    node.qtcl_qty = qtcl_qty;
                     node.quantity = ZhCalc.sum([node.sgfh_qty, node.sjcl_qty, node.qtcl_qty]);
+                    node.sgfh_tp = ZhCalc.mul(sgfh_qty, node.unit_price, decimal.tp) || 0;
+                    node.sjcl_tp = ZhCalc.mul(sjcl_qty, node.unit_price, decimal.tp) || 0;
+                    node.qtcl_tp = ZhCalc.mul(qtcl_qty, node.unit_price, decimal.tp) || 0;
                     node.total_price = ZhCalc.mul(node.quantity, node.unit_price, decimal.tp) || 0;
                 }
             }
@@ -337,7 +342,6 @@ $(document).ready(() => {
             setObjEnable($('a[name=base-opr][type=up-level]'), valid && first && sameParent && tree.getParent(first) && !nodeUsed
                 && first.level > 2 && ((!posRange || posRange.length === 0) || tree.isLastSibling(last)) && upPower && first.ccid);
             const preNodePosRange = preNode ? pos.getLedgerPos(preNode.id) : [];
-            console.log(preNode);
             setObjEnable($('a[name=base-opr][type=down-level]'), valid && first && sameParent
                 && first.level > 1 && preNode && (preNode.children.length > 0 || (preNode.children.length === 0 && preNode.ccid && (!preNodePosRange || preNodePosRange.length === 0))) && !preNode.used && first.ccid);
             setObjEnable($('#cut'), valid);

+ 5 - 2
app/service/change_ledger.js

@@ -1480,7 +1480,6 @@ module.exports = app => {
                             if (children.length === 0 && !parent.ccid) {
                                 throw '原台账节点为子项时不能添加它的子项';
                             }
-                            // console.log(parent);
                             isNew = true;
                             const newData = this._filterStdData(stdNode);
                             newData.is_leaf = (i === len - 1);
@@ -1581,7 +1580,11 @@ module.exports = app => {
             };
 
             const pid = parentData ? parentData.ledger_id : rootId;
-            const children = await this.getChildrenByParentId(tenderId, pid);
+            let children = await this.getChildrenByParentId(this.tableName, tenderId, pid);
+            if (!this.newBills) {
+                const ledgerChildren = await this.getChildrenByParentId(this.ctx.service.ledger.tableName, tenderId, pid);
+                children = this._.orderBy(this._.concat(children, ledgerChildren), [this.setting.order], ['asc']);
+            }
             const preData = findPreData(children, data);
             if (!preData || children.indexOf(preData) < children.length - 1) {
                 await this._updateChildrenOrder(this.tableName, tenderId, pid, preData ? preData.order + 1 : 1);