Browse Source

本期计量台账,保留小数位数相关

MaiXinRong 6 years ago
parent
commit
d3276a3039
1 changed files with 18 additions and 0 deletions
  1. 18 0
      app/controller/stage_controller.js

+ 18 - 0
app/controller/stage_controller.js

@@ -62,8 +62,26 @@ module.exports = app => {
                     return cols.indexOf(c.field) > -1;
                 });
             }
+            function setColFormat(cols, field, formatter) {
+                const filterCols = cols.filter(function (c) {
+                    return c.field.search(field) !== -1;
+                });
+                for (const col of filterCols) {
+                    col.formatter = formatter;
+                }
+            }
+            const qtyFormatter = this.ctx.helper.getNumberFormatter(this.ctx.tender.info.decimal.qty);
+            const tpFormatter = this.ctx.helper.getNumberFormatter(this.ctx.tender.info.decimal.tp);
+            const upFormatter = this.ctx.helper.getNumberFormatter(2);
             const ledger = JSON.parse(JSON.stringify(spreadConst.stage.ledger));
+            setColFormat(ledger.cols, 'quantity', qtyFormatter);
+            setColFormat(ledger.cols, 'qty', qtyFormatter);
+            setColFormat(ledger.cols, 'unit_price', upFormatter);
+            setColFormat(ledger.cols, 'total_price', tpFormatter);
+            setColFormat(ledger.cols, 'tp', tpFormatter);
             const pos = JSON.parse(JSON.stringify(spreadConst.stage.pos));
+            setColFormat(pos.cols, 'quantity', qtyFormatter);
+            setColFormat(pos.cols, 'qty', qtyFormatter);
             const tender = this.ctx.tender, stage = this.ctx.stage;
             if (this._stageReadOnly(stage)) {
                 ledger.readOnly = true;