Parcourir la source

解决重新审批权限bug

laiguoran il y a 5 ans
Parent
commit
561eb73577
1 fichiers modifiés avec 6 ajouts et 6 suppressions
  1. 6 6
      app/middleware/stage_check.js

+ 6 - 6
app/middleware/stage_check.js

@@ -49,6 +49,10 @@ module.exports = options => {
             stage.auditors = yield this.service.stageAudit.getAuditors(stage.id, stage.times);
             stage.curAuditor = yield this.service.stageAudit.getCurAuditor(stage.id, stage.times);
 
+            // 获取最新的期
+            stage.highOrder = yield this.service.stage.count({
+                tid: this.tender.id,
+            });
             // 权限相关
             // todo 校验权限 (标段参与人、分享)
             const accountId = this.session.sessionUser.accountId, auditorIds = _.map(stage.auditors, 'aid'), shareIds = [];
@@ -70,7 +74,6 @@ module.exports = options => {
                 if (stage.status === status.uncheck) {
                     throw '您无权查看该数据';
                 }
-                stage.readOnly = (stage.status !== status.checking && stage.status !== status.checkNoPre) || accountId !== stage.curAuditor.aid;
                 stage.curTimes = stage.status === status.checkNo ? stage.times - 1 : stage.times;
                 if (stage.status === status.checked) {
                     stage.curOrder = _.max(_.map(stage.auditors, 'order'));
@@ -82,6 +85,8 @@ module.exports = options => {
                 } 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.readOnly = stage.auditors !== undefined && stage.auditors.length !== 0 && stage.auditors[stage.auditors.length - 1].aid === accountId && stage.status === status.checked && stage.order === stage.highOrder ? false : stage.readOnly;
             } else if (shareIds.indexOf(accountId) !== -1) { // 分享人
                 if (stage.status === status.uncheck) {
                     throw '您无权查看该数据';
@@ -95,11 +100,6 @@ module.exports = options => {
 
             const lastRevise = yield this.service.ledgerRevise.getLastestRevise(this.tender.id);
             stage.revising = (lastRevise && lastRevise.status !== reviseStatus.checked) || false;
-
-            // 获取最新的期
-            stage.highOrder = yield this.service.stage.count({
-                tid: this.tender.id,
-            });
             this.stage = stage;
             yield next;
         } catch (err) {