Browse Source

待办页添加材料调差数据展示

laiguoran 5 years ago
parent
commit
79a5fd531c

+ 5 - 0
app/controller/dashboard_controller.js

@@ -27,12 +27,14 @@ module.exports = app => {
             const auditStages = await ctx.service.stageAudit.getAuditStage(ctx.session.sessionUser.accountId);
             const auditChanges = await ctx.service.changeAudit.getAuditChange(ctx.session.sessionUser.accountId);
             const auditRevise = await ctx.service.reviseAudit.getAuditRevise(ctx.session.sessionUser.accountId);
+            const auditMaterial = await ctx.service.materialAudit.getAuditMaterial(ctx.session.sessionUser.accountId);
             const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
             const lastNotice = pa.last_notice ? pa.last_notice : (pa.last_notice === 0 ? new Date() : new Date(pa.last_login * 1000));
             const noticeLedger = await ctx.service.ledgerAudit.getNoticeTender(ctx.session.sessionProject.id, pa.id, lastNotice);
             const noticeStage = await ctx.service.stageAudit.getNoticeStage(ctx.session.sessionProject.id, pa.id, lastNotice);
             const noticeChange = await ctx.service.changeAudit.getNoticeChange(ctx.session.sessionProject.id, pa.id, lastNotice);
             const noticeRevise = await ctx.service.reviseAudit.getNoticeRevise(ctx.session.sessionProject.id, pa.id, lastNotice);
+            const noticeMaterial = await ctx.service.materialAudit.getNoticeMaterial(ctx.session.sessionProject.id, pa.id, lastNotice);
             const projectData = await ctx.service.project.getDataById(ctx.session.sessionProject.id);
             // 获取销售人员数据
             const salesmanData = await ctx.service.manager.getDataById(projectData.manager_id);
@@ -52,16 +54,19 @@ module.exports = app => {
                 auditStages,
                 auditChanges,
                 auditRevise,
+                auditMaterial,
                 role: pa.role,
                 authMobile: pa.auth_mobile,
                 acLedger: auditConst.ledger,
                 acStage: auditConst.stage,
                 acChange: auditConst.flow,
                 acRevise: auditConst.revise,
+                acMaterial: auditConst.material,
                 noticeLedger,
                 noticeStage,
                 noticeChange,
                 noticeRevise,
+                noticeMaterial,
                 projectData,
                 salesmanData,
                 officeName,

+ 29 - 5
app/service/material_audit.js

@@ -483,17 +483,41 @@ module.exports = app => {
          * @returns {Promise<*>}
          */
         async getAuditMaterial(auditorId) {
-            const sql = 'SELECT sa.`aid`, sa.`times`, sa.`order`, sa.`begin_time`, sa.`end_time`, sa.`tid`, sa.`mid`,' +
-                        '    s.`order` As `sorder`, s.`status` As `sstatus`,' +
+            const sql = 'SELECT ma.`aid`, ma.`times`, ma.`order`, ma.`begin_time`, ma.`end_time`, ma.`tid`, ma.`mid`,' +
+                        '    m.`order` As `morder`, m.`status` As `mstatus`,' +
                         '    t.`name`, t.`project_id`, t.`type`, t.`user_id` ' +
-                        '  FROM ?? AS sa, ?? AS s, ?? As t ' +
-                        '  WHERE ((sa.`aid` = ? and sa.`status` = ?) OR (s.`user_id` = ? and sa.`status` = ? and s.`status` = ? and sa.`times` = (s.`times`-1)))' +
-                        '    and sa.`mid` = s.`id` and sa.`tid` = t.`id`';
+                        '  FROM ?? AS ma, ?? AS m, ?? As t ' +
+                        '  WHERE ((ma.`aid` = ? and ma.`status` = ?) OR (m.`user_id` = ? and ma.`status` = ? and m.`status` = ? and ma.`times` = (m.`times`-1)))' +
+                        '    and ma.`mid` = m.`id` and ma.`tid` = t.`id`';
             const sqlParam = [this.tableName, this.ctx.service.material.tableName, this.ctx.service.tender.tableName, auditorId, auditConst.status.checking, auditorId, auditConst.status.checkNo, auditConst.status.checkNo];
             return await this.db.query(sql, sqlParam);
         }
 
         /**
+         * 获取 某时间后 审批进度 更新的期
+         * @param {Number} pid - 查询标段
+         * @param {Number} uid - 查询人
+         * @param {Date} time - 查询时间
+         * @returns {Promise<*>}
+         */
+        async getNoticeMaterial(pid, uid, time) {
+            const sql = 'SELECT t.`name`, t.`project_id`, t.`type`, t.`user_id`, ' +
+                '    m.`order` As `m_order`, m.`status` As `m_status`, ' +
+                '    ma.`aid`, ma.`times`, ma.`order`, ma.`end_time`, ma.`tid`, ma.`mid`, ma.`status`, ' +
+                '    pa.`name` As `su_name`, pa.role As `su_role`, pa.company As `su_company`' +
+                '  FROM ?? As t' +
+                '  LEFT JOIN ?? As m On t.`id` = m.`tid`' +
+                '  LEFT JOIN ?? As ma ON m.`id` = ma.`mid`' +
+                '  LEFT JOIN ?? As pa ON ma.`aid` = pa.`id`' +
+                '  WHERE ma.`aid` <> ? and ma.`end_time` > ? and t.`project_id` = ?' +
+                '  GROUP By t.`id`' +
+                '  ORDER By ma.`end_time`';
+            const sqlParam = [this.ctx.service.tender.tableName, this.ctx.service.material.tableName, this.tableName,
+                this.ctx.service.projectAccount.tableName, uid, time, pid];
+            return await this.db.query(sql, sqlParam);
+        }
+
+        /**
          * 获取审核人流程列表
          *
          * @param auditorId

+ 48 - 2
app/view/dashboard/index.ejs

@@ -28,7 +28,7 @@
                     <div class="card">
                         <div class="card-header">需要你处理</div>
                         <div class="card-body">
-                            <% if (auditTenders.length !== 0 || auditRevise.length !== 0 || auditStages.length !== 0 || auditChanges.length !== 0) { %>
+                            <% if (auditTenders.length !== 0 || auditRevise.length !== 0 || auditStages.length !== 0 || auditChanges.length !== 0 || auditMaterial.length !== 0) { %>
                                 <ul class="list-unstyled m-0">
                                     <% for (const t of auditTenders) { %>
                                         <% if (t.ledger_status === acLedger.status.checking) { %>
@@ -116,6 +116,35 @@
                                             </div>
                                         </li>
                                     <% } %>
+                                    <% for (const am of auditMaterial) { %>
+                                        <% if (am.mstatus !== acMaterial.status.checkNo) { %>
+                                            <li class="media pb-3 mb-3 border-bottom-1">
+                                                <div class="media-body">
+                                                    <div class="row">
+                                                        <div class="col-auto"><span class="badge badge-secondary">材料调差</span></div>
+                                                        <div class="col-6"><a href="/tender/<%- am.tid %>"><%- am.name %></a> 第<%- am.morder %>期</div>
+                                                        <div class="col-3 ml-auto text-right pl-0"><a href="/tender/<%- am.tid %>/measure/material/<%- am.morder %>" class="btn btn-sm btn-outline-primary">审批</a></div>
+                                                    </div>
+                                                    <p class="mt-1 mb-0"><%- ctx.session.sessionUser.name %><small class="ml-1 text-muted"><%- (role ? '- ' + role : '') %></small>
+                                                        <span class="pull-right text-muted"><%- am.begin_time.toLocaleString() %></span>
+                                                    </p>
+                                                </div>
+                                            </li>
+                                        <% } else { %>
+                                            <li class="media pb-3 mb-3 border-bottom-1">
+                                                <div class="media-body">
+                                                    <div class="row">
+                                                        <div class="col-auto"><span class="badge badge-secondary">材料调差</span></div>
+                                                        <div class="col-6"><a href="/tender/<%- am.tid %>"><%- am.name %></a> 第<%- am.morder %>期</div>
+                                                        <div class="col-3 ml-auto text-right pl-0"><a href="/tender/<%- am.tid %>/measure/material/<%- am.morder %>" class="btn btn-sm btn-outline-primary">重新上报</a></div>
+                                                    </div>
+                                                    <p class="mt-1 mb-0"><%- ctx.session.sessionUser.name %><small class="ml-1 text-muted"><%- (role ? '- ' + role : '') %></small>
+                                                        <span class="pull-right text-muted"><%- am.end_time.toLocaleString() %></span>
+                                                    </p>
+                                                </div>
+                                            </li>
+                                        <% } %>
+                                    <% } %>
                             </ul>
                             <% } else { %>
                             <!--没有处理信息-->
@@ -128,7 +157,7 @@
                     <div class="card">
                         <div class="card-header">需要你关注</div>
                         <div class="card-body">
-                            <% if (noticeLedger.length !== 0 || noticeRevise.length !== 0 || noticeStage.length !== 0 || noticeChange.length !== 0) { %>
+                            <% if (noticeLedger.length !== 0 || noticeRevise.length !== 0 || noticeStage.length !== 0 || noticeChange.length !== 0 || noticeMaterial.length !== 0) { %>
                                 <ul class="list-unstyled m-0">
                                     <% for (const nl of noticeLedger) { %>
                                         <li class="media pb-3 mb-3 border-bottom-1">
@@ -196,6 +225,23 @@
                                             </div>
                                         </li>
                                     <% } %>
+                                    <% for (const nm of noticeMaterial) { %>
+                                        <li class="media pb-3 mb-3 border-bottom-1">
+                                            <div class="media-body">
+                                                <div class="row">
+                                                    <div class="col-auto"><span class="badge badge-secondary">材料调差</span></div>
+                                                    <div class="col-6">
+                                                        <a href="/tender/<%- nm.tid %>"><%- nm.name %></a>
+                                                        <a href="/tender/<%- nm.tid %>/measure/stage/<%- nm.m_order %>">第<%- nm.m_order %>期 </a>
+                                                        <%- acStage.statusString[nm.status]%>
+                                                    </div>
+                                                </div>
+                                                <p class="mt-1 mb-0"><%- nm.su_name %><small class="ml-1 text-muted"><%- (nm.su_role ? '- ' + nm.su_role : '') %></small>
+                                                    <span class="pull-right text-muted"><%- nm.end_time.toLocaleString() %></span>
+                                                </p>
+                                            </div>
+                                        </li>
+                                    <% } %>
                                 </ul>
                                 <% } else { %>
                                 <!--没有关注信息-->