|
@@ -69,22 +69,48 @@ module.exports = app => {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- async doCheckStage(stage, force = false) {
|
|
|
+ async loadStageUser(stage) {
|
|
|
const status = auditConst.status;
|
|
|
+ const accountId = this.ctx.session.sessionUser.accountId;
|
|
|
+
|
|
|
stage.auditors = await this.ctx.service.stageAudit.getAuditors(stage.id, stage.times);
|
|
|
stage.curAuditor = await this.ctx.service.stageAudit.getCurAuditor(stage.id, stage.times);
|
|
|
|
|
|
- const accountId = this.ctx.session.sessionUser.accountId,
|
|
|
- auditorIds = this._.map(stage.auditors, 'aid'),
|
|
|
- shareIds = [];
|
|
|
+ stage.assists = await this.service.stageAuditAss.getData(stage);
|
|
|
+ stage.userAssists = stage.assists.filter(x => { return x.user_id === stage.user_id; }); // 原报协同人
|
|
|
+ stage.auditAssists = stage.assists.filter(x => { return x.user_id !== stage.user_id; }); // 审批协同人
|
|
|
+ stage.relaAssists = stage.assists.filter(x => { return x.user_id === accountId });
|
|
|
+ stage.auditorIds = this._.map(stage.auditors, 'aid');
|
|
|
+ stage.userAssistIds = this._.map(stage.userAssists, 'ass_user_id');
|
|
|
+ stage.auditAssistIds = this._.map(stage.auditAssists, 'ass_user_id');
|
|
|
+ stage.users = stage.status === status.uncheck
|
|
|
+ ? [stage.user_id, ...stage.userAssistIds]
|
|
|
+ : [stage.user_id, ...stage.userAssistIds, ...stage.auditorIds, ...stage.auditAssistIds];
|
|
|
+ }
|
|
|
+
|
|
|
+ async doCheckStage(stage, force = false) {
|
|
|
+ const status = auditConst.status;
|
|
|
+ await this.loadStageUser(stage);
|
|
|
+
|
|
|
+ const accountId = this.ctx.session.sessionUser.accountId, shareIds = [];
|
|
|
+ if (stage.status === status.uncheck || stage.status === status.checkNo) {
|
|
|
+ stage.readOnly = accountId !== stage.user_id && stage.userAssistIds.indexOf(accountId) < 0;
|
|
|
+ if (!stage.readOnly) stage.assist = stage.userAssists.find(x => { return x.ass_user_id === accountId; });
|
|
|
+ } else if (stage.status === status.checked) {
|
|
|
+ stage.readOnly = true;
|
|
|
+ } else {
|
|
|
+ const ass = stage.auditAssists.find(x => { return x.user_id === stage.curAuditor.aid && x.ass_user_id === accountId; });
|
|
|
+ stage.readOnly = stage.curAuditor.aid !== accountId && !ass;
|
|
|
+ if (!stage.readOnly) stage.assist = ass;
|
|
|
+ }
|
|
|
+ if (stage.readOnly) {
|
|
|
+ stage.assist = accountId === stage.user_id || auditorIds.indexOf(accountId) >= 0
|
|
|
+ ? null
|
|
|
+ : stage.assists.find(x => { return x.ass_user_id === accountId});
|
|
|
+ }
|
|
|
const isTenderTourist = await this.service.tenderTourist.getDataByCondition({ tid: stage.tid, user_id: accountId });
|
|
|
const permission = this.ctx.session.sessionUser.permission;
|
|
|
- if (accountId === stage.user_id) { // 原报
|
|
|
- if (stage.curAuditor) {
|
|
|
- stage.readOnly = stage.curAuditor.aid !== accountId;
|
|
|
- } else {
|
|
|
- stage.readOnly = stage.status !== status.uncheck && stage.status !== status.checkNo;
|
|
|
- }
|
|
|
+ if (accountId === stage.user_id || stage.userAssistIds.indexOf(accountId) >= 0) { // 原报
|
|
|
stage.curTimes = stage.times;
|
|
|
if (stage.status === status.uncheck || stage.status === status.checkNo) {
|
|
|
stage.curOrder = 0;
|
|
@@ -93,6 +119,7 @@ module.exports = app => {
|
|
|
} else {
|
|
|
stage.curOrder = stage.curAuditor.aid === accountId ? stage.curAuditor.order : stage.curAuditor.order - 1;
|
|
|
}
|
|
|
+ stage.filePermission = true;
|
|
|
} else if (!!isTenderTourist || force) { // 游客
|
|
|
stage.readOnly = true;
|
|
|
stage.curTimes = stage.times;
|
|
@@ -103,10 +130,8 @@ module.exports = app => {
|
|
|
} else {
|
|
|
stage.curOrder = stage.curAuditor.order;
|
|
|
}
|
|
|
- } else if (auditorIds.indexOf(accountId) !== -1) { // 审批人
|
|
|
- if (stage.status === status.uncheck) {
|
|
|
- throw '您无权查看该数据';
|
|
|
- }
|
|
|
+ } else if (stage.auditorIds.indexOf(accountId) >= 0 || stage.auditAssistIds.indexOf(accountId) >= 0) { // 审批人
|
|
|
+ if (stage.status === status.uncheck) throw '您无权查看该数据';
|
|
|
stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
|
|
|
if (stage.status === status.checked) {
|
|
|
stage.curOrder = this._.max(this._.map(stage.auditors, 'order'));
|
|
@@ -118,7 +143,7 @@ module.exports = app => {
|
|
|
} else {
|
|
|
stage.curOrder = accountId === stage.curAuditor.aid ? stage.curAuditor.order : stage.curAuditor.order - 1;
|
|
|
}
|
|
|
- stage.readOnly = (stage.status !== status.checking && stage.status !== status.checkNoPre) || accountId !== stage.curAuditor.aid;
|
|
|
+ stage.filePermission = true;
|
|
|
} else if (shareIds.indexOf(accountId) !== -1 || (permission !== null && permission.tender !== undefined && permission.tender.indexOf('2') !== -1)) { // 分享人
|
|
|
if (stage.status === status.uncheck) {
|
|
|
throw '您无权查看该数据';
|