|
|
@@ -1,6 +1,6 @@
|
|
|
'use strict';
|
|
|
|
|
|
-const audit = require('../const/audit');
|
|
|
+const auditConsts = require('../const/audit');
|
|
|
|
|
|
module.exports = app => {
|
|
|
class WeappMeasureController extends app.BaseController {
|
|
|
@@ -13,7 +13,7 @@ module.exports = app => {
|
|
|
return;
|
|
|
}
|
|
|
const renderData = {
|
|
|
- tender: tender.data
|
|
|
+ tender: tender.data,
|
|
|
};
|
|
|
|
|
|
tender.info = await ctx.service.tenderInfo.getTenderInfo(tenderId);
|
|
|
@@ -24,11 +24,11 @@ module.exports = app => {
|
|
|
|
|
|
renderData.stages = await ctx.service.stage.getValidStages(tenderId, this.ctx.session.sessionUser.is_admin);
|
|
|
for (const s of renderData.stages) {
|
|
|
- if (!s.final_auditor_str || s.status !== audit.stage.status.checked) {
|
|
|
- if (s.status === audit.stage.status.checkNoPre) s.status = audit.stage.status.checking;
|
|
|
- if (s.status !== audit.stage.status.checkNo) s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);
|
|
|
- if (s.status === audit.stage.status.checked) {
|
|
|
- const final_auditor_str = (s.curAuditors[0].audit_type === audit.auditType.key.common)
|
|
|
+ if (!s.final_auditor_str || s.status !== auditConsts.stage.status.checked) {
|
|
|
+ if (s.status === auditConsts.stage.status.checkNoPre) s.status = auditConsts.stage.status.checking;
|
|
|
+ if (s.status !== auditConsts.stage.status.checkNo) s.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(s.id, s.status, s.times);
|
|
|
+ if (s.status === auditConsts.stage.status.checked) {
|
|
|
+ const final_auditor_str = (s.curAuditors[0].audit_type === auditConsts.auditType.key.common)
|
|
|
? `${s.curAuditors[0].name}${(s.curAuditors[0].role ? '-' + s.curAuditors[0].role : '')}`
|
|
|
: ctx.helper.transFormToChinese(s.curAuditors[0].audit_order) + '审';
|
|
|
await ctx.service.stage.defaultUpdate({ id: s.id, final_auditor_str });
|
|
|
@@ -36,7 +36,7 @@ module.exports = app => {
|
|
|
}
|
|
|
}
|
|
|
renderData.unCompleteStageCount = renderData.stages.filter(s => {
|
|
|
- return s.status !== audit.stage.status.checked;
|
|
|
+ return s.status !== auditConsts.stage.status.checked;
|
|
|
}).length;
|
|
|
ctx.body = { code: 0, msg: '', data: renderData };
|
|
|
|
|
|
@@ -68,15 +68,48 @@ module.exports = app => {
|
|
|
await ctx.service.stage.loadStageUser(stage);
|
|
|
await ctx.service.stage.loadStageAuditViewData(stage);
|
|
|
|
|
|
- if (!stage.final_auditor_str || stage.status !== audit.stage.status.checked) {
|
|
|
- if (stage.status === audit.stage.status.checkNoPre) {
|
|
|
- stage.status = audit.stage.status.checking;
|
|
|
+ stage.auditHistory = stage.auditHistory && stage.auditHistory.length && stage.auditHistory[stage.auditHistory.length - 1].reduce((prev, curr, idx) => {
|
|
|
+ if (idx === 0) {
|
|
|
+ const reportor = {
|
|
|
+ audit_id: stage.user.id,
|
|
|
+ audit_order: 0,
|
|
|
+ audit_type: 1,
|
|
|
+ status: stage.status === auditConsts.stage.status.uncheck ? auditConsts.stage.status.uncheck : auditConsts.stage.status.checked,
|
|
|
+ times: stage.status === auditConsts.stage.status.checkNo ? stage.times - 1 : stage.times,
|
|
|
+ begin_time: curr.begin_time,
|
|
|
+ end_time: curr.begin_time,
|
|
|
+ name: stage.user.name,
|
|
|
+ company: stage.user.company,
|
|
|
+ role: stage.user.role,
|
|
|
+ mobile: '',
|
|
|
+ opinion: '',
|
|
|
+
|
|
|
+ };
|
|
|
+ prev.push({
|
|
|
+ name: '原报',
|
|
|
+ status: reportor.status,
|
|
|
+ audit_type: reportor.audit_type,
|
|
|
+ auditors: [reportor],
|
|
|
+ });
|
|
|
}
|
|
|
- if (stage.status !== audit.stage.status.checkNo) {
|
|
|
+ prev.push({
|
|
|
+ name: curr.is_final ? '终审' : `${curr.audit_order}审`,
|
|
|
+ audit_type: curr.audit_type,
|
|
|
+ status: curr.status,
|
|
|
+ auditors: curr.auditors,
|
|
|
+ });
|
|
|
+ return prev;
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ if (!stage.final_auditor_str || stage.status !== auditConsts.stage.status.checked) {
|
|
|
+ if (stage.status === auditConsts.stage.status.checkNoPre) {
|
|
|
+ stage.status = auditConsts.stage.status.checking;
|
|
|
+ }
|
|
|
+ if (stage.status !== auditConsts.stage.status.checkNo) {
|
|
|
stage.curAuditors = await ctx.service.stageAudit.getAuditorsByStatus(stage.id, stage.status, stage.times);
|
|
|
}
|
|
|
- if (stage.status === audit.stage.status.checked) {
|
|
|
- const final_auditor_str = (stage.curAuditors[0].audit_type === audit.auditType.key.common)
|
|
|
+ if (stage.status === auditConsts.stage.status.checked) {
|
|
|
+ const final_auditor_str = (stage.curAuditors[0].audit_type === auditConsts.auditType.key.common)
|
|
|
? `${stage.curAuditors[0].name}${(stage.curAuditors[0].role ? '-' + stage.curAuditors[0].role : '')}`
|
|
|
: ctx.helper.transFormToChinese(stage.curAuditors[0].audit_order) + '审';
|
|
|
await ctx.service.stage.defaultUpdate({ id: stage.id, final_auditor_str });
|
|
|
@@ -123,7 +156,7 @@ module.exports = app => {
|
|
|
ctx.body = { code: -1, msg: '协同数据已确认,如需修改,请撤销上报或重新审批', data: null };
|
|
|
return;
|
|
|
}
|
|
|
- if (ctx.stage.status !== audit.stage.status.checking && ctx.stage.status !== audit.stage.status.checkNoPre) {
|
|
|
+ if (ctx.stage.status !== auditConsts.stage.status.checking && ctx.stage.status !== auditConsts.stage.status.checkNoPre) {
|
|
|
ctx.body = { code: -1, msg: '当前期数据有误', data: null };
|
|
|
return;
|
|
|
}
|
|
|
@@ -151,4 +184,4 @@ module.exports = app => {
|
|
|
}
|
|
|
|
|
|
return WeappMeasureController;
|
|
|
-};
|
|
|
+};
|