|
@@ -713,28 +713,35 @@ module.exports = app => {
|
|
|
*/
|
|
|
async checkAgain(tenderId, times = 1) {
|
|
|
const time = new Date();
|
|
|
+ const accountId = this.ctx.session.sessionUser.accountId;
|
|
|
// 整理当前流程审核人状态更新
|
|
|
const auditors = await this.getAllDataByCondition({
|
|
|
where: { tender_id: tenderId, times },
|
|
|
orders: [['audit_order', 'desc']],
|
|
|
});
|
|
|
if (auditors.length <= 0) throw '台账审核数据错误';
|
|
|
- const selfAudit = auditors[0];
|
|
|
- if (selfAudit.audit_id !== this.ctx.session.sessionUser.accountId) throw '当前台账您无权重审';
|
|
|
+ const flowAuditors = auditors.filter(x => { return x.audit_order === auditors[0].audit_order; });
|
|
|
+ const selfAudit = flowAuditors.find(x => { return x.audit_id === accountId; });
|
|
|
+ if (!selfAudit) throw '当前台账您无权重审';
|
|
|
const tender = this.ctx.service.tender.getDataById(tenderId);
|
|
|
if (!tender) throw '标段数据错误';
|
|
|
|
|
|
let otherAuditIds = [tender.user_id, ...auditors.map(x => { return x.audit_id })];
|
|
|
otherAuditIds = this._.uniq(otherAuditIds).filter(x => { return x !== selfAudit.audit_id; });
|
|
|
|
|
|
- const checkAgainAuditor = {
|
|
|
- tender_id: tenderId, times, audit_order: selfAudit.audit_order + 1, audit_id: selfAudit.audit_id,
|
|
|
- begin_time: time, end_time: time, opinion: '', status: auditConst.status.checkAgain,
|
|
|
- };
|
|
|
- const checkingAuditor = {
|
|
|
- tender_id: tenderId, times, audit_order: selfAudit.audit_order + 2, audit_id: selfAudit.audit_id,
|
|
|
- begin_time: time, end_time: null, opinion: '', status: auditConst.status.checking,
|
|
|
- };
|
|
|
+ const checkAgainAuditor = flowAuditors.map(x => {
|
|
|
+ return {
|
|
|
+ tender_id: tenderId, times, audit_order: x.audit_order + 1, audit_id: x.audit_id,
|
|
|
+ begin_time: time, end_time: time, opinion: '',
|
|
|
+ status: x.audit_id === accountId ? auditConst.status.checkAgain : auditConst.status.checkSkip,
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const checkingAuditor = flowAuditors.map(x => {
|
|
|
+ return {
|
|
|
+ tender_id: tenderId, times, audit_order: x.audit_order + 2, audit_id: x.audit_id,
|
|
|
+ begin_time: time, end_time: null, opinion: '', status: auditConst.status.checking,
|
|
|
+ };
|
|
|
+ });
|
|
|
const transaction = await this.db.beginTransaction();
|
|
|
try {
|
|
|
// 当前审批人2次添加至流程中
|