Pārlūkot izejas kodu

1. 台账修订,计量单元计算问题
2. 期缓存数据,审批退回原报情况调整

MaiXinRong 5 gadi atpakaļ
vecāks
revīzija
ff0ab0cf55
2 mainītis faili ar 17 papildinājumiem un 11 dzēšanām
  1. 0 1
      app/public/js/shares/cs_tools.js
  2. 17 10
      app/service/revise_pos.js

+ 0 - 1
app/public/js/shares/cs_tools.js

@@ -105,7 +105,6 @@ const showSideTools = function (show) {
                 if (!curBills) { return }
 
                 SpreadJsObj.locateTreeNode(setting.relaSpread.getActiveSheet(), curBills.ledger_id, true);
-                console.log(curBills);
                 if (setting.afterLocated) {
                     setting.afterLocated();
                 }

+ 17 - 10
app/service/revise_pos.js

@@ -241,7 +241,7 @@ module.exports = app => {
                 await transaction.commit();
                 updateBills.ledger_id = bills.ledger_id;
                 return {
-                    ledger: { update: [updateBills] },
+                    ledger: { update: needUpdateBills ? [updateBills] : [] },
                     pos: data,
                 }
             } catch(err) {
@@ -278,7 +278,10 @@ module.exports = app => {
                 await transaction.update(this.ctx.service.reviseBills.tableName, updateBills);
                 await transaction.commit();
                 updateBills.ledger_id = bills.ledger_id;
-                return { ledger: { update: [updateBills] }, pos: data };
+                return {
+                    ledger: { update: [updateBills] },
+                    pos: data
+                };
             } catch(err) {
                 await transaction.rollback();
                 throw err;
@@ -302,6 +305,7 @@ module.exports = app => {
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, bills.unit);
             const updateBills = {id: bills.id};
             const billsPos = await this.getAllDataByCondition({where: {tid: tid, lid: bills.id} });
+            let needUpdateBills;
             for (const bp of billsPos) {
                 const d = data.find(function (x) {
                     return bp.id ? x.id === bp.id : false;
@@ -316,7 +320,7 @@ module.exports = app => {
             try {
                 for (const d of data) {
                     const op = d.id ? this._.find(orgPos, {id: d.id}) : null;
-                    if (d.sgfh_qty || d.sjcl_qty || d.qtcl_qty) {
+                    if (d.sgfh_qty !== undefined || d.sjcl_qty !== undefined || d.qtcl_qty !== undefined) {
                         if (d.sgfh_qty !== undefined) {
                             d.sgfh_qty = this.round(d.sgfh_qty, precision.value);
                         } else if (op) {
@@ -337,6 +341,7 @@ module.exports = app => {
                         updateBills.qtcl_qty = this.ctx.helper.add(updateBills.qtcl_qty, d.qtcl_qty);
                         d.quantity = this.ctx.helper.sum([d.sgfh_qty, d.qtcl_qty, d.sjcl_qty]);
                         updateBills.quantity = this.ctx.helper.add(updateBills.quantity, d.quantity);
+                        needUpdateBills = true;
                     }
                     if (d.id) {
                         await transaction.update(this.tableName, d);
@@ -345,19 +350,21 @@ module.exports = app => {
                     }
                 }
                 const info = this.ctx.tender.info;
-                updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
-                updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
-                updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
-                updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
-                await transaction.update(this.ctx.service.reviseBills.tableName, updateBills);
-                updateBills.ledger_id = bills.ledger_id;
+                if (needUpdateBills) {
+                    updateBills.sgfh_tp = this.ctx.helper.mul(updateBills.sgfh_qty, bills.unit_price, info.decimal.tp);
+                    updateBills.sjcl_tp = this.ctx.helper.mul(updateBills.sjcl_qty, bills.unit_price, info.decimal.tp);
+                    updateBills.qtcl_tp = this.ctx.helper.mul(updateBills.qtcl_qty, bills.unit_price, info.decimal.tp);
+                    updateBills.total_price = this.ctx.helper.mul(updateBills.quantity, bills.unit_price, info.decimal.tp);
+                    await transaction.update(this.ctx.service.reviseBills.tableName, updateBills);
+                    updateBills.ledger_id = bills.ledger_id;
+                }
                 await transaction.commit();
             } catch (err) {
                 await transaction.rollback();
                 throw err;
             }
             result.pos = data;
-            result.ledger.update = [updateBills];
+            result.ledger.update = needUpdateBills ? [updateBills] : [];
             return result;
         }
     }