| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 | 'use strict';/** * 控制面板 * * @author CaiAoLin * @date 2017/11/23 * @version */const auditConst = require('../const/audit');module.exports = app => {    class DashboardController extends app.BaseController {        /**         * 控制面板页面         *         * @param {Object} ctx - egg全局变量         * @return {void}         */        async index(ctx) {            const auditTenders = await ctx.service.ledgerAudit.getAuditTender(ctx.session.sessionUser.accountId);            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 projectAccountInfo = await ctx.service.projectAccount.getDataById(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 renderData = {                auditTenders,                auditStages,                auditChanges,                auditRevise,                role: projectAccountInfo.role,                acLedger: auditConst.ledger,                acStage: auditConst.stage,                acChange: auditConst.flow,                acRevise: auditConst.revise,                noticeLedger,                noticeStage,                noticeChange,                noticeRevise,            };            await this.layout('dashboard/index.ejs', renderData);            await ctx.service.projectAccount.defaultUpdate({                id: this.ctx.session.sessionUser.accountId,                last_notice: new Date(),            });        }    }    return DashboardController;};
 |