Ver código fonte

调用变更令,计量上限

MaiXinRong 1 ano atrás
pai
commit
44c6911f79
3 arquivos alterados com 23 adições e 6 exclusões
  1. 21 5
      app/public/js/stage.js
  2. 1 1
      app/service/change.js
  3. 1 0
      app/view/stage/index.ejs

+ 21 - 5
app/public/js/stage.js

@@ -375,10 +375,10 @@ $(document).ready(() => {
                     if (col.field === 'uamount') {
                         if (data.bamount > 0) {
                             const usedAmount = ZhCalc.add(data.uamount, data.pre_amount);
-                            return usedAmount < 0 || usedAmount > data.bamount ? spreadColor.stage.over : defaultColor;
+                            return usedAmount < 0 || usedAmount > data.limitAmount ? spreadColor.stage.over : defaultColor;
                         } else if (data.bamount < 0) {
                             const usedAmount = ZhCalc.add(data.uamount, data.pre_amount);
-                            return usedAmount > 0 || usedAmount < data.bamount ? spreadColor.stage.over : defaultColor;
+                            return usedAmount > 0 || usedAmount < data.limitAmount ? spreadColor.stage.over : defaultColor;
                         } else {
                             return data.uamount ? spreadColor.stage.over : defaultColor;
                         }
@@ -489,13 +489,13 @@ $(document).ready(() => {
                     if (c.uamount) {
                         if (c.bamount > 0) {
                             const usedAmount = ZhCalc.add(c.uamount, c.pre_amount);
-                            if (usedAmount < 0 || usedAmount > c.bamount) {
+                            if (usedAmount < 0 || usedAmount > c.limitAmount) {
                                 toastr.error('变更令:' + c.code + ' 超计,请修改本期计量后,再提交');
                                 return;
                             }
                         } else if (c.bamount < 0) {
                             const usedAmount = ZhCalc.add(c.uamount, c.pre_amount);
-                            if (usedAmount > 0 || usedAmount < c.bamount) {
+                            if (usedAmount > 0 || usedAmount < c.limiAmount) {
                                 toastr.error('变更令:' + c.code + ' 超计,请修改本期计量后,再提交');
                                 return;
                             }
@@ -524,10 +524,26 @@ $(document).ready(() => {
                 });
             })
         }
+        findDecimal(unit) {
+            let value = 3;
+            if (unit !== '') {
+                value = precision.other.value;
+                const changeUnits = precision;
+                for (const d in changeUnits) {
+                    if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
+                        value = changeUnits[d].value;
+                        break;
+                    }
+                }
+            }
+            return value;
+        }
         _calculateAmount() {
             for (const c of this.changes) {
                 c.bamount = _.toNumber(c.b_amount);
-                c.vamount = ZhCalc.sub(ZhCalc.sub(c.bamount, c.used_amount), c.stage_used_amount);
+                const qtyDecimal = this.findDecimal(c.unit);
+                c.limitAmount = ZhCalc.mul(c.bamount, ZhCalc.div(c.delimit, 100, 2), qtyDecimal);
+                c.vamount = ZhCalc.sub(ZhCalc.sub(c.limitAmount, c.used_amount), c.stage_used_amount);
                 const uc = _.find(this.useChanges, {cid: c.cid, cbid: c.cbid, no_value: this.callData.noValue});
                 if (uc) {
                     c.org_uamount = uc.qty;

+ 1 - 1
app/service/change.js

@@ -1259,7 +1259,7 @@ module.exports = app => {
             const sql =
                 'SELECT c.cid, c.code, c.name, c.w_code, c.p_code, c.peg, c.org_name, c.org_code, c.new_name, c.new_code,' +
                 '    c.content, c.basis, c.memo, c.type, c.class, c.quality, c.company, c.charge,' +
-                '    cb.id As cbid, cb.code As b_code, cb.name As b_name, cb.unit As b_unit, cb.samount As b_amount, cb.detail As b_detail, cb.bwmx As b_bwmx, cb.gcl_id, cb.is_valuation, cb.delimit' +
+                '    cb.id As cbid, cb.code As b_code, cb.name As b_name, cb.unit As b_unit, cb.samount As b_amount, cb.detail As b_detail, cb.bwmx As b_bwmx, cb.gcl_id, cb.is_valuation, cb.delimit,' +
                 '    scb.used_amount' +
                 '  FROM ' + this.tableName + ' As c ' +
                 '  Left Join ' + this.ctx.service.changeAuditList.tableName + ' As cb On c.cid = cb.cid ' +

+ 1 - 0
app/view/stage/index.ejs

@@ -541,6 +541,7 @@
     const tender = JSON.parse(unescape('<%- escape(JSON.stringify(tender)) %>'));
     const tenderInfo = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.tender.info)) %>'));
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
+    const precision = JSON.parse('<%- JSON.stringify(ctx.tender.info.precision) %>');
     const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
     const stage = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.stage)) %>'));
     const imType = JSON.parse('<%- JSON.stringify(imType) %>');