浏览代码

审批流程问题

MaiXinRong 1 年之前
父节点
当前提交
67741b4962
共有 4 个文件被更改,包括 47 次插入10 次删除
  1. 1 5
      app/controller/measure_controller.js
  2. 38 3
      app/service/stage_audit.js
  3. 2 0
      app/service/tender_cache.js
  4. 6 2
      app/view/measure/stage.ejs

+ 1 - 5
app/controller/measure_controller.js

@@ -50,12 +50,8 @@ module.exports = app => {
                 renderData.stages = await ctx.service.stage.getValidStages(ctx.tender.id);
                 if (renderData.stages.length > 0) await this.ctx.service.stage.checkStageGatherData(renderData.stages[0], this.ctx.session.sessionUser.is_admin);
                 for (const s of renderData.stages) {
-                    // s.curAuditor = null;
                     // 根据期状态返回展示用户
-                    s.curAuditor = await ctx.service.stageAudit.getAuditorByStatus(s.id, s.status, s.times);
-                    if (s.status === auditConst.status.checkNoPre) {
-                        s.curAuditor2 = await ctx.service.stageAudit.getAuditorByStatus(s.id, auditConst.status.checking);
-                    }
+                    s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);
                 }
                 await this.layout('measure/stage.ejs', renderData, 'measure/stage_modal.ejs');
             } catch (err) {

+ 38 - 3
app/service/stage_audit.js

@@ -457,7 +457,7 @@ module.exports = app => {
                     if (selfAudit.audit_type === auditType.key.or) {
                         const updateOther = [];
                         for (const audit of audits) {
-                            if (audit.aid === selfAudit) continue;
+                            if (audit.aid === selfAudit.aid) continue;
                             updateOther.push({
                                 id: audit.id,
                                 status: auditConst.status.checkSkip,
@@ -465,7 +465,7 @@ module.exports = app => {
                                 end_time: time,
                             });
                         }
-                        if (updateOther.length > 0) transaction.updateRows(this.table, updateOther);
+                        if (updateOther.length > 0) transaction.updateRows(this.tableName, updateOther);
                     }
                     // 无下一审核人表示,审核结束
                     if (nextAudits.length > 0) {
@@ -487,7 +487,7 @@ module.exports = app => {
                             tp_history: JSON.stringify(this.ctx.stage.tp_history),
                             cache_time_r: this.ctx.stage.cache_time_l,
                         });
-                        await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, [], flowAudits, ledgerTp, stageTp);
+                        await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, nextAudits, flowAudits, ledgerTp, stageTp);
                         // 多人协同,取消下一审批人存在的锁定
                         await this.ctx.service.stageAuditAss.cancelLock(this.ctx.stage, nextAudits.map(x => { return x.aid; }), transaction);
 
@@ -1629,6 +1629,41 @@ module.exports = app => {
             return auditor;
         }
 
+        async getAuditorsByStatus(stageId, status, times = 1) {
+            let auditor = [];
+            let sql = '';
+            let sqlParam = '';
+            let cur;
+            switch (status) {
+                case auditConst.status.checking:
+                case auditConst.status.checked:
+                case auditConst.status.checkNoPre:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where sid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [stageId, times, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
+                        '  WHERE la.`sid` = ? and la.`order` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order];
+                    auditor = await this.db.query(sql, sqlParam);
+                    break;
+                case auditConst.status.checkNo:
+                    cur = await this.db.queryOne(`SELECT * From ${this.tableName} where sid = ? AND times = ? AND status = ? ORDER By times DESC, ` + '`order` DESC', [stageId, parseInt(times) - 1, status]);
+                    if (!cur) return [];
+
+                    sql = 'SELECT la.`aid`, pa.`name`, pa.`company`, pa.`role`, la.`times`, la.`sid`, la.`order`, la.audit_order ' +
+                        '  FROM ?? AS la Left Join ?? AS pa On la.`aid` = pa.`id` ' +
+                        '  WHERE la.`sid` = ? and la.`order` = ? and la.`times` = ?';
+                    sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, stageId, cur.order, parseInt(times) - 1];
+                    auditor = await this.db.queryOne(sql, sqlParam);
+                    break;
+                case auditConst.status.uncheck:
+                default:
+                    break;
+            }
+            return auditor;
+        }
+
         /**
          * 取某一期已批准审核信息(报表用)
          *

+ 2 - 0
app/service/tender_cache.js

@@ -209,6 +209,8 @@ module.exports = app => {
         }
 
         async updateStageCache4Flow(transaction, stage, status, auditors, preAuditors, ledgerTp, stageTp, pcTp) {
+            console.log(preAuditors);
+            console.log(auditors);
             const orgCache = await this.getDataById(stage.tid);
             const data = { id: stage.tid, stage_status: status };
             if (ledgerTp) data.ledger_tp = JSON.stringify(ledgerTp);

+ 6 - 2
app/view/measure/stage.ejs

@@ -80,8 +80,12 @@
                         <td class="text-right"><%- (s.sf_tp ? s.sf_tp : '') %></td>
                         <% } %>
                         <td class="<%- auditConst.auditProgressClass[s.status] %>">
-                            <% if (s.curAuditor) { %>
-                            <a href="#sp-list" data-toggle="modal" data-target="#sp-list" s-order="<%- s.order %>"><%- s.curAuditor.name %><%if (s.curAuditor.role !== '' && s.curAuditor.role !== null) { %>-<%- s.curAuditor.role %><% } %></a>
+                            <% if (s.curAuditors.length > 0) { %>
+                            <% if (s.curAuditors[0].audit_type === auditType.key.common) { %>
+                            <a href="#sp-list" data-toggle="modal" data-target="#sp-list" s-order="<%- s.order %>"><%- s.curAuditors[0].name %><%if (s.curAuditors[0].role !== '' && s.curAuditors[0].role !== null) { %>-<%- s.curAuditors[0].role %><% } %></a>
+                            <% } else { %>
+                            <a href="#sp-list" data-toggle="modal" data-target="#sp-list" s-order="<%- s.order %>"><%- ctx.helper.transFormToChinese(s.curAuditors[0].audit_order) + '审' %></a>
+                            <% } %>
                             <% } %>
                             <%- auditConst.auditProgress[s.status] %>
                         </td>