|
@@ -393,34 +393,38 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ async _checkStageValid(stage) {
|
|
|
+ if (stage.status === auditConst.stage.status.uncheck && !this.ctx.tender.isTourist) {
|
|
|
+ const assist = await this.ctx.service.auditAss.getAllDataByCondition({ where: { tid: stage.tid, user_id: stage.user_id } });
|
|
|
+ const assistId = assist.map(x => { return x.ass_user_id });
|
|
|
+ return stage.user_id === this.ctx.session.sessionUser.accountId || assistId.indexOf(this.ctx.session.sessionUser.accountId) >= 0;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
/**
|
|
|
* 获取标段下的全部计量期,按倒序
|
|
|
* @param tenderId
|
|
|
* @return {Promise<void>}
|
|
|
*/
|
|
|
async getValidStages(tenderId) {
|
|
|
- const stages = await this.db.select(this.tableName, {
|
|
|
+ let stages = await this.db.select(this.tableName, {
|
|
|
where: { tid: tenderId },
|
|
|
orders: [['order', 'desc']],
|
|
|
});
|
|
|
for (const s of stages) {
|
|
|
s.tp_history = s.tp_history ? JSON.parse(s.tp_history) : [];
|
|
|
+ s.valid = await this._checkStageValid(s);
|
|
|
}
|
|
|
if (stages.length !== 0 && !this.ctx.session.sessionUser.is_admin) {
|
|
|
- const lastStage = stages[0];
|
|
|
- if (lastStage.status === auditConst.stage.status.uncheck && !this.ctx.tender.isTourist) {
|
|
|
- const assist = await this.ctx.service.auditAss.getAllDataByCondition({ where: { tid: tenderId, user_id: lastStage.user_id } });
|
|
|
- const assistId = assist.map(x => { return x.ass_user_id });
|
|
|
- if (lastStage.user_id !== this.ctx.session.sessionUser.accountId && assistId.indexOf(this.ctx.session.sessionUser.accountId) < 0) {
|
|
|
- stages.splice(0, 1);
|
|
|
- }
|
|
|
- }
|
|
|
+ stages = stages.filter(x => { return x.valid; });
|
|
|
}
|
|
|
// 最新一期计量(未审批完成),当前操作人的期详细数据,应实时计算
|
|
|
if (stages.length === 0) return stages;
|
|
|
|
|
|
- await this.checkStageGatherData(stages[0], true);
|
|
|
for (const s of stages) {
|
|
|
+ if (s.status !== auditConst.stage.status.checked) await this.checkStageGatherData(s, true);
|
|
|
s.tp = this.ctx.helper.sum([s.contract_tp, s.qc_tp, s.pc_tp]);
|
|
|
s.pre_tp = this.ctx.helper.add(s.pre_contract_tp, s.pre_qc_tp);
|
|
|
s.end_tp = this.ctx.helper.add(s.pre_tp, s.tp);
|