yangc 7 лет назад
Родитель
Сommit
3234322369

+ 32 - 0
src/main/webapp/resources/js/common/b2bServices.js

@@ -3098,4 +3098,36 @@ define([ 'angular', 'common/services', 'common/utils', 'big'], function(angular,
             }
           });
         }])
+        .factory('B2bAccountRole', ['$resource', 'BaseService', function($resource, BaseService) {
+        		var b2bUrl = BaseService.getB2bUrl();
+        		return $resource(b2bUrl + '/account/role/:id', {}, {
+        			// 确认修改
+        			save: {
+        				url: b2bUrl + '/account/role',
+        				method: 'POST'
+        			},
+        			// 确认删除
+                    remove: {
+        				url: b2bUrl + '/account/role/:id',
+        				method: 'DELETE'
+        			},
+        			// 恢复默认
+                    recover: {
+                        url: b2bUrl + '/account/role/recover/:roleId',
+                        method: 'POST'
+                    },
+                    // 获取默认权限
+                    getDefaultRole: {
+                        url: b2bUrl + '/account/role/default/:roleId',
+                        method: 'GET'
+                    },
+        			updateDefault: {
+        				url: b2bUrl + '/account/role/updateDefault',
+        				method: 'POST'
+        			}
+        		});
+        	}])
+        .factory('B2bAccountResource', ['$resource', 'BaseService', function($resource, BaseService) {
+            return $resource(BaseService.getB2bUrl() + '/account/resource', {});
+        }])
 });

+ 60 - 26
src/main/webapp/resources/js/sso/controllers/rolePermissionCtrl.js

@@ -4,9 +4,10 @@
  */
 define(['app/app'], function (app) {
     "use strict";
-    app.register.controller('rolePermissionCtrl', ['$scope', '$rootScope', 'Enterprise', 'User', 'toaster', '$modal', 'BaseService', 'ngTableParams', '$http', 'AuthenticationService', '$stateParams','AccountResource','AccountRole', 'Authority', function ($scope, $rootScope, Enterprise, User, toaster, $modal, BaseService, ngTableParams, $http, AuthenticationService, $stateParams, AccountResource, AccountRole, Authority) {
+    app.register.controller('rolePermissionCtrl', ['$scope', '$rootScope', 'Enterprise', 'User', 'toaster', '$modal', 'BaseService', 'ngTableParams', '$http', 'AuthenticationService', '$stateParams','AccountResource','AccountRole', 'Authority', 'B2bAccountRole', 'B2bAccountUser', function ($scope, $rootScope, Enterprise, User, toaster, $modal, BaseService, ngTableParams, $http, AuthenticationService, $stateParams, AccountResource, AccountRole, Authority, B2bAccountRole, B2bAccountUser) {
         $rootScope.active = 'sso_permission';
         document.title = '角色权限';
+        $scope.tab = 'b2c';
         $scope.addingUser = false;
         $scope.setAddingUser = function (status) {
             $scope.addingUser = status;
@@ -363,30 +364,50 @@ define(['app/app'], function (app) {
             $scope.resources = data;
         });
         var getData = function () {
-            AccountRole.findAll({}, function (data) {
-                var defaults = [], custom = [];
-                angular.forEach(data, function (d) {
-                    if (d.isdefault == 1)
-                        defaults.push(d);
-                    else
-                        custom.push(d);
+            if ($scope.tab == 'b2c') {
+                AccountRole.findAll({}, function (data) {
+                    var defaults = [], custom = [];
+                    angular.forEach(data, function (d) {
+                        if (d.isdefault == 1)
+                            defaults.push(d);
+                        else
+                            custom.push(d);
+                    });
+                    $scope.roles = {defaults: defaults, custom: custom};
+                },function (error) {
+                    $scope.rolesExcept = error.data;
                 });
-                $scope.roles = {defaults: defaults, custom: custom};
-            },function (error) {
-                $scope.rolesExcept = error.data;
-            });
-            AccountRole.getByExistRoleAndEnuu({}, function (data) {
-                var defaults = [], custom = [];
-                angular.forEach(data, function (d) {
-                    if (d.isdefault == 1)
-                        defaults.push(d);
-                    else
-                        custom.push(d);
+                // 这个请求不知道干嘛的
+                AccountRole.getByExistRoleAndEnuu({}, function (data) {
+                    var defaults = [], custom = [];
+                    angular.forEach(data, function (d) {
+                        if (d.isdefault == 1)
+                            defaults.push(d);
+                        else
+                            custom.push(d);
+                    });
+                    $scope.existRoles = {defaults: defaults, custom: custom};
                 });
-                $scope.existRoles = {defaults: defaults, custom: custom};
-            });
+            } else {
+                B2bAccountRole.query({}, function (data) {
+                    var defaults = [], custom = [];
+                    angular.forEach(data, function (d) {
+                        if (d.isdefault == 1)
+                            defaults.push(d);
+                        else
+                            custom.push(d);
+                    });
+                    $scope.roles = {defaults: defaults, custom: custom};
+                },function (error) {
+                    $scope.rolesExcept = error.data;
+                })
+            }
         };
         getData();
+        $scope.setTab = function (tab) {
+            $scope.tab = tab;
+            getData();
+        }
         $scope.editRole = function (role) {
             var modalInstance = $modal.open({
                 animation: true,
@@ -395,6 +416,9 @@ define(['app/app'], function (app) {
                 resolve: {
                     role: function () {
                         return role;
+                    },
+                    isB2b: function () {
+                        return $scope.tab == 'b2b';
                     }
                 }
             });
@@ -522,8 +546,8 @@ define(['app/app'], function (app) {
           };
         }]);
 
-//角色管理-编辑角色controller
-    app.register.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'BaseService', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, BaseService) {
+    //角色管理-编辑角色controller
+    app.register.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'BaseService', 'isB2b', 'B2bAccountResource', 'B2bAccountRole', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, BaseService, isB2b, B2bAccountResource, B2bAccountRole) {
         BaseService.scrollBackToTop();
         $scope.role = angular.copy(role || {});
         $scope.master = angular.copy($scope.role);
@@ -558,8 +582,18 @@ define(['app/app'], function (app) {
                 });
             }
         }
+        var getB2bResource = function () {
+            return isB2b ? {
+                AccountResource: B2bAccountResource,
+                AccountRole: B2bAccountRole
+            } : {
+                AccountResource: AccountResource,
+                AccountRole: AccountRole
+            }
+        }
+        var queryObj = getB2bResource();
 
-        AccountResource.query({}, function (data) {
+        queryObj.AccountResource.query({}, function (data) {
             if (data && data.length > 0) {
                 var rs = [];// 已分配的资源的id
                 if (role && role.resourceItems) {
@@ -714,7 +748,7 @@ define(['app/app'], function (app) {
             if (!$scope.master.color || $scope.master.color == '') {
                 $scope.master.color = parseInt(Math.random() * 5) + 1 + '';
             }
-            AccountRole.save($scope.master, function () {
+            queryObj.AccountRole.save($scope.master, function () {
                 toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加' : '修改') + '成功');
                 $modalInstance.close(true);
             }, function (response) {
@@ -723,7 +757,7 @@ define(['app/app'], function (app) {
         };
         $scope.del = function () {
             if (confirm('确定删除角色(' + $scope.role.desc + ')吗?')) {
-                AccountRole.remove({id: role.id}, function () {
+                queryObj.AccountRole.remove({id: role.id}, function () {
                     toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
                     $modalInstance.close(true);
                 }, function (response) {

+ 14 - 4
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_account_management_ctrl.js

@@ -1840,7 +1840,7 @@ define(['app/app'], function (app) {
                 };
             }]);
 //角色管理-编辑角色controller
-    app.register.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'BaseService', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, BaseService) {
+    app.register.controller('RoleEditCtrl', ['$scope', '$modalInstance', '$timeout', 'AccountResource', 'AccountRole', 'toaster', 'role', 'BaseService', 'isB2b', 'B2bAccountResource', 'B2bAccountRole', function ($scope, $modalInstance, $timeout, AccountResource, AccountRole, toaster, role, BaseService, isB2b, B2bAccountResource, B2bAccountRole) {
         BaseService.scrollBackToTop();
         $scope.role = angular.copy(role || {});
         $scope.master = angular.copy($scope.role);
@@ -1875,8 +1875,18 @@ define(['app/app'], function (app) {
                 });
             }
         }
+        var getB2bResource = function () {
+            return isB2b ? {
+                AccountResource: B2bAccountResource,
+                AccountRole: B2bAccountRole
+            } : {
+                AccountResource: AccountResource,
+                AccountRole: AccountRole
+            }
+        }
+        var queryObj = getB2bResource();
 
-        AccountResource.query({}, function (data) {
+        queryObj.AccountResource.query({}, function (data) {
             if (data && data.length > 0) {
                 var rs = [];// 已分配的资源的id
                 if (role && role.resourceItems) {
@@ -2031,7 +2041,7 @@ define(['app/app'], function (app) {
             if (!$scope.master.color || $scope.master.color == '') {
                 $scope.master.color = parseInt(Math.random() * 5) + 1 + '';
             }
-            AccountRole.save($scope.master, function () {
+            queryObj.AccountRole.save($scope.master, function () {
                 toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加' : '修改') + '成功');
                 $modalInstance.close(true);
             }, function (response) {
@@ -2040,7 +2050,7 @@ define(['app/app'], function (app) {
         };
         $scope.del = function () {
             if (confirm('确定删除角色(' + $scope.role.desc + ')吗?')) {
-                AccountRole.remove({id: role.id}, function () {
+                queryObj.AccountRole.remove({id: role.id}, function () {
                     toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
                     $modalInstance.close(true);
                 }, function (response) {

+ 6 - 1
src/main/webapp/resources/view/sso/rolePermission.html

@@ -904,9 +904,14 @@
 </style>
 <!--右侧主体部分-->
 <div class="count user_right fr" ng-click="hideList()">
+    <div class="tab_top" style="margin-bottom: 16px;">
+        <ul>
+            <li ng-class="{active: tab == 'b2c'}" ng-click="setTab('b2c')"><a href="javascript:void(0)">商城角色</a></li>
+            <li ng-class="{active: tab == 'b2b'}" ng-click="setTab('b2b')"><a href="javascript:void(0)">b2b角色</a></li>
+        </ul>
+    </div>
     <!--安全设置-->
     <div class="count_center">
-        <div class="rt_menu"><span>角色权限</span></div>
         <!-- 角色管理 -->
         <div class="count01 clearfix role-manage" >
             <p>默认角色</p>