fix check has role

master
luoyang 6 years ago
parent a9a74e58cf
commit 005a33d84e

@ -281,14 +281,14 @@ margin-bottom: 10%;"/>
<ul class="sidebar-menu" data-widget="tree"> <ul class="sidebar-menu" data-widget="tree">
<li ui-sref-active="active" ng-if="'dashboard'|withModule"> <li ui-sref-active="active" ng-if="roleNow!=null && 'dashboard'|withModule">
<a ui-sref="dashboard"> <a ui-sref="dashboard">
<i class="fa fa-dashboard"></i> <i class="fa fa-dashboard"></i>
<span>控制台|Dashboard</span> <span>控制台|Dashboard</span>
</a> </a>
</li> </li>
<li class="treeview" ng-if="roleNow!='administrator' && roleNow!='developer' && roleNow!='sitemanager'"> <li class="treeview" ng-if="roleNow!=null && roleNow!='administrator' && roleNow!='developer' && roleNow!='sitemanager'">
<a href="javascript:;"> <a href="javascript:;">
<i class="fa fa-sitemap"></i> <i class="fa fa-sitemap"></i>
<span>商户管理|Partner Manage</span> <span>商户管理|Partner Manage</span>
@ -322,7 +322,7 @@ margin-bottom: 10%;"/>
</ul> </ul>
</li> </li>
<li class="treeview" ng-if="roleNow!='administrator' && roleNow!='developer' && roleNow!='sitemanager'"> <li class="treeview" ng-if="roleNow!=null && roleNow!='administrator' && roleNow!='developer' && roleNow!='sitemanager'">
<a href="javascript:;"> <a href="javascript:;">
<i class="fa fa-list-alt"></i> <i class="fa fa-list-alt"></i>
<span>交易管理|Transaction</span> <span>交易管理|Transaction</span>
@ -691,7 +691,7 @@ margin-bottom: 10%;"/>
</ul> </ul>
</li> </li>
<li class="treeview" ng-if="(role=='salesmanager') || (role=='director')"> <li class="treeview" ng-if="(roleNow=='salesmanager') || (roleNow=='director')">
<a href="javascript:;"> <a href="javascript:;">
<i class="fa fa-tv"></i> <i class="fa fa-tv"></i>
<span>合伙人管理</span> <span>合伙人管理</span>

@ -147,6 +147,7 @@ margin-bottom: 10%;"/>
<b>RoyalPay</b> <b>RoyalPay</b>
<b>|</b> <b>|</b>
<b>{{roleNow}}</b> <b>{{roleNow}}</b>
</span> </span>
</a> </a>
<a ui-sref="home" ng-click="headerCopyDisplay()" class="logo logo-yedian shine" ng-if="currentUser.org"> <a ui-sref="home" ng-click="headerCopyDisplay()" class="logo logo-yedian shine" ng-if="currentUser.org">
@ -157,6 +158,9 @@ margin-bottom: 10%;"/>
ng-bind="currentUser.org.name"></b><b>|</b> ng-bind="currentUser.org.name"></b><b>|</b>
<b>{{roleNow}}</b></span> <b>{{roleNow}}</b></span>
</a> </a>
<select style="height: 30px;border: 0;text-align: center;text-align-last:center;" ng-model="roleName" ng-change="changeRole(roleName)">
<option ng-repeat="x in rolelist" value="{{x.value}}">{{x.module}}</option>
</select>
<ul class="navbar-header"> <ul class="navbar-header">
<li ui-sref-active="active" style="border-bottom-left-radius: 5px;border-top-left-radius: 5px;"> <li ui-sref-active="active" style="border-bottom-left-radius: 5px;border-top-left-radius: 5px;">
<a ui-sref="dashboard" role="button">Dashboard</a> <a ui-sref="dashboard" role="button">Dashboard</a>

@ -202,6 +202,48 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
}); });
} }
function hasRole() {
var rolenum;
switch (sessionStorage.getItem('role')) {
case "administrator":
rolenum = 1;
break;
case "bduser":
rolenum = 4;
break;
case "salesmanager":
rolenum = 8192;
break;
case "accountant":
rolenum = 8;
break;
case "sitemanager":
rolenum = 128;
break;
case "director":
rolenum = 64;
break;
case "developer":
rolenum = 256;
break;
case "compliance":
rolenum = 2;
break;
case "riskmanager":
rolenum = 1024;
break;
default:
break;
}
if ((window.currentUser.role & rolenum) >0) {
return true;
}else {
sessionStorage.removeItem('role');
return false;
}
}
var getRoleMenulist = function (role) { var getRoleMenulist = function (role) {
var roleMenu = []; var roleMenu = [];
@ -238,7 +280,13 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
return roleMenu; return roleMenu;
}; };
$scope.role = getRoleMenulist(window.currentUser.role); $scope.role = getRoleMenulist(window.currentUser.role);
sessionStorage.setItem('role',$scope.role[0].value);
if (sessionStorage.getItem('role') == null) {
sessionStorage.setItem('role',$scope.role[0].value);
}else {
hasRole();
}
$scope.roleNow = sessionStorage.getItem('role'); $scope.roleNow = sessionStorage.getItem('role');
$scope.changeRole = function (index) { $scope.changeRole = function (index) {

@ -6,38 +6,38 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
var app = angular.module('managerMainAppv2', ['ngSanitize', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ngFileUpload']); var app = angular.module('managerMainAppv2', ['ngSanitize', 'ngAnimate', 'ngMessages', 'ui.router', 'ui.bootstrap', 'ngFileUpload']);
app.config(['$urlRouterProvider', '$httpProvider', function ($urlRouterProvider, $httpProvider) { app.config(['$urlRouterProvider', '$httpProvider', function ($urlRouterProvider, $httpProvider) {
var getRoleMenulist = function (role) { window.getRoleMenulist = function (role) {
var roleMenu = []; var roleMenu = [];
if ((role & 1) >0){ if ((role & 1) >0){
roleMenu.push("administrator"); roleMenu.push({'value':'administrator','module':'系统配置'});
} }
if ((role & 2) >0){ if ((role & 2) >0){
roleMenu.push("compliance"); roleMenu.push({'value':'compliance','module':'合规中心'});
} }
if ((role & 4) >0){ if ((role & 4) >0){
roleMenu.push("bduser"); roleMenu.push({'value':'bduser','module':"销售中心"});
} }
if ((role & 8) >0){ if ((role & 8) >0){
roleMenu.push("accountant"); roleMenu.push({'value':'accountant','module':"财务中心"});
} }
if ((role & 64) >0){ if ((role & 64) >0){
roleMenu.push("director"); roleMenu.push({'value':'director','module':"领导决策"});
} }
if ((role & 128) >0){ if ((role & 128) >0){
roleMenu.push("sitemanager"); roleMenu.push({'value':'sitemanager','module':"营销中心"});
} }
if ((role & 256) >0){ if ((role & 256) >0){
roleMenu.push("developer"); roleMenu.push({'value':'developer','module':"开发中心"});
} }
if ((role & 1024) >0){ if ((role & 1024) >0){
roleMenu.push("riskmanager"); roleMenu.push({'value':'riskmanager','module':"风控中心"});
} }
if ((role & 2048) >0){ if ((role & 2048) >0){
roleMenu.push("guest"); roleMenu.push({'value':'guest','module':"guest"});
} }
if ((role & 8192) >0){ if ((role & 8192) >0){
roleMenu.push("salesmanager"); roleMenu.push({'value':'salesmanager','module':"销管中心"});
} }
return roleMenu; return roleMenu;
}; };
@ -46,8 +46,8 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
$urlRouterProvider.otherwise(((window.currentUser.role & parseInt('100000', 2)) > 0) ? '/managers' : '/home'); $urlRouterProvider.otherwise(((window.currentUser.role & parseInt('100000', 2)) > 0) ? '/managers' : '/home');
}else { }else {
sessionStorage.setItem('roleNum','1'); sessionStorage.setItem('roleNum','1');
sessionStorage.setItem('role',getRoleMenulist(window.currentUser.role).valueOf()); sessionStorage.setItem('role',getRoleMenulist(window.currentUser.role)[0].value);
$urlRouterProvider.otherwise(((window.currentUser.role & parseInt('100000', 2)) > 0) ? '/managers' : '/menu?role=' + getRoleMenulist(window.currentUser.role).valueOf()); $urlRouterProvider.otherwise(((window.currentUser.role & parseInt('100000', 2)) > 0) ? '/managers' : '/menu');
} }
@ -61,9 +61,19 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache'; $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
$httpProvider.defaults.headers.get['Pragma'] = 'no-cache'; $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
}]); }]);
app.controller('managerIndexCtrl', ['$scope', '$rootScope', '$http', '$log', '$timeout', '$interval', '$uibModal', '$filter', 'myLoginLogView', 'commonDialog', app.controller('managerIndexCtrl', ['$scope', '$state','$rootScope', '$http', '$log', '$timeout', '$interval', '$uibModal', '$filter', 'myLoginLogView', 'commonDialog',
function ($scope, $rootScope, $http, $log, $timeout, $interval, $uibModal, $filter, myLoginLogView, commonDialog) { function ($scope, $state,$rootScope, $http, $log, $timeout, $interval, $uibModal, $filter, myLoginLogView, commonDialog) {
$scope.rolelist = window.getRoleMenulist(window.currentUser.role);
$scope.roleNow = getroleNow(); $scope.roleNow = getroleNow();
$scope.roleName = getroleNow();
$scope.changeRole = function (index) {
sessionStorage.setItem('role',index);
$scope.roleNow = getroleNow();
$state.go('listMenu',null,{
reload:true
});
};
if (sessionStorage.getItem('roleNum') =='N'){ if (sessionStorage.getItem('roleNum') =='N'){
if (window.location.hash == "" || window.location.hash == "#/home") { if (window.location.hash == "" || window.location.hash == "#/home") {
$scope.headerDisplay = false; $scope.headerDisplay = false;

@ -131,6 +131,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]); }]);
app.controller('newManagerDialogCtrl', ['$scope', '$http', function ($scope, $http) { app.controller('newManagerDialogCtrl', ['$scope', '$http', function ($scope, $http) {
$scope.params = {}; $scope.params = {};
$scope.manager = {};
if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){ if(($scope.currentUser.role & parseInt('1000000000000', 2)) > 0 && $scope.currentUser.org_id){
var params = angular.copy($scope.params); var params = angular.copy($scope.params);
params.org_id = $scope.currentUser.org_id; params.org_id = $scope.currentUser.org_id;
@ -164,6 +165,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
$scope.manager.org_id = $scope.manager.org_id2; $scope.manager.org_id = $scope.manager.org_id2;
} }
delete $scope.manager.org_id2; delete $scope.manager.org_id2;
$http.post('/sys/manager_accounts', $scope.manager).then(function () { $http.post('/sys/manager_accounts', $scope.manager).then(function () {
$scope.$close(); $scope.$close();
}, function (resp) { }, function (resp) {

@ -98,9 +98,9 @@
<label ng-if="!manager.admin && !manager.operator"> <label ng-if="!manager.admin && !manager.operator">
<input type="checkbox" ng-model="manager.bd" name="bd">BD User <input type="checkbox" ng-model="manager.bd" name="bd">BD User
</label> </label>
<label ng-if="('00001'|withRole)"> <!-- <label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="manager.orgmanager" name="orgmanager">Org Manager <input type="checkbox" ng-model="manager.orgmanager" name="orgmanager">Org Manager
</label> </label>-->
</p> </p>
</div> </div>
<!-- <div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && !manager.sitemanager && orgs!=null"> <!-- <div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && !manager.sitemanager && orgs!=null">

@ -107,13 +107,13 @@
<label ng-if="!manager.admin && !manager.operator"> <label ng-if="!manager.admin && !manager.operator">
<input type="checkbox" ng-model="manager.bd" name="bd">BD User <input type="checkbox" ng-model="manager.bd" name="bd">BD User
</label> </label>
<label ng-if="('00001'|withRole)"> <!-- <label ng-if="('00001'|withRole)">
<input type="checkbox" ng-model="manager.orgmanager" name="guest">Org Manager <input type="checkbox" ng-model="manager.orgmanager" name="guest">Org Manager
</label> </label>-->
</p> </p>
</div> </div>
<div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && orgs != null"> <div class="form-group" ng-if="('1'|withRole) && !manager.admin && !manager.operator && orgs != null && manager.bd">
<label class="control-label" for="org-select">Organization</label> <label class="control-label" for="org-select">Organization</label>
<select class="form-control" ng-model="manager.org_id" id="org-select" <select class="form-control" ng-model="manager.org_id" id="org-select"
ng-options="org.org_id as org.name for org in orgs" ng-options="org.org_id as org.name for org in orgs"

@ -6,7 +6,7 @@
</ol> </ol>
</section> </section>
<div class="content"> <div class="content">
<div class="box box-default"> <div class="box box-default" ng-if="'10000000000000'|withRole">
<div class="box-body"> <div class="box-body">
<div class="form-inline"> <div class="form-inline">
<div class="form-group"> <div class="form-group">

@ -3,7 +3,7 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
var app = angular.module('listMenuApp', ['ui.router', 'ui.bootstrap']); var app = angular.module('listMenuApp', ['ui.router', 'ui.bootstrap']);
app.config(['$stateProvider', function ($stateProvider) { app.config(['$stateProvider', function ($stateProvider) {
$stateProvider.state('listMenu', { $stateProvider.state('listMenu', {
url: '/menu?role', url: '/menu',
controller: 'listMenuCtrl', controller: 'listMenuCtrl',
templateUrl: '/static/menu/templates/main_menu.html' templateUrl: '/static/menu/templates/main_menu.html'
}).state('home', { }).state('home', {
@ -14,7 +14,50 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
}]); }]);
app.controller('listMenuCtrl', ['$scope', '$http', '$filter','$uibModal','$location', '$anchorScroll','$stateParams', function ($scope, $http,$filter, $uibModal,$location, $anchorScroll,$stateParams) { app.controller('listMenuCtrl', ['$scope', '$http', '$filter','$uibModal','$location', '$anchorScroll','$stateParams', function ($scope, $http,$filter, $uibModal,$location, $anchorScroll,$stateParams) {
$scope.role = sessionStorage.getItem('role'); function hasRole() {
var rolenum;
switch (sessionStorage.getItem('role')) {
case "administrator":
rolenum = 1;
break;
case "bduser":
rolenum = 4;
break;
case "salesmanager":
rolenum = 8192;
break;
case "accountant":
rolenum = 8;
break;
case "sitemanager":
rolenum = 128;
break;
case "director":
rolenum = 64;
break;
case "developer":
rolenum = 256;
break;
case "compliance":
rolenum = 2;
break;
case "riskmanager":
rolenum = 1024;
break;
default:
break;
}
if ((window.currentUser.role & rolenum) >0) {
return true;
}else {
sessionStorage.removeItem('role');
return false;
}
}
if (hasRole()) {
$scope.role = sessionStorage.getItem('role');
}
$scope.editRateConfig = function () { $scope.editRateConfig = function () {
$uibModal.open({ $uibModal.open({

@ -10,7 +10,7 @@
} }
.box-items { .box-items {
padding: 30px 15px 15px 15px; padding: 30px 1% 15px 1%;
cursor: pointer; cursor: pointer;
} }
@ -71,7 +71,7 @@
<div style="margin: 0 auto;display: flex;padding-top: 40px;padding-bottom:0.5%;width: 60%;min-height:626px;flex-wrap:wrap"> <div style="margin: 0 auto;display: flex;padding-top: 40px;padding-bottom:0.5%;width: 60%;min-height:626px;flex-wrap:wrap">
<div class="box-items" ng-if="'100'|withRole"> <div class="box-items" ng-if="'100'|withRole">
<a ng-click="headerShow('bduser')" ui-sref="listMenu({role:'bduser'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('bduser')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_1.png"> <img src="/static/images/manage/menu_1.png">
</div> </div>
@ -80,7 +80,7 @@
</div> </div>
<div class="box-items" ng-if="'10000000000'|withRole"> <div class="box-items" ng-if="'10000000000'|withRole">
<a ng-click="headerShow('riskmanager')" ui-sref="listMenu({role:'riskmanager'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('riskmanager')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_2.png"> <img src="/static/images/manage/menu_2.png">
</div> </div>
@ -89,7 +89,7 @@
</div> </div>
<div class="box-items" ng-if="'10'|withRole"> <div class="box-items" ng-if="'10'|withRole">
<a ng-click="headerShow('compliance')" ui-sref="listMenu({role:'compliance'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('compliance')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_3.png"> <img src="/static/images/manage/menu_3.png">
</div> </div>
@ -98,7 +98,7 @@
</div> </div>
<div class="box-items" ng-if="'1000'|withRole"> <div class="box-items" ng-if="'1000'|withRole">
<a ng-click="headerShow('accountant')" ui-sref="listMenu({role:'accountant'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('accountant')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_4.png"> <img src="/static/images/manage/menu_4.png">
</div> </div>
@ -107,7 +107,7 @@
</div> </div>
<div class="box-items" ng-if="'10000000000000'|withRole"> <div class="box-items" ng-if="'10000000000000'|withRole">
<a ng-click="headerShow('salesmanager')" ui-sref="listMenu({role:'salesmanager'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('salesmanager')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_5.png"> <img src="/static/images/manage/menu_5.png">
</div> </div>
@ -116,7 +116,7 @@
</div> </div>
<div class="box-items" ng-if="'10000000'|withRole"> <div class="box-items" ng-if="'10000000'|withRole">
<a ng-click="headerShow('sitemanager')" ui-sref="listMenu({role:'sitemanager'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('sitemanager')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_6.png"> <img src="/static/images/manage/menu_6.png">
</div> </div>
@ -125,7 +125,7 @@
</div> </div>
<div class="box-items" ng-if="'1000000'|withRole"> <div class="box-items" ng-if="'1000000'|withRole">
<a ng-click="headerShow('director')" ui-sref="listMenu({role:'director'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('director')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_7.png"> <img src="/static/images/manage/menu_7.png">
</div> </div>
@ -134,7 +134,7 @@
</div> </div>
<div class="box-items" ng-if="'1'|withRole"> <div class="box-items" ng-if="'1'|withRole">
<a ng-click="headerShow('administrator')" ui-sref="listMenu({role:'administrator'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('administrator')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_8.png"> <img src="/static/images/manage/menu_8.png">
</div> </div>
@ -143,7 +143,7 @@
</div> </div>
<div class="box-items" ng-if="'100000000'|withRole"> <div class="box-items" ng-if="'100000000'|withRole">
<a ng-click="headerShow('developer')" ui-sref="listMenu({role:'developer'})" ui-sref-opts="{reload:true}"> <a ng-click="headerShow('developer')" ui-sref="listMenu()" ui-sref-opts="{reload:true}">
<div class="boxs"> <div class="boxs">
<img src="/static/images/manage/menu_9.png"> <img src="/static/images/manage/menu_9.png">
</div> </div>
@ -152,7 +152,7 @@
</div> </div>
<!--<div class="box-items" ng-if="'1000000'|withRole">--> <!--<div class="box-items" ng-if="'1000000'|withRole">-->
<!--<a ng-click="headerShow()" ui-sref="listMenu({role:'datacontent'})" ui-sref-opts="{reload:true}">--> <!--<a ng-click="headerShow()" ui-sref="listMenu()" ui-sref-opts="{reload:true}">-->
<!--<div class="boxs">--> <!--<div class="boxs">-->
<!--<img src="/static/images/manage/menu_10.png">--> <!--<img src="/static/images/manage/menu_10.png">-->
<!--</div>--> <!--</div>-->

@ -32,7 +32,7 @@
</div> </div>
</div> </div>
--> <a role="button" style="float: right;line-height: 46px" ui-sref="home" ng-click="headerCopyDisplay()"><i class="fa fa-reply"></i> 返回</a> --> <a role="button" style="float: right;line-height: 46px" ui-sref="home" ng-click="headerCopyDisplay()"><i class="fa fa-reply"></i> 返回</a>
<div class="list-group" ng-if="role!='administrator' && role!='developer' && role!='sitemanager'"> <div class="list-group" ng-if="role!=null && role!='administrator' && role!='developer' && role!='sitemanager'">
<div class="row"> <div class="row">
<div class="col-sm-2 col-lg-2 col-xs-6" id="partners"> <div class="col-sm-2 col-lg-2 col-xs-6" id="partners">
<div class="description-block"> <div class="description-block">
@ -103,7 +103,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="list-group" ng-if="role!='administrator' && role!='developer' && role!='sitemanager'"> <div class="list-group" ng-if="role!=null && role!='administrator' && role!='developer' && role!='sitemanager'">
<div class="row" > <div class="row" >
<div class="col-sm-2 col-lg-2 col-xs-6" id="transaction"> <div class="col-sm-2 col-lg-2 col-xs-6" id="transaction">
<div class="description-block"> <div class="description-block">

Loading…
Cancel
Save