Explorar o código

权限实时刷新

laiguoran %!s(int64=6) %!d(string=hai) anos
pai
achega
7e09ed2753
Modificáronse 2 ficheiros con 13 adicións e 8 borrados
  1. 7 2
      app/controller/tender_controller.js
  2. 6 6
      app/service/project_account.js

+ 7 - 2
app/controller/tender_controller.js

@@ -39,6 +39,9 @@ module.exports = app => {
                     t.completeStage = await this.ctx.service.stage.getLastestCompleteStage(t.id);
                 }
                 const categoryData = await this.ctx.service.category.getAllCategory(this.ctx.session.sessionProject.id);
+                // 获取用户新建标段权利
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
                 const renderData = {
                     tenderList,
                     tenderConst,
@@ -48,7 +51,7 @@ module.exports = app => {
                     measureType: tenderConst.measureType,
                     jsFiles: this.app.jsFiles.common.concat(this.jsFiles),
                     auditConst,
-                    userPermission: this.ctx.session.sessionUser.permission !== '' ? JSON.parse(this.ctx.session.sessionUser.permission) : null,
+                    userPermission,
                 };
                 await this.layout(view, renderData, modal);
             } catch (err) {
@@ -101,7 +104,9 @@ module.exports = app => {
                 const responseData = {
                     err: 0, msg: '', data: null,
                 };
-                const userPermission = ctx.session.sessionUser.permission !== '' ? JSON.parse(ctx.session.sessionUser.permission) : null;
+                // 获取用户新建标段权利
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(this.ctx.session.sessionUser.accountId);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
                 if (userPermission === null || userPermission.tender === undefined || userPermission.tender.indexOf('1') === -1) {
                     throw '当前用户没有创建标段的权限';
                 }

+ 6 - 6
app/service/project_account.js

@@ -115,8 +115,8 @@ module.exports = app => {
                 let accountData = {};
                 let projectInfo = {};
                 let projectList = [];
-                let permission = '';
-                let cooperation = 0;
+                // let permission = '';
+                // let cooperation = 0;
                 if (loginType === 2) {
                     // 查找项目数据
                     const projectData = await this.ctx.service.project.getProjectByCode(data.project.toString());
@@ -141,8 +141,8 @@ module.exports = app => {
                     }
 
                     projectList = await this.getProjectInfoByAccount(data.account);
-                    permission = accountData.permission;
-                    cooperation = accountData.cooperation;
+                    // permission = accountData.permission;
+                    // cooperation = accountData.cooperation;
 
                     // 判断密码
                     // if (accountData.is_admin === 1) {
@@ -185,8 +185,8 @@ module.exports = app => {
                         is_admin: accountData.is_admin,
                         sessionToken,
                         loginType,
-                        permission,
-                        cooperation,
+                        // permission,
+                        // cooperation,
                     };
                     this.ctx.session.sessionProject = projectInfo;
                     this.ctx.session.sessionProjectList = projectList;