Browse Source

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

MaiXinRong 11 months ago
parent
commit
96b0ea18b2

+ 2 - 0
app/controller/dashboard_controller.js

@@ -35,6 +35,7 @@ module.exports = app => {
             const auditChangeApply = ctx.session.sessionProject.page_show.openChangeApply ? await ctx.service.changeApplyAudit.getAuditChangeApply(ctx.session.sessionUser.accountId) : [];
             const auditChangePlan = ctx.session.sessionProject.page_show.openChangePlan ? await ctx.service.changePlanAudit.getAuditChangePlan(ctx.session.sessionUser.accountId) : [];
             const auditPayments = ctx.session.sessionProject.page_show.openPayment ? await ctx.service.paymentDetailAudit.getAuditPayment(ctx.session.sessionUser.accountId) : [];
+            const auditStageAss = await ctx.service.stageAuditAss.getAuditStageAss(ctx.session.sessionUser.accountId);
             const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
             const noticeList = await ctx.service.noticePush.getNotice(ctx.session.sessionProject.id, pa.id);
             const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
@@ -89,6 +90,7 @@ module.exports = app => {
                 auditChangeApply,
                 auditChangePlan,
                 auditPayments,
+                auditStageAss,
                 shenpi_count,
                 total_count,
                 last_day: ctx.helper.calcDayNum(last_time),

+ 40 - 0
app/service/stage_audit_ass.js

@@ -40,6 +40,46 @@ module.exports = app => {
             return result;
         }
 
+        async getAuditStageAss(ass_user_id) {
+            // 找出待上报或待审批的协同字段
+            const accountStageAssData = await this.getAllDataByCondition({ where: { ass_user_id, confirm: 0 } });
+            const result = [];
+            const accountAssData = await this.ctx.service.auditAss.getAllDataByCondition({ where: { ass_user_id } });
+            for (const as of accountStageAssData) {
+                const index = accountAssData.findIndex(x => { return x.tid === as.tid && x.user_id === as.user_id; });
+                if (index >= 0) {
+                    accountAssData.splice(index, 1);
+                    result.push(as);
+                }
+            }
+            result.push(...accountAssData);
+            // 判断该标段是否存在待审批或待上报的协同人,同时到本人协同阶段
+            const result2 = [];
+            if (result.length > 0) {
+                for (const r of result) {
+                    const t = await this.ctx.service.tender.getDataById(r.tid);
+                    const s = r.sid ? await this.ctx.service.stage.getDataById(r.sid) : await this.ctx.service.stage.getLastestStage(r.tid);
+                    if (s) {
+                        r.tender_name = t.name;
+                        r.sstatus = s.status;
+                        r.sorder = s.order;
+                        if (s && s.status === auditConst.stage.status.checkNo && s.user_id === r.user_id) {
+                            const lastAudit = await this.ctx.service.stageAudit.getLastestAuditor(s.id, s.times - 1, auditConst.stage.status.checkNo);
+                            r.begin_time = lastAudit ? lastAudit.end_time : s.in_time;
+                            result2.push(r);
+                        } else {
+                            const curAudits = await this.ctx.service.stageAudit.getCurAuditors(s.id, s.times);
+                            if (curAudits.length > 0 && this._.findIndex(curAudits, { user_id: r.user_id }) !== -1) {
+                                r.begin_time = curAudits[0].begin_time;
+                                result2.push(r);
+                            }
+                        }
+                    }
+                }
+            }
+            return result2;
+        }
+
         async getUserAssist(stage, user_id) {
             const stageData = await this.getAllDataByCondition({ where: { sid: stage.id, times: stage.times, user_id } });
             if (stage.status === auditConst.stage.status.checked) return stageData;

+ 19 - 0
app/view/dashboard/index.ejs

@@ -143,6 +143,25 @@
                                                 </tr>
                                             <% } %>
                                         <% } %>
+                                        <% for (const audit of auditStageAss) { %>
+                                            <% if (audit.sstatus !== acStage.status.checkNo) { %>
+                                                <tr data-type="2">
+                                                    <td><span class="bg-new-stage text-new-stage badge text-width">计量审批</span></td>
+                                                    <td><a href="/tender/<%- audit.tid %>"><%- audit.tender_name %></a> <a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>">第<%- audit.sorder %>期</a></td>
+                                                    <td>第<%- audit.sorder %>期</td>
+                                                    <td><%- ctx.moment(audit.begin_time).format('YYYY/MM/DD HH:mm') %></td>
+                                                    <td><a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>" class="btn btn-outline-primary btn-sm btn-table" role="button">协同审批</a></td>
+                                                </tr>
+                                            <% } else { %>
+                                                <tr data-type="2">
+                                                    <td><span class="bg-new-stage text-new-stage badge text-width">计量审批</span></td>
+                                                    <td><a href="/tender/<%- audit.tid %>"><%- audit.tender_name %></a> <a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>">第<%- audit.sorder %>期</a></td>
+                                                    <td>第<%- audit.sorder %>期</td>
+                                                    <td><%- ctx.moment(audit.begin_time).format('YYYY/MM/DD HH:mm') %></td>
+                                                    <td><a href="/tender/<%- audit.tid %>/measure/stage/<%- audit.sorder %>" class="btn btn-outline-warning btn-sm btn-table text-warning" role="button">协同上报</a></td>
+                                                </tr>
+                                            <% } %>
+                                        <% } %>
                                         <% for (const change of auditChanges) { %>
                                             <tr data-type="3">
                                                 <td><span class="bg-new-change text-new-change badge text-width">变更审批</span></td>