Forráskód Böngészése

审批管理页面调整

MaiXinRong 1 éve
szülő
commit
4f429f6908

+ 3 - 6
app/controller/stage_controller.js

@@ -1353,7 +1353,7 @@ module.exports = app => {
                 }
 
                 if ((ctx.stage.finalAuditorIds.indexOf(ctx.session.sessionUser.accountId) >= 0 || (ctx.query.confirm === '确认设置终审审批' && ctx.session.sessionUser.is_admin)) && ctx.stage.status === auditConst.status.checked && ctx.stage.order === ctx.stage.highOrder) {
-                    await ctx.service.stageAudit.checkAgain(ctx.stage.id, ctx.stage.times);
+                    await ctx.service.stageAudit.checkAgain(ctx.stage.id, ctx.stage.times, (ctx.query.confirm === '确认设置终审审批' && ctx.session.sessionUser.is_admin));
                     // ctx.redirect(ctx.request.header.referer);
                     ctx.body = {
                         err: 0,
@@ -2021,14 +2021,11 @@ module.exports = app => {
                 const renderData = await this._getDefaultRenderData(ctx);
                 // 获取已完成期审批列表
                 const lastStage = await ctx.service.stage.getLastestStage(ctx.tender.id, true);
-                const auditList = [];
+                let auditList = [];
                 if (lastStage) {
                     renderData.lastStageUser = await ctx.service.projectAccount.getDataById(lastStage.user_id);
                     const times = lastStage.status !== auditConst.status.checkNo ? lastStage.times : lastStage.times - 1;
-                    for (let i = times; i > 0; i--) {
-                        const timeAuditList = await ctx.service.stageAudit.getAuditors(lastStage.id, i, 'desc');
-                        auditList.push(timeAuditList);
-                    }
+                    auditList = await ctx.service.stageAudit.getAuditorHistory(lastStage.id, times, true);
                 }
                 renderData.lastStage = lastStage;
                 renderData.lastAuditList = auditList;

+ 15 - 10
app/service/stage_audit.js

@@ -895,7 +895,7 @@ module.exports = app => {
          * @param {Number} times - 第几次审批
          * @return {Promise<void>}
          */
-        async checkAgain(stageId, times = 1) {
+        async checkAgain(stageId, times = 1, force) {
             const accountId = this.ctx.session.sessionUser.accountId;
             const time = new Date();
             // 整理当前流程审核人状态更新
@@ -907,7 +907,8 @@ module.exports = app => {
             const audits = auditors.filter(x => { return x.order === maxOrder});
             if (!audits || audits.length === 0 || maxOrder < 1) throw '审核数据错误';
             const selfAudit = audits.find(x => { return x.aid === accountId; });
-            if (!selfAudit) throw '当前标段您无权审批';
+            if (!selfAudit && !force) throw '当前标段您无权审批';
+            const finalAudit = selfAudit || audits[0];
             const stageInfo = await this.ctx.service.stage.getDataById(stageId);
 
             const transaction = await this.db.beginTransaction();
@@ -918,7 +919,7 @@ module.exports = app => {
                     checkAgainAuditors.push({
                         tid: x.tid, sid: x.sid, aid: x.aid,
                         times: x.times, order: x.order + 1,
-                        status: x.aid === selfAudit.aid ? auditConst.status.checkAgain : auditConst.status.checkSkip,
+                        status: !selfAudit || x.aid === selfAudit.aid ? auditConst.status.checkAgain : auditConst.status.checkSkip,
                         begin_time: time, end_time: time, opinion: '',
                         audit_type: x.audit_type, audit_order: x.audit_order,
                     });
@@ -936,8 +937,8 @@ module.exports = app => {
                 await transaction.insert(this.tableName, checkingAuditors);
 
                 // 复制一份最新数据给下一人
-                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, selfAudit.order + 1, transaction);
-                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, selfAudit.order + 2, transaction);
+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, finalAudit.order + 1, transaction);
+                await this.ctx.service.stagePay.copyAuditStagePays(this.ctx.stage, this.ctx.stage.times, finalAudit.order + 2, transaction);
                 await this.ctx.service.stageJgcl.updateHistory4CheckAgain(this.ctx.stage, transaction);
                 await this.ctx.service.stageBonus.updateHistory4CheckAgain(this.ctx.stage, transaction);
                 await this.ctx.service.stageOther.updateHistory4CheckAgain(this.ctx.stage, transaction);
@@ -945,7 +946,7 @@ module.exports = app => {
                 await this.ctx.service.stageTempLand.updateHistory4CheckAgain(this.ctx.stage, transaction);
 
                 // 同步 期信息
-                const his = this.ctx.stage.tp_history.find(x => { return x.times === times && x.order === selfAudit.order });
+                const his = this.ctx.stage.tp_history.find(x => { return x.times === times && x.order === finalAudit.order });
                 const stageTp = {
                     contract_tp: his.contract_tp,
                     qc_tp: his.qc_tp,
@@ -954,7 +955,7 @@ module.exports = app => {
                     yf_tp: his.tp,
                     sf_tp: his.tp,
                 };
-                this.ctx.stage.tp_history.push({ times, order: selfAudit.order + 1, ...stageTp });
+                this.ctx.stage.tp_history.push({ times, order: finalAudit.order + 1, ...stageTp });
                 await transaction.update(this.ctx.service.stage.tableName, {
                     id: stageId,
                     status: auditConst.status.checking,
@@ -965,7 +966,7 @@ module.exports = app => {
                 await this.ctx.service.revisePrice.cancelPriceUsed(this.ctx.stage, transaction);
                 // 重算所有单价变更
                 const priceCalc = new RevisePrice(this.ctx);
-                const pcTp = await priceCalc.stageCheckAgainPriceChange(this.ctx.stage, selfAudit.order + 2, transaction);
+                const pcTp = await priceCalc.stageCheckAgainPriceChange(this.ctx.stage, finalAudit.order + 2, transaction);
                 await this.ctx.service.tenderCache.updateStageCache4Flow(transaction, this.ctx.stage, auditConst.status.checking, checkingAuditors, checkAgainAuditors, null, stageTp, pcTp);
 
                 // 添加短信通知-需要审批提醒功能
@@ -1996,7 +1997,7 @@ module.exports = app => {
             return group;
         }
 
-        async getAuditorHistory(stageId, times) {
+        async getAuditorHistory(stageId, times, reverse = false) {
             const history = [];
             if (times >= 1) {
                 for (let i = 1; i <= times; i++) {
@@ -2041,7 +2042,11 @@ module.exports = app => {
                         }
                         historyGroup.push(his);
                     }
-                    history.push(historyGroup);
+                    if (reverse) {
+                        history.push(historyGroup.reverse());
+                    } else {
+                        history.push(historyGroup);
+                    }
                 }
             }
             return history;

+ 20 - 7
app/view/stage/manager.ejs

@@ -43,18 +43,31 @@
                                         <th width="15%">审批状态</th>
                                         <th>审批意见</th>
                                     </tr>
-                                    <% for (const audit of lastAuditList[la]) { %>
+                                    <% for (const group of lastAuditList[la]) { %>
                                     <tr>
-                                        <td><% if (audit.max_sort === audit.sort) { %>终<% } else { %><%- audit.sort %><% } %>审</td>
-                                        <td><%- audit.name %><% if (audit.role) { %>(<%- audit.role %>)<% } %><p class="text-muted m-0"><%- audit.company %></p></td>
                                         <td>
-                                            <% if (audit.status === auditConst.status.checkNo) { %>
+                                            <% if (group.is_final) { %>终<% } else { %><%- group.audit_order %><% } %>审
+                                            <% if (group.audit_type !== auditType.key.common) { %><span class="text-<%- auditType.info[group.audit_type].class %>"><%- auditType.info[group.audit_type].short %></span><% } %>
+                                        </td>
+                                        <td>
+                                            <% for (const audit of group.auditors) { %>
+                                            <div class="d-inline-block mr-2">
+                                                <%- audit.name %><% if (audit.role) { %>(<%- audit.role %>)<% } %><p class="text-muted m-0"><%- audit.company %></p>
+                                            </div>
+                                            <% } %>
+                                        </td>
+                                        <td>
+                                            <% if (group.status === auditConst.status.checkNo) { %>
                                             <span class="text-danger">退回原报</span>
                                             <% } else { %>
-                                            <span class="<%- auditConst.auditStringClass[audit.status] %>"><% if (audit.status !== auditConst.status.uncheck) { %><%- auditConst.auditProgress[audit.status] %><% } %></span>
+                                            <span class="<%- auditConst.auditStringClass[group.status] %>"><% if (group.status !== auditConst.status.uncheck) { %><%- auditConst.auditProgress[group.status] %><% } %></span>
+                                            <% } %>
+                                            <p class="text-muted m-0"><% if (group.status !== auditConst.status.uncheck && group.status !== auditConst.status.checking) { %><%- group.end_time.toLocaleDateString() %><% } %></p></td>
+                                        <td>
+                                            <% for (const audit of group.auditors) { %>
+                                            <%- audit.opinion %>
                                             <% } %>
-                                            <p class="text-muted m-0"><% if (audit.status !== auditConst.status.uncheck && audit.status !== auditConst.status.checking) { %><%- audit.end_time.toLocaleDateString() %><% } %></p></td>
-                                        <td><%- audit.opinion %></td>
+                                        </td>
                                     </tr>
                                     <% } %>
                                     <tr>