فهرست منبع

Merge branch 'dev' of http://192.168.1.41:3000/maixinrong/Calculation into dev

TonyKang 4 سال پیش
والد
کامیت
8cc78d8975
4فایلهای تغییر یافته به همراه51 افزوده شده و 35 حذف شده
  1. 16 8
      app/controller/change_controller.js
  2. 21 13
      app/service/stage_pos.js
  3. 13 13
      app/view/change/info.ejs
  4. 1 1
      app/view/material/info.ejs

+ 16 - 8
app/controller/change_controller.js

@@ -393,9 +393,12 @@ module.exports = app => {
                     let stotalCost = 0;
                     const auditTotalCost = [];
                     for (const cl of changeList) {
-                        ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
-                        ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
-                        stotalCost += cl.samount !== '' && cl.unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
+                        // ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
+                        ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, renderData.tpUnit);
+                        // ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
+                        ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, renderData.tpUnit);
+                        // stotalCost += cl.samount !== '' && cl.unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), renderData.tpUnit)) : 0;
+                        stotalCost += cl.samount !== '' && cl.unit_price !== null ? ctx.helper.mul(cl.unit_price, cl.samount, renderData.tpUnit) : 0;
                         const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
                         auditTotalCost.push(audit_amount);
                     }
@@ -410,7 +413,8 @@ module.exports = app => {
                             au.totalCost = 0;
                             for (const [auindex, at] of auditTotalCost.entries()) {
                                 au.list_amount.push(at[index - 1]);
-                                au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
+                                // au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
+                                au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? ctx.helper.mul(changeList[auindex].unit_price, at[index - 1], renderData.tpUnit) : 0;
                             }
                         }
                     }
@@ -455,8 +459,10 @@ module.exports = app => {
                     const auditTotalCost = [];
                     const auditUnit = [];
                     for (const cl of changeList) {
-                        ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
-                        ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
+                        // ototalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), renderData.tpUnit));
+                        ototalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.oamount, renderData.tpUnit);
+                        // ctotalCost += cl.unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), renderData.tpUnit));
+                        ctotalCost += cl.unit_price === null ? 0 : ctx.helper.mul(cl.unit_price, cl.camount, renderData.tpUnit);
                         const audit_amount = cl.audit_amount !== null && cl.audit_amount !== '' ? cl.audit_amount.split(',') : '';
                         auditTotalCost.push(audit_amount);
                     }
@@ -478,12 +484,14 @@ module.exports = app => {
                                     //     au.totalCost += parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, changeList[auindex].camount), renderData.tpUnit));
                                     // }
                                     au.list_amount.push(changeList[auindex].spamount);
-                                    au.totalCost += changeList[auindex].unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, changeList[auindex].spamount), renderData.tpUnit));
+                                    // au.totalCost += changeList[auindex].unit_price === null ? 0 : parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, changeList[auindex].spamount), renderData.tpUnit));
+                                    au.totalCost += changeList[auindex].unit_price === null ? 0 : ctx.helper.mul(changeList[auindex].unit_price, changeList[auindex].spamount, renderData.tpUnit);
                                 }
                             } else {
                                 for (const [auindex, at] of auditTotalCost.entries()) {
                                     au.list_amount.push(at[index - 1]);
-                                    au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
+                                    // au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? parseFloat(ctx.helper.roundNum(ctx.helper.accMul(changeList[auindex].unit_price, at[index - 1]), renderData.tpUnit)) : 0;
+                                    au.totalCost += at[index - 1] !== undefined && changeList[auindex].unit_price !== null ? ctx.helper.mul(changeList[auindex].unit_price, at[index - 1], renderData.tpUnit) : 0;
                                 }
                             }
                         }

+ 21 - 13
app/service/stage_pos.js

@@ -88,7 +88,7 @@ module.exports = app => {
             return await this.db.query(sql, sqlParam);
         }
 
