|
@@ -81,6 +81,8 @@ module.exports = app => {
|
|
|
// 需要缓存的数据
|
|
|
this.stageImData = null;
|
|
|
this.changeData = null;
|
|
|
+ this.changeApplyData = null;
|
|
|
+ this.changeProjectData = null;
|
|
|
this.stageValidRole = [];
|
|
|
}
|
|
|
|
|
@@ -790,7 +792,6 @@ module.exports = app => {
|
|
|
throw err;
|
|
|
this.changeData = {change: [], bills: []};
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
async _generateChangeAudit() {
|
|
@@ -837,16 +838,78 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async getChangeApplyData(tid, sid, fields) {
|
|
|
+ async _generateChangeApply(tid) {
|
|
|
+ if (!!this.changeApplyData) return;
|
|
|
const where = { tid };
|
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeApply.status.checked;
|
|
|
- return await this.ctx.service.changeApply.getAllDataByCondition({ where });
|
|
|
+ this.changeApplyData.data = await this.ctx.service.changeApply.getAllDataByCondition({ where });
|
|
|
}
|
|
|
|
|
|
- async getChangeProjectData(tid, sid, fields) {
|
|
|
+ async _generateChangeApplyAudit() {
|
|
|
+ if (!!this.changeApplyData.audit) return;
|
|
|
+
|
|
|
+ this.changeApplyData.audit = [];
|
|
|
+ for (const c of this.changeApplyData.data) {
|
|
|
+ const changeAudit = await this.ctx.service.changeApplyAudit.getAllDataByCondition({ where: { caid: c.id, times: c.times }});
|
|
|
+ const changeAuditFilter = this.ctx.helper.filterLastestData(changeAudit, ['aid']);
|
|
|
+ this.changeData.audit.push(...changeAuditFilter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getChangeApplyData(tid, sid, fields) {
|
|
|
+ try {
|
|
|
+ await this._generateChangeApply(tid);
|
|
|
+ return this.changeApplyData.data;
|
|
|
+ } catch (err) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async _generateChangeProject(tid) {
|
|
|
+ if (!!this.changeProjectData) return;
|
|
|
const where = { tid };
|
|
|
if (this.ctx.session.sessionProject.page_show.isOnlyChecked) where.status = audit.changeProject.status.checked;
|
|
|
- return await this.ctx.service.changeProject.getAllDataByCondition({ where });
|
|
|
+ this.changeProjectData.data = await this.ctx.service.changeProject.getAllDataByCondition({ where });
|
|
|
+ }
|
|
|
+
|
|
|
+ async getChangeApplyAuditData(tid, sid, fields) {
|
|
|
+ try {
|
|
|
+ await this._generateChangeApply(tid);
|
|
|
+ await this._generateChangeApplyAudit();
|
|
|
+ return this.changeApplyData.audit;
|
|
|
+ } catch (err) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async _generateChangeProjectAudit() {
|
|
|
+ if (!!this.changeProjectData.audit) return;
|
|
|
+
|
|
|
+ this.changeProjectData.audit = [];
|
|
|
+ for (const c of this.changeProjectData.data) {
|
|
|
+ const changeAudit = await this.ctx.service.changeProjectAudit.getAllDataByCondition({ where: { cpid: c.id, times: c.times }});
|
|
|
+ const changeAuditFilter = this.ctx.helper.filterLastestData(changeAudit, ['aid']);
|
|
|
+ this.changeData.audit.push(...changeAuditFilter);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getChangeProjectData(tid, sid, fields) {
|
|
|
+ try {
|
|
|
+ await this._generateChangeProject(tid);
|
|
|
+ return this.changeProjectData.data;
|
|
|
+ } catch (err) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ async getChangeProjectAuditData(tid, sid, fields) {
|
|
|
+ try {
|
|
|
+ await this._generateChangeProject(tid);
|
|
|
+ await this._generateChangeProjectAudit();
|
|
|
+ return this.changeProjectData.audit;
|
|
|
+ } catch (err) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async getStageJgcl(tid, sid, fields) {
|