浏览代码

fix: 材料调差审核流程bug修复

lanjianrong 4 年之前
父节点
当前提交
1fc6b30f41

+ 2 - 4
app/controller/material_controller.js

@@ -203,8 +203,8 @@ module.exports = app => {
             const times = ctx.material.status === auditConst.status.checkNo ? ctx.material.times - 1 : ctx.material.times;
             ctx.material.user = await ctx.service.projectAccount.getAccountInfoById(ctx.material.user_id);
             ctx.material.auditHistory = [];
-            if (ctx.material.times >= 1) {
-                for (let i = 1; i <= times; i++) {
+            if (ctx.material.times > 1) {
+                for (let i = 1; i < ctx.material.times; i++) {
                     ctx.material.auditHistory.push(await ctx.service.materialAudit.getAuditors(ctx.material.id, i));
                 }
             }
@@ -304,7 +304,6 @@ module.exports = app => {
                 renderData.pos = await ctx.service.pos.getPosData({ tid: ctx.tender.id });
                 // 获取所选期数据并合并相加同类清单项
                 renderData.curLedgerData = await ctx.service.stageBills.getStagesData(ctx.tender.id, ctx.material.stage_id);
-                console.log('curLedgerData:', renderData.curLedgerData);
                 renderData.curPosData = await ctx.service.stagePos.getStagesData(ctx.tender.id, ctx.material.stage_id);
                 await this.layout('material/list.ejs', renderData, 'material/list_modal.ejs');
             } catch (err) {
@@ -578,7 +577,6 @@ module.exports = app => {
                     checkType: parseInt(ctx.request.body.checkType),
                     opinion: ctx.request.body.opinion,
                 };
-                console.log(ctx.request.body);
                 if (!data.checkType || isNaN(data.checkType)) {
                     throw '提交数据错误';
                 }

+ 2 - 0
app/controller/stage_controller.js

@@ -120,6 +120,8 @@ module.exports = app => {
          */
         async _getStageAuditViewData(ctx) {
             const times = ctx.stage.status === auditConst.status.checkNo ? ctx.stage.times - 1 : ctx.stage.times;
+            console.log('times', times);
+
             ctx.stage.user = await ctx.service.projectAccount.getAccountInfoById(ctx.stage.user_id);
             ctx.stage.auditHistory = [];
             if (ctx.stage.times > 1) {

+ 0 - 1
app/middleware/material_check.js

@@ -46,7 +46,6 @@ module.exports = options => {
 
             // 读取原报、审核人数据
             material.auditors = yield this.service.materialAudit.getAuditors(material.id, material.times);
-            console.log(material);
             // if (material.status > 1) {
             //     material.auditors2 === 2 ? material.auditors : (yield this.service.materialAudit.getAuditors(material.id, material.times - 1));
             // }

+ 1 - 0
app/public/js/material_audit.js

@@ -163,6 +163,7 @@ function checkAuditorFrom () {
 }
 // texterea换行
 function auditCheck(i) {
+    console.log('11111111111')
     const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
     $('textarea[name="opinion"]').eq(i).val(opinion);
     return true;

+ 37 - 0
app/service/material_audit.js

@@ -406,6 +406,41 @@ module.exports = app => {
             }
         }
 
+        async _checkNoPre(materialId, checkData, times) {
+            const time = new Date();
+            // 整理当前流程审核人状态更新
+            const audit = await this.getDataByCondition({ mid: materialId, times, status: auditConst.status.checking });
+            console.log('audit', audit);
+            if (!audit || audit.order <= 1) {
+                throw '审核数据错误';
+            }
+            // 添加重新审批后,不能用order-1,取groupby值里的上一个才对
+            const auditors2 = await this.getAuditGroupByList(materialId, times);
+            const auditorIndex = await auditors2.findIndex(function(item) {
+                return item.aid === audit.aid;
+            });
+            const preAuditor = auditors2[auditorIndex - 1];
+            const transaction = await this.db.beginTransaction();
+            try {
+                await transaction.update(this.tableName, { id: audit.id, status: checkData.checkType, opinion: checkData.opinion, end_time: time });
+                const newAuditors = [];
+                newAuditors.push({
+                    tid: audit.tid, mid: audit.mid, aid: preAuditor.aid,
+                    times: audit.times, order: audit.order + 1, status: auditConst.status.checking,
+                    begin_time: time,
+                });
+                newAuditors.push({
+                    tid: audit.tid, mid: audit.mid, aid: audit.aid,
+                    times: audit.times, order: audit.order + 2, status: auditConst.status.uncheck,
+                });
+                await transaction.insert(this.tableName, newAuditors);
+                await transaction.commit();
+            } catch (error) {
+                await transaction.rollback();
+                throw error;
+            }
+        }
+
         /**
          * 审批
          * @param {Number} materialId - 材料调差期id
@@ -417,6 +452,8 @@ module.exports = app => {
             if (checkData.checkType !== auditConst.status.checked && checkData.checkType !== auditConst.status.checkNo && checkData.checkType !== auditConst.status.checkNoPre) {
                 throw '提交数据错误';
             }
+            console.log('checkData:', checkData);
+            console.log('times', times);
             switch (checkData.checkType) {
                 case auditConst.status.checked:
                     await this._checked(materialId, checkData, times);

文件差异内容过多而无法显示
+ 212 - 147
app/view/material/audit_modal.ejs


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

@@ -264,7 +264,7 @@
                                 <li class="nav-item ml-auto">
                                     <!--所有附件 翻页-->
                                     <span id="showPage" style="display: none"><a href="javascript:void(0);" class="page-select" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select" content="next"><i class="fa fa-chevron-right"></i></a></span>
-                                    <a href="#upload" data-toggle="modal" data-target="#upload"  class="btn btn-sm btn-outline-primary ml-3">上传</a>
+                                        <a href="#upload" data-toggle="modal" data-target="#upload"  class="btn btn-sm btn-outline-primary ml-3">上传</a>
                                 </li>
                             </ul>
                         </div>