-        async _filterLastestData(stagePos) {
+        _filterLastestData(stagePos) {
             const stagePosIndex = {};
             for (const sp of stagePos) {
                 const key = 'sp-' + sp.pid;
@@ -545,20 +545,28 @@ module.exports = app => {
          * @returns {Promise<void>}
          */
         async getStagesData(tid, stage_id_list) {
-            let stage_id_listSql = '';
-            stage_id_list = stage_id_list.indexOf(',') !== -1 ? stage_id_list.split(',') : stage_id_list;
-            if (stage_id_list) {
-                if (stage_id_list instanceof Array) {
-                    stage_id_listSql = stage_id_list.length > 0 ? ' And sid in (' + this.ctx.helper.getInArrStrSqlFilter(stage_id_list) + ')' : '';
-                } else {
-                    stage_id_listSql = ' And sid in (' + this.db.escape(stage_id_list) + ')';
+            const sids = stage_id_list.split(',');
+            const result = [];
+            for (const sid of sids) {
+                const sql = 'SELECT id, tid, sid, pid, lid, contract_qty, qc_qty, postil, `times`, `order`, `contract_expr`' +
+                    '  FROM ' + this.tableName +
+                    '  WHERE tid = ? And sid = ? ';
+                const sqlParam = [tid, sid];
+                const stagePos = await this.db.query(sql, sqlParam);
+                const stagePosFilter = this._filterLastestData(stagePos);
+                for (const sp of stagePosFilter) {
+                    const rsp = result.find(function (x) { return x.pid === sp.pid});
+                    if (rsp) {
+                        rsp.contract_qty = this.ctx.helper.add(rsp.contract_qty, sp.contract_qty);
+                        rsp.qc_qty = this.ctx.helper.add(rsp.qc_qty, sp.qc_qty);
+                    } else {
+                        result.push({
+                            id: sp.id, tid: sp.tid, lid: sp.lid, pid: sp.pid,
+                            contract_qty: sp.contract_qty, qc_qty: sp.qc_qty,
+                        });
+                    }
                 }
             }
-            const sql = 'SELECT `id`, `tid`, `sid`, `pid`, `lid`, SUM(`contract_qty`) as `contract_qty`, SUM(`qc_qty`) as `qc_qty`' +
-                ' FROM ' + this.tableName + ' WHERE `tid` = ? ' +
-                stage_id_listSql + 'GROUP BY `pid`';
-            const sqlParam = [tid];
-            const result = await this.db.query(sql, sqlParam);
             return result;
         }
 

+ 13 - 13
app/view/change/info.ejs

@@ -457,9 +457,9 @@
                         <td data-site="4"><%= cl.unit %></td>
                         <td data-site="5"><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                         <td data-site="6"><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
-                        <td data-site="7"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                        <td data-site="7"><%= ctx.helper.mul(cl.unit_price, cl.oamount, tpUnit) %></td>
                         <td data-site="8"><input class="form-control form-control-sm" placeholder="变更数量" type="text" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)"  value="<%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %>"></td>
-                        <td data-site="9"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                        <td data-site="9"><%= ctx.helper.mul(cl.unit_price, cl.camount, tpUnit) %></td>
                         <td><a class="text-danger">移除</a>
                         </td>
                     </tr>
@@ -483,9 +483,9 @@
                         </td>
                         <td data-site="5"><input class="form-control form-control-sm" placeholder="单价" onkeyup="RegNum(this,event, <%= upUnit %>)" type="text" value="<%= ctx.helper.roundNum(cl.unit_price, upUnit) %>"></td>
                         <td data-site="6"><input class="form-control form-control-sm" placeholder="数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %>"></td>
-                        <td data-site="7"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                        <td data-site="7"><%= ctx.helper.mul(cl.unit_price, cl.oamount, tpUnit) %></td>
                         <td data-site="8"><input class="form-control form-control-sm" placeholder="变更数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %>"></td>
-                        <td data-site="9"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                        <td data-site="9"><%= ctx.helper.mul(cl.unit_price, cl.camount, tpUnit) %></td>
                         <td><a class="text-danger">移除</a>
                         </td>
                     </tr>
@@ -534,11 +534,11 @@
                             <td><%= cl.unit %></td>
                             <td><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.oamount, tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.camount, tpUnit) %></td>
                             <td><%= cl.samount !== '' ? ctx.helper.roundNum(cl.samount, ctx.helper.findDecimal(cl.unit)) : '' %></td>
-                            <td><%= cl.samount !== '' ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), tpUnit) : '' %></td>
+                            <td><%= cl.samount !== '' ? ctx.helper.mul(cl.unit_price, cl.samount, tpUnit) : '' %></td>
                             </td>
                         </tr>
                     <% } %>
@@ -593,13 +593,13 @@
                             <td><%= cl.unit %></td>
                             <td><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.oamount, tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.camount, tpUnit) %></td>
                             <% for (const audit of auditList2) { %>
                                 <% if (audit.usite !== 0) { %>
                                 <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %></td>
-                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, audit.list_amount[cindex]), tpUnit) : '' %></td>
+                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.mul(cl.unit_price,  audit.list_amount[cindex], tpUnit) : '' %></td>
                                 <% } %>
                             <% } %>
                             </td>
@@ -661,9 +661,9 @@
                             <td><%= cl.unit %></td>
                             <td data-site="5"><%= ctx.helper.roundNum(cl.unit_price, upUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.oamount, tpUnit) %></td>
                             <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
-                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
+                            <td><%= ctx.helper.mul(cl.unit_price, cl.camount, tpUnit) %></td>
                             <% for (const audit of auditList) { %>
                                 <% if (audit.usite !== 0) { %>
                                     <% if (uid === audit.uid && audit.status === 2) { %>
@@ -676,7 +676,7 @@
                                     <% } else { %>
                                     <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %></td>
                                     <% } %>
-                                    <td<% if (uid === audit.uid) { %> class="amount_cost"<% } %>><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, audit.list_amount[cindex]), tpUnit) : '' %></td>
+                                    <td<% if (uid === audit.uid) { %> class="amount_cost"<% } %>><%= audit.list_amount[cindex] !== undefined ? ctx.helper.mul(cl.unit_price, audit.list_amount[cindex], tpUnit) : '' %></td>
                                 <% } %>
                             <% } %>
                             </td>

+ 1 - 1
app/view/material/info.ejs

@@ -10,7 +10,7 @@
                         <a href="javascript: void(0);" id="del" class="btn btn-sm btn-light text-primary" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除材料"><i class="fa fa-remove" aria-hidden="true"></i></a>
                     </div>
                 <% } %>
-                <div class="d-inline-block">
+                <div class="d-inline-block ml-3">
                     本期调差计量期:第<span class="mx-2"><%= material.s_order.split(',').join(',') %></span>期
                     <span id="qi-month">
                         <% if (months.length > 0) { %>