瀏覽代碼

变更附件删除权限bug

ellisran 10 月之前
父節點
當前提交
d1300d3ece
共有 1 個文件被更改,包括 12 次插入18 次删除
  1. 12 18
      app/controller/change_controller.js

+ 12 - 18
app/controller/change_controller.js

@@ -433,9 +433,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
                 const settleBills = ctx.change.readySettle ? await ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
                 const settlePos = ctx.change.readySettle ? await ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: ctx.change.readySettle.id } }) : [];
@@ -1267,9 +1266,8 @@ module.exports = app => {
                     throw '该文件不存在';
                 }
                 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 deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = accountInfo && accountInfo.permission ? JSON.parse(accountInfo.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 if (!fileInfo.extra_upload && change.status === audit.change.status.checked && !deleteFilePermission) {
                     throw '无权限删除';
                 }
@@ -2175,9 +2173,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 // 判断并更新
                 const renderData = {
                     tender: ctx.tender,
@@ -3031,9 +3028,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const renderData = {
                     tender,
                     change: ctx.change,
@@ -3088,9 +3084,8 @@ module.exports = app => {
                 const fileList = await ctx.service.changeApplyAtt.getAllChangeApplyAtt(ctx.tender.id, ctx.change.id);
                 await this._getChangeApplyAuditViewData(ctx);
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const renderData = {
                     tender,
                     change: ctx.change,
@@ -3866,9 +3861,8 @@ module.exports = app => {
                 // 获取用户人验证手机号
                 const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
                 const auth_mobile = pa.auth_mobile;
-                const userPermission = pa !== undefined && pa.permission !== ''
-                    ? JSON.parse(pa.permission) : null;
-                const deleteFilePermission = userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1;
+                const userPermission = pa && pa.permission ? JSON.parse(pa.permission) : null;
+                const deleteFilePermission = !!(userPermission && userPermission.change !== undefined && userPermission.change.indexOf('2') !== -1);
                 const changeClass = await this._getOrUpdateClass(ctx, 'changePlan');
                 const renderData = {
                     tender,