Sfoglia il codice sorgente

变更立项、变更申请、变更方案,缓存终审人信息

MaiXinRong 1 anno fa
parent
commit
7e1c72fbbe

+ 30 - 6
app/controller/change_controller.js

@@ -1719,7 +1719,15 @@ module.exports = app => {
             const changes = await ctx.service.changeProject.getListByStatus(tender.id, status, 1, sorts, orders);
             const total = await ctx.service.changeProject.getCountByStatus(tender.id, status);
             for (const c of changes) {
-                c.curAuditors = await ctx.service.changeProjectAudit.getAuditorsByStatus(c.id, c.status, c.times);
+                if (c.status !== audit.change.status.checked || !c.final_auditor_str) {
+                    c.curAuditors = await ctx.service.changeProjectAudit.getAuditorsByStatus(c.id, c.status, c.times);
+                    if (c.status === audit.change.status.checked && c.curAuditors.length > 0) {
+                        const final_auditor_str = c.curAuditors[0].audit_type === auditType.key.common
+                            ? c.curAuditors[0].name + (c.curAuditors[0].role ? '-' + c.curAuditors[0].role : '')
+                            : ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审';
+                        await ctx.service.changeProject.defaultUpdate({ final_auditor_str }, { where: { id: c.id } });
+                    }
+                }
             }
             const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
             const userPermission = accountInfo !== undefined && accountInfo.permission !== ''
@@ -2548,7 +2556,15 @@ module.exports = app => {
             let page_total = 0;
             const tp = await ctx.service.changeApply.getTp(tender.id, status);
             for (const c of changes) {
-                c.curAuditors = await ctx.service.changeApplyAudit.getAuditorsByStatus(c.id, c.status, c.times);
+                if (c.status !== audit.change.status.checked || !c.final_auditor_str) {
+                    c.curAuditors = await ctx.service.changeApplyAudit.getAuditorsByStatus(c.id, c.status, c.times);
+                    if (c.status === audit.change.status.checked && c.curAuditors.length > 0) {
+                        const final_auditor_str = c.curAuditors[0].audit_type === auditType.key.common
+                            ? c.curAuditors[0].name + (c.curAuditors[0].role ? '-' + c.curAuditors[0].role : '')
+                            : ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审';
+                        await ctx.service.changeApply.defaultUpdate({ final_auditor_str }, { where: { id: c.id } });
+                    }
+                }
                 page_total = ctx.helper.add(page_total, c.total_price);
             }
             const tender_userInfo = await ctx.service.projectAccount.getDataById(ctx.tender.data.user_id);
@@ -3378,10 +3394,18 @@ module.exports = app => {
             let page_total = 0;
             const tp = await ctx.service.changePlan.getTp(tender.id, status);
             for (const c of changes) {
-                c.curAuditors = await ctx.service.changePlanAudit.getAuditorsByStatus(c.id, c.status, c.times);
-                // if (c.status === audit.changePlan.status.checkNoPre) {
-                //     c.curAuditors2 = await ctx.service.changePlanAudit.getAuditorsByStatus(c.id, audit.changePlan.status.checking, c.times);
-                // }
+                if (c.status !== audit.change.status.checked || !c.final_auditor_str) {
+                    c.curAuditors = await ctx.service.changePlanAudit.getAuditorsByStatus(c.id, c.status, c.times);
+                    // if (c.status === audit.changePlan.status.checkNoPre) {
+                    //     c.curAuditors2 = await ctx.service.changePlanAudit.getAuditorsByStatus(c.id, audit.changePlan.status.checking, c.times);
+                    // }
+                    if (c.status === audit.change.status.checked && c.curAuditors.length > 0) {
+                        const final_auditor_str = c.curAuditors[0].audit_type === auditType.key.common
+                            ? c.curAuditors[0].name + (c.curAuditors[0].role ? '-' + c.curAuditors[0].role : '')
+                            : ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审';
+                        await ctx.service.changePlan.defaultUpdate({ final_auditor_str }, { where: { id: c.id } });
+                    }
+                }
                 page_total = ctx.helper.add(page_total, c.total_price);
             }
             const tender_userInfo = await ctx.service.projectAccount.getDataById(ctx.tender.data.user_id);

+ 8 - 6
app/view/change/apply.ejs

@@ -98,12 +98,14 @@
                                 <% } %>
                             </td>
                             <td class="<%- auditConst.auditProgressClass[c.status] %>">
-                                <% if (c.curAuditors && c.curAuditors.length > 0) { %>
-                                    <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
-                                    <% } else { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
-                                    <% } %>
+                                <% if (c.status === auditConst.status.checked && c.final_auditor_str) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.final_auditor_str %></a>
+                                <% } else if (c.curAuditors.length > 0) { %>
+                                <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
+                                <% } else { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
+                                <% } %>
                                 <% } %>
                                 <%- auditConst.auditProgress[c.status] %>
                             </td>

+ 8 - 6
app/view/change/plan.ejs

@@ -97,12 +97,14 @@
                                 <% } %>
                             </td>
                             <td class="<%- auditConst.auditProgressClass[c.status] %>">
-                                <% if (c.curAuditors && c.curAuditors.length > 0) { %>
-                                    <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
-                                    <% } else { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
-                                    <% } %>
+                                <% if (c.status === auditConst.status.checked && c.final_auditor_str) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.final_auditor_str %></a>
+                                <% } else if (c.curAuditors.length > 0) { %>
+                                <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
+                                <% } else { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
+                                <% } %>
                                 <% } %>
                                 <%- auditConst.auditProgress[c.status] %>
                             </td>

+ 8 - 6
app/view/change/project.ejs

@@ -95,12 +95,14 @@
                                 <% } %>
                             </td>
                             <td class="<%- auditConst.auditProgressClass[c.status] %>">
-                                <% if (c.curAuditors && c.curAuditors.length > 0) { %>
-                                    <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
-                                    <% } else { %>
-                                        <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.id %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
-                                    <% } %>
+                                <% if (c.status === auditConst.status.checked && c.final_auditor_str) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.final_auditor_str %></a>
+                                <% } else if (c.curAuditors.length > 0) { %>
+                                <% if (c.curAuditors[0].audit_type === auditType.key.common) { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- c.curAuditors[0].name %><%if (c.curAuditors[0].role !== '' && c.curAuditors[0].role !== null) { %>-<%- c.curAuditors[0].role %><% } %></a>
+                                <% } else { %>
+                                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" c-id="<%- c.cid %>"><%- ctx.helper.transFormToChinese(c.curAuditors[0].audit_order) + '审' %></a>
+                                <% } %>
                                 <% } %>
                                 <%- auditConst.auditProgress[c.status] %>
                             </td>

+ 6 - 0
sql/update.sql

@@ -44,3 +44,9 @@ ADD COLUMN `memo` varchar(255) NOT NULL DEFAULT '' AFTER `run_time`;
 
 ALTER TABLE `zh_change`
 ADD COLUMN `final_auditor_str` varchar(50) NOT NULL DEFAULT '' COMMENT '终审人相关(cache)' AFTER `sp_group`;
+ALTER TABLE `zh_change_apply`
+ADD COLUMN `final_auditor_str` varchar(50) NOT NULL DEFAULT '' COMMENT '终审人相关(cache)' AFTER `sp_group`;
+ALTER TABLE `zh_change_plan`
+ADD COLUMN `final_auditor_str` varchar(50) NOT NULL DEFAULT '' COMMENT '终审人相关(cache)' AFTER `sp_group`;
+ALTER TABLE `zh_change_project`
+ADD COLUMN `final_auditor_str` varchar(50) NOT NULL DEFAULT '' COMMENT '终审人相关(cache)' AFTER `sp_group`;