Просмотр исходного кода

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

TonyKang 4 лет назад
Родитель
Сommit
8a1f53278d

+ 1 - 1
app/controller/material_controller.js

@@ -405,7 +405,7 @@ module.exports = app => {
                         }
                     }
                     // 并更新至调差表中
-                    await ctx.service.materialExponent.update({ ex_calc: renderData.ex_calc, ex_expr: ctx.material.ex_expr }, { id: ctx.material.id });
+                    await ctx.service.material.update({ ex_calc: JSON.stringify(renderData.ex_calc), ex_expr: ctx.material.ex_expr }, { id: ctx.material.id });
                 } else {
                     renderData.ex_calc = JSON.parse(ctx.material.ex_calc);
                 }

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

@@ -50,7 +50,7 @@ $(document).ready(() => {
     const materialExponentBase = {
         isUsed: function (data) {
             if (data.type === 2) {
-                return data.mid === materialID;
+                return data.mid === materialID || data.weight_num === null;
             } else {
                 return false;
             }

+ 5 - 1
app/service/material_exponent.js

@@ -68,6 +68,9 @@ module.exports = app => {
             try {
                 const meInfo = await this.getDataById(id);
                 await transaction.delete(this.tableName, { id });
+                if (meInfo.weight_num === null) {
+                    await transaction.delete(this.ctx.service.materialExponentHistory.tableName, { mid: id });
+                }
                 let ex_tp = this.ctx.material.ex_tp;
                 let ex_expr = this.ctx.material.ex_expr;
                 if (meInfo.is_summary === materialConst.is_summary.yes) {
@@ -227,7 +230,8 @@ module.exports = app => {
          * @returns {Promise<number>}
          */
         async updateNewMaterial(transaction, mid, ctx, stage_id, ex_calc) {
-            const calcBase = await ctx.service.stage.getMaterialCalcBase(stage_id, ctx.tender.info);
+            const stage_list = await ctx.service.stage.getStageMsgByStageId(stage_id);
+            const calcBase = await ctx.service.stage.getMaterialCalcBase(stage_list, ctx.tender.info);
             const old_ex_calc = ex_calc ? JSON.parse(ex_calc) : null;
             const new_ex_calc = materialConst.ex_calc;
             for (const bq of new_ex_calc) {

+ 2 - 16
app/service/stage_bills.js

@@ -454,16 +454,7 @@ module.exports = app => {
             let contract_tp = 0;
             let qc_tp = 0;
             for (const stage of stage_list) {
-                const sql = 'SELECT Sum(`contract_tp`) As `contract_tp`, Sum(`qc_tp`) As `qc_tp` FROM ' + this.tableName + ' As Bills ' +
-                    '  INNER JOIN ( ' +
-                    '    SELECT MAX(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` From ' + this.tableName +
-                    '      WHERE `times` <= ? AND `order` <= ?' +
-                    '      GROUP BY `lid`' +
-                    '  ) As MaxFilter ' +
-                    '  ON (Bills.times * ' + timesLen + ' + `order`) = MaxFilter.flow And Bills.lid = MaxFilter.lid' +
-                    '  WHERE Bills.sid = ?';
-                const sqlParam = [stage.curTimes, stage.curOrder, stage.id];
-                const result = await this.db.queryOne(sql, sqlParam);
+                const result = await this.getSumTotalPrice(stage);
                 if (result) {
                     contract_tp = this.ctx.helper.add(contract_tp, result.contract_tp);
                     qc_tp = this.ctx.helper.add(qc_tp, result.qc_tp);
@@ -476,12 +467,7 @@ module.exports = app => {
             let contract_tp = 0;
             let qc_tp = 0;
             for (const stage of stage_list) {
-                let result = null;
-                if (regText) {
-                    result = await this.getSumTotalPriceFilter(stage, 'REGEXP', regText);
-                } else {
-                    result = await this.getSumTotalPriceFilter(stage, '<>', this.db.escape(''));
-                }
+                const result = await this.getSumTotalPriceGcl(stage, regText);
                 if (result) {
                     contract_tp = this.ctx.helper.add(contract_tp, result.contract_tp);
                     qc_tp = this.ctx.helper.add(qc_tp, result.qc_tp);

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

@@ -679,9 +679,9 @@
     <script>
         const accountGroup = JSON.parse('<%- JSON.stringify(accountGroup) %>');
         const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
-        const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');
     </script>
 <% } %>
+<script>const cur_uid = parseInt('<%- ctx.session.sessionUser.accountId %>');</script>
 <script>
     $('.sp-location-list').on('shown.bs.modal', function () {
         const scrollBox = $(this).find('div[class="col-8 modal-height-500"]');

+ 2 - 2
app/view/material/file.ejs

@@ -101,8 +101,8 @@
 <script>
   const auditors = JSON.parse('<%- JSON.stringify(auditors) %>');
   const curAuditor = JSON.parse('<%- JSON.stringify(ctx.material.curAuditor) %>');
-  const materialStatus = '<%- ctx.material.status %>';
-  const materialUid = '<%- ctx.material.user_id %>';
+  const materialStatus = parseInt('<%- ctx.material.status %>');
+  const materialUid = parseInt('<%- ctx.material.user_id %>');
   const auditConst = JSON.parse('<%- JSON.stringify(auditConst) %>');
   const tid = '<%- ctx.tender.id %>';
   const mid = '<%- ctx.material.id %>';

+ 10 - 9
app/view/material/index.ejs

@@ -25,16 +25,17 @@
                         <th class="text-center" rowspan="2">计量期</th>
                         <th class="text-center" colspan="2">信息价调差</th>
                         <th class="text-center" colspan="2">指数法调差</th>
-                        <th class="text-center" width="110" rowspan="2">合计(含税)</th>
-                        <th class="text-center" width="110" rowspan="2">合计</th>
+                        <th class="text-center" colspan="2">合计</th>
                         <th class="text-center" rowspan="2">审批进度</th>
                         <th class="text-center" rowspan="2" width="140">操作</th>
                     </tr>
                     <tr>
-                        <th class="text-center" width="110">价差费用(含税)</th>
-                        <th class="text-center" width="110">价差费用</th>
-                        <th class="text-center" width="110">价差费用(含税)</th>
-                        <th class="text-center" width="110">价差费用</th>
+                        <th class="text-center">价差费用</th>
+                        <th class="text-center">价差费用(含税)</th>
+                        <th class="text-center">价差费用</th>
+                        <th class="text-center">价差费用(含税)</th>
+                        <th class="text-center">价差费用</th>
+                        <th class="text-center">价差费用(含税)</th>
                     </tr>
                     </thead>
                     <tbody>
@@ -46,12 +47,12 @@
                             <% console.log(ctx.helper.add(ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), 2), ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), 2))) %>
                             <td class="text-center"><%= moment(m.in_time).format('YYYY-MM-DD') %></td>
                             <td class="text-center">第 <%= m.s_order %> 期</td>
-                            <td class="text-right"><%= m.m_tp !== null ? ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), 2) : null %></td>
                             <td class="text-right"><%= m.m_tp !== null ? ctx.helper.round(m.m_tp, 2) : null %></td>
-                            <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), 2) : null %></td>
+                            <td class="text-right"><%= m.m_tp !== null ? ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), 2) : null %></td>
                             <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(m.ex_tp, 2) : null %></td>
-                            <td class="text-right"><%= ctx.helper.add(ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), 2), ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), 2)) %></td>
+                            <td class="text-right"><%= m.ex_tp !== null ? ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), 2) : null %></td>
                             <td class="text-right"><%= ctx.helper.add(ctx.helper.round(m.ex_tp, 2), ctx.helper.round(m.m_tp, 2)) %></td>
+                            <td class="text-right"><%= ctx.helper.add(ctx.helper.round(ctx.helper.mul(m.ex_tp, 1+m.rate/100), 2), ctx.helper.round(ctx.helper.mul(m.m_tp, 1+m.rate/100), 2)) %></td>
                             <td class="<%- auditConst.auditProgressClass[m.status] %>">
                                 <% if (m.curAuditor) { %>
                                     <a href="#sp-list" data-toggle="modal" data-target="#sp-list" m-order="<%- m.order %>"><%- m.curAuditor.name %><%if (m.curAuditor.role !== '' && m.curAuditor.role !== null) { %>-<%- m.curAuditor.role %><% } %></a>