MaiXinRong пре 5 година
родитељ
комит
b7e12ba3d7
3 измењених фајлова са 22 додато и 4 уклоњено
  1. 2 2
      app/public/js/div_resizer.js
  2. 1 1
      app/public/js/stage.js
  3. 19 1
      app/service/stage_bills.js

+ 2 - 2
app/public/js/div_resizer.js

@@ -75,9 +75,9 @@
                         const min = obj.attr('min') ? obj.attr('min') : 10;
                         const max = 100 - min;
 
-                        const percent1 = Math.min(Math.max((orgSize1 + moveSize) / (orgSize1 + orgSize2) * 100, 10), 90);
+                        const percent1 = Math.min(Math.max((orgSize1 + moveSize) / (orgSize1 + orgSize2) * 100, min), max);
                         $(obj.attr('div1')).css(rType, percent1 + '%');
-                        const percent2 = Math.min(Math.max((orgSize2 - moveSize) / (orgSize1 + orgSize2) * 100, 10), 90);
+                        const percent2 = Math.min(Math.max((orgSize2 - moveSize) / (orgSize1 + orgSize2) * 100, min), max);
                         $(obj.attr('div2')).css(rType, percent2 + '%');
                     } else {
                         const min = obj.attr('min') ? obj.attr('min') : parseInt(((orgSize1 + orgSize2) / 10).toFixed(0));

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

@@ -1858,7 +1858,7 @@ $(document).ready(() => {
                                     const updateData = {lid: data.lid};
                                     if (data.uuid) {
                                         updateData.uuid = data.uuid;
-                                        updateData.doc_code = null;
+                                        updateData.doc_code = '';
                                         datas.push(updateData);
                                     }
                                 }

+ 19 - 1
app/service/stage_bills.js

@@ -178,6 +178,22 @@ module.exports = app => {
             return await this.db.queryOne(sql, sqlParam);
         }
 
+        _calcStageBillsData(data, orgData, ledgerData) {
+            const info = this.ctx.tender.info;
+            const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
+            if (data.contract_qty !== undefined) {
+                data.contract_qty = this.round(data.contract_qty, precision.value);
+                data.contract_tp = this.ctx.helper.mul(data.contract_qty, ledgerData.unit_price, info.decimal.tp);
+            }
+            if (data.qc_qty !== undefined) {
+                data.qc_qty = this.round(data.qc_qty, precision.value);
+                data.qc_tp = this.ctx.helper.mul(data.qc_qty, ledgerData.unit_price, info.decimal.tp);
+            }
+            if (ledgerData.is_tp && data.contract_tp !== undefined) {
+                data.contract_tp = this.ctx.helper.round(data.contract_tp, info.decimal.tp);
+            }
+        }
+
         async _insertStageBillsData(transaction, insertData, orgData, ledgerData) {
             const info = this.ctx.tender.info;
             const d = {
@@ -195,8 +211,8 @@ module.exports = app => {
                 d.qc_tp = orgData.qc_tp;
                 d.postil = orgData.postil;
             }
-
             const precision = this.ctx.helper.findPrecision(this.ctx.tender.info.precision, ledgerData.unit);
+
             if (insertData.contract_qty !== undefined) {
                 d.contract_qty = this.round(insertData.contract_qty, precision.value);
                 d.contract_tp = this.ctx.helper.mul(d.contract_qty, ledgerData.unit_price, info.decimal.tp);
@@ -231,6 +247,7 @@ module.exports = app => {
                         await this._insertStageBillsData(transaction, d, stageBills, ledgerBills);
                     } else {
                         d.id = stageBills.id;
+                        this._calcStageBillsData(d, stageBills, ledgerBills);
                         await transaction.update(this.tableName, d);
                     }
                 }
@@ -257,6 +274,7 @@ module.exports = app => {
                     (data.qc_qty === undefined || stageBills.qc_qty !== data.qc_qty)) {
                     if (stageBills.times === this.ctx.stage.curTimes && stageBills.order === this.ctx.stage.curOrder) {
                         data.id = stageBills.id;
+                        this._calcStageBillsData(data, stageBills, ledgerBills);
                         await transaction.update(this.tableName, data);
                     } else {
                         await this._insertStageBillsData(transaction, data, stageBills, ledgerBills);