Browse Source

计算调整

MaiXinRong 1 year ago
parent
commit
14b4153c65
1 changed files with 6 additions and 4 deletions
  1. 6 4
      app/lib/rm/material.js

+ 6 - 4
app/lib/rm/material.js

@@ -131,7 +131,7 @@ class ReportMemoryMaterial {
         return result;
         return result;
     }
     }
 
 
-    _completeMaterialGl(materialGl) {
+    _completeMaterialGl(materialGl, decimal) {
         const tTypeStr = [], mTypeStr = [];
         const tTypeStr = [], mTypeStr = [];
         for (const t of materialConst.t_type) {
         for (const t of materialConst.t_type) {
             tTypeStr[t.value] = t.text;
             tTypeStr[t.value] = t.text;
@@ -140,7 +140,7 @@ class ReportMemoryMaterial {
             mTypeStr[m.value] = m.text;
             mTypeStr[m.value] = m.text;
         }
         }
         for (const gl of materialGl) {
         for (const gl of materialGl) {
-            gl.tp = this.ctx.helper.mul(gl.quantity, gl.m_spread, 2);
+            gl.tp = this.ctx.helper.mul(gl.quantity, gl.m_spread, decimal.tp);
             gl.t_type_str = tTypeStr[gl.t_type];
             gl.t_type_str = tTypeStr[gl.t_type];
             gl.m_type_str = mTypeStr[gl.m_type];
             gl.m_type_str = mTypeStr[gl.m_type];
             gl.end_tp = this.ctx.helper.add(gl.tp, gl.pre_tp);
             gl.end_tp = this.ctx.helper.add(gl.tp, gl.pre_tp);
@@ -171,9 +171,10 @@ class ReportMemoryMaterial {
         });
         });
         if (materials.length === 0) return [];
         if (materials.length === 0) return [];
 
 
-        let result, material;
+        let result, material, decimal;
         if (materials[0].order === material_order) {
         if (materials[0].order === material_order) {
             material = materials[0];
             material = materials[0];
+            decimal = material.decimal ? JSON.parse(material.decimal) : { qty: 3, up: 3, tp: 2 };
             if (material.is_stage_self) {
             if (material.is_stage_self) {
                 const sql = 'SELECT msb.id, msb.tid, msb.mid, msb.ms_id, ms.sid, ms.`order` as s_order, mb.order, mb.t_type, mb.code, mb.name, mb.unit, mb.spec, mb.m_type,' +
                 const sql = 'SELECT msb.id, msb.tid, msb.mid, msb.ms_id, ms.sid, ms.`order` as s_order, mb.order, mb.t_type, mb.code, mb.name, mb.unit, mb.spec, mb.m_type,' +
                     '    msb.quantity, mb.expr,' +
                     '    msb.quantity, mb.expr,' +
@@ -195,6 +196,7 @@ class ReportMemoryMaterial {
             material = this.ctx.helper._.find(materials, {order: material_order});
             material = this.ctx.helper._.find(materials, {order: material_order});
             if (!material) return [];
             if (!material) return [];
 
 
+            decimal = material.decimal ? JSON.parse(material.decimal) : { tp: 2 };
             if (material.is_stage_self) {
             if (material.is_stage_self) {
                 const sql = 'SELECT msb.id, msb.tid, msb.mid, msb.ms_id, ms.sid, ms.`order` as s_order, mb.order, mb.t_type, mb.code, mb.name, mb.unit, mb.spec, mb.m_type,' +
                 const sql = 'SELECT msb.id, msb.tid, msb.mid, msb.ms_id, ms.sid, ms.`order` as s_order, mb.order, mb.t_type, mb.code, mb.name, mb.unit, mb.spec, mb.m_type,' +
                     '    msb.quantity, mbh.expr,' +
                     '    msb.quantity, mbh.expr,' +
@@ -221,7 +223,7 @@ class ReportMemoryMaterial {
                 result = await this.ctx.app.mysql.query(sql, [tender_id, material.id]);
                 result = await this.ctx.app.mysql.query(sql, [tender_id, material.id]);
             }
             }
         }
         }
-        this._completeMaterialGl(result);
+        this._completeMaterialGl(result, decimal);
 
 
         if (this._checkFieldsExist(fields, ['month_msg_tp', 'month'])) await this._loadMaterialMonth(material, result);
         if (this._checkFieldsExist(fields, ['month_msg_tp', 'month'])) await this._loadMaterialMonth(material, result);
         return result;
         return result;