'use strict'; /** * 变更立项 * * @author Mai * @date * @version */ const RptMemBase = require('./base'); const bindData = {}; class rptMemChange extends RptMemBase { constructor(ctx) { super(ctx, bindData); } async doCheckChangeProject(id) { if (this.ctx.change_project) return; this.ctx.change_project = await this.ctx.service.change.getDataById(id); } async doCheckTender(tenderId) { if (this.ctx.tender) return; this.ctx.tender = { id: tenderId }; this.ctx.tender.data = await this.ctx.service.getTender(tenderId); this.ctx.tender.info = await this.ctx.service.tenderInfo.getTenderInfo(tenderId); } async doBeforeLoadReport(params) { await this.doCheckChangeProject(params.change_project_id); await this.doCheckTender(this.ctx.change_project.tid); } async _getChangeProjectAudit() { const changeAudit = await this.ctx.service.changeProjectAudit.getAllDataByCondition({ where: { cpid: this.ctx.change_project.id, times: this.ctx.change_project.times }}); return this.ctx.helper.filterLastestData(changeAudit, ['aid']); } getCommonData(params, tableName, fields, customDefine, customSelect) { switch (tableName) { case 'mem_change_project': return this.ctx.change_project; case 'mem_change_project_audit': return this._getChangeProjectAudit(); case 'mem_change_project_att': return this.ctx.service.changeProjectAtt.getChangeAttachment(this.ctx.change_project.id); case 'mem_project': return this.ctx.service.project.getDataByCondition({ id: this.ctx.session.sessionProject.id }); case 'mem_tender': return this.ctx.tender.data; case 'mem_tender_info': return this.ctx.tender.info; default: return []; } } } module.exports = rptMemChange;