From 1858235eb6bd024be905d12cc8180e1e66571c67 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 6 Jul 2023 16:38:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/auth/index.js | 4 + weapp/src/pages/home/index.jsx | 101 +++++++++++++++----------- weapp/src/pages/user/index.jsx | 78 ++++++++++++-------- 3 files changed, 107 insertions(+), 76 deletions(-) diff --git a/api/app/lib/controllers/auth/index.js b/api/app/lib/controllers/auth/index.js index e77ad9b0..f2554ee0 100644 --- a/api/app/lib/controllers/auth/index.js +++ b/api/app/lib/controllers/auth/index.js @@ -90,6 +90,10 @@ async function wxLogin(ctx, next) { delete: false, }, attributes: { exclude: ['password', 'delete'] }, + include: [{ + attributes: ["resourceId", "isshow"], + model: models.UserResource + }] }); if (!userRes) { ctx.status = 400; diff --git a/weapp/src/pages/home/index.jsx b/weapp/src/pages/home/index.jsx index e6a155d2..2479777a 100644 --- a/weapp/src/pages/home/index.jsx +++ b/weapp/src/pages/home/index.jsx @@ -43,52 +43,65 @@ const Index = () => { }) } + function judgeRight (code) { + return userInfo && userInfo.userResources && userInfo.userResources.some(item => item.resourceId === code) + } + return ( - - - 巡 查 上 报 - toPatrolView('patrol') - : () => toPatrol('patrol') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 养 护 上 报 - toPatrolView('conserve') - : () => toPatrol('conserve') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 在 建 道 路 - toPatrolView('road') - : () => toPatrol('road') - }> - {isSuperAdmin ? '查看' : '填报'} - - - - - 异 常 反 馈 - toPatrolView('anomaly') - : () => toPatrol('anomaly') - }> - {isSuperAdmin ? '查看' : '填报'} - - + { + judgeRight('WXPATROLREPOR') ? + + 巡 查 上 报 + toPatrolView('patrol') + : () => toPatrol('patrol') + }> + {isSuperAdmin ? '查看' : '填报'} + + + : '' + } + { + judgeRight('WXMAINTENANCEREPORT') ? + + 养 护 上 报 + toPatrolView('conserve') + : () => toPatrol('conserve') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } + { + judgeRight('WXBUILDINGROAD') ? + + 在 建 道 路 + toPatrolView('road') + : () => toPatrol('road') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } + { + judgeRight('WXFEEDBACKMANAGE') ? + + 异 常 反 馈 + toPatrolView('anomaly') + : () => toPatrol('anomaly') + }> + {isSuperAdmin ? '查看' : '填报'} + + : '' + } {/* { isSuperAdmin && diff --git a/weapp/src/pages/user/index.jsx b/weapp/src/pages/user/index.jsx index 83c5c9c2..5472a55a 100644 --- a/weapp/src/pages/user/index.jsx +++ b/weapp/src/pages/user/index.jsx @@ -52,6 +52,10 @@ const Index = ({ ...props }) => { }) } + function judgeRight (code) { + return userInfo && userInfo.userResources && userInfo.userResources.some(item => item.resourceId === code) + } + return ( @@ -64,38 +68,48 @@ const Index = ({ ...props }) => { - toPatrolReport('patrol') : () => toMyReport('patrol')}> - - - {isSuperAdmin ? '巡查上报' : '巡查上报'} - - - - - toPatrolReport('conserve') : () => toMyReport('conserve')}> - - - {isSuperAdmin ? '养护上报' : '养护上报'} - - - - - toPatrolReport('road') : () => toMyReport('road')}> - - - {isSuperAdmin ? '在建道路上报' : '在建道路'} - - - - - toPatrolReport('anomaly') : () => toMyReport('anomaly')}> - - - {isSuperAdmin ? '异常反馈上报' : '异常反馈'} - - - - + { + judgeRight('WXPATROLREPOR') ? + toPatrolReport('patrol') : () => toMyReport('patrol')}> + + + {isSuperAdmin ? '巡查上报' : '巡查上报'} + + + : '' + } + { + judgeRight('WXMAINTENANCEREPORT') ? + toPatrolReport('conserve') : () => toMyReport('conserve')}> + + + {isSuperAdmin ? '养护上报' : '养护上报'} + + + + : '' + } + { + judgeRight('WXBUILDINGROAD') ? + toPatrolReport('road') : () => toMyReport('road')}> + + + {isSuperAdmin ? '在建道路上报' : '在建道路'} + + + : '' + } + { + judgeRight('WXFEEDBACKMANAGE') ? + toPatrolReport('anomaly') : () => toMyReport('anomaly')}> + + + {isSuperAdmin ? '异常反馈上报' : '异常反馈'} + + + + : '' + } 修改密码