Просмотр исходного кода

feat: 材料调差附件上传权限调整

lanjianrong 4 лет назад
Родитель
Сommit
c0804aa998
1 измененных файлов с 15 добавлено и 10 удалено
  1. 15 10
      app/controller/material_controller.js

+ 15 - 10
app/controller/material_controller.js

@@ -843,19 +843,24 @@ module.exports = app => {
             }
         }
 
-        _checkMaterialFileCanModify(ctx) {
+        async _checkMaterialFileCanModify(ctx) {
             // 检查登录用户,是否可操作
             const accountId = ctx.session.sessionUser.accountId;
-            if (!ctx.material.curAuditor) {
-                if (ctx.material.status === auditConst.status.uncheck || ctx.material.status === auditConst.status.checkNo && accountId === ctx.material.user_id) {
-                    return;
-                }
-                throw '该调差期当前您无权操作';
-            } else {
-                if (ctx.material.curAuditor.aid === accountId) return;
+            const auditors = await ctx.service.materialAudit.getAuditorsWithOwner(ctx.material.id, ctx.material.times);
+            // console.log(auditors);
+
+            if (auditors.findIndex(item => item.aid === accountId) === -1) {
                 throw '该调差期当前您无权操作';
             }
-
+            // if (!ctx.material.curAuditor) {
+            //     if (ctx.material.status === auditConst.status.uncheck || ctx.material.status === auditConst.status.checkNo && accountId === ctx.material.user_id) {
+            //         return;
+            //     }
+            //     throw '该调差期当前您无权操作';
+            // } else {
+            //     if (ctx.material.curAuditor.aid === accountId) return;
+            //     throw '该调差期当前您无权操作';
+            // }
         }
         /**
          * 上传附件
@@ -864,7 +869,7 @@ module.exports = app => {
         async upload(ctx) {
             let stream;
             try {
-                this._checkMaterialFileCanModify(ctx);
+                await this._checkMaterialFileCanModify(ctx);
                 const parts = this.ctx.multipart({
                     autoFields: true,
                 });