Browse Source

权限 角色搜索 调整

wangdy 8 years ago
parent
commit
2a4fa5287c

+ 12 - 0
src/main/java/com/uas/platform/b2c/common/account/controller/RoleController.java

@@ -13,6 +13,7 @@ import org.springframework.ui.ModelMap;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * 账户管理--角色
@@ -40,6 +41,17 @@ public class RoleController {
         return roleService.findAll();
     }
 
+    /**
+     * 取当前企业已经存在的人员角色
+     *
+     * @return
+     */
+    @RequestMapping(value = "/existRole", method = RequestMethod.GET)
+    @ResponseBody
+    public Set<Role> getRolesByExist() {
+        return roleService.getRolesByExist();
+    }
+
     /**
      * 添加自定义角色
      *

+ 8 - 0
src/main/java/com/uas/platform/b2c/common/account/service/RoleService.java

@@ -4,6 +4,7 @@ import com.uas.platform.b2c.common.account.model.Role;
 import org.springframework.ui.ModelMap;
 
 import java.util.List;
+import java.util.Set;
 
 
 public interface RoleService {
@@ -15,6 +16,13 @@ public interface RoleService {
      */
     public List<Role> findAll();
 
+    /**
+     * 取当前企业已经存在的人员角色
+     *
+     * @return
+     */
+    public Set<Role> getRolesByExist();
+
     /**
      * 查找指定企业下所有角色
      *

+ 18 - 0
src/main/java/com/uas/platform/b2c/common/account/service/impl/RoleServiceImpl.java

@@ -15,7 +15,10 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
 
+import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 
 
 @Service
@@ -35,6 +38,21 @@ public class RoleServiceImpl implements RoleService {
         return findByEnterprise(SystemSession.getUser().getEnterprise().getUu());
     }
 
+    @Override
+    public Set<Role> getRolesByExist() {
+        Long enuu = SystemSession.getUser().getEnterprise().getUu();
+        List<User> users = userDao.findByEnUU(enuu);
+        Set<Role> roles = new HashSet<>();
+        for (User u : users){
+            for (Role role : u.getRoles()){
+                if (role.getEnUU().equals(enuu)){
+                    roles.add(role);
+                }
+            }
+        }
+        return roles;
+    }
+
     @Override
     public List<Role> findByEnterprise(long enUU) {
         List<Role> roles = roleDao.findByEnUU(enUU);

+ 1 - 0
src/main/java/com/uas/platform/b2c/common/account/v2/service/impl/UserServiceImpl.java

@@ -49,6 +49,7 @@ public class UserServiceImpl implements UserService {
         if (null == u) {
             u = new com.uas.platform.b2c.common.account.model.User();
         }
+
         oneSave(user,u);
 //        if (null == user.getDialectUID() || "".equals(user.getDialectUID())){
 //            List<com.uas.platform.b2c.common.account.model.User> users = userDao.findUserByUserTel(user.getUid());

+ 128 - 122
src/main/webapp/resources/js/common/query/user.js

@@ -1,114 +1,114 @@
-define([ 'angular', 'ui-bootstrap', 'ngResource' ], function(angular) {
-	'use strict';
-	angular.module('common.query.user', ['ui.bootstrap', 'ngResource']).factory('UserService', ['$modal', function($modal){
-		return {
-			open: function(enterprise) {
-				var modalInstance = $modal.open({
-					templateUrl : 'static/view/common/query/user.html',
-					controller : 'UserQueryCtrl',
-					backdrop : "static",
-					resolve : {
-						enterprise : function() {
-							return enterprise;
-						}
-					},
-					windowClass : 'modal-large'
-				});
-				return modalInstance;
-			}
-		};
-	}]).controller('UserQueryCtrl', ['$scope', '$modalInstance', '$http', '$filter', 'enterprise', 'ngTableParams', function($scope, $modalInstance, $http, $filter, enterprise, ngTableParams){
-		$scope.enterprise = enterprise;
-		
-		$scope.tableParams = new ngTableParams({
-			page : 1,
-			total: 1, 
-			count : 500,
-			sorting: {
+define(['angular', 'ui-bootstrap', 'ngResource'], function (angular) {
+    'use strict';
+    angular.module('common.query.user', ['ui.bootstrap', 'ngResource']).factory('UserService', ['$modal', function ($modal) {
+        return {
+            open: function (enterprise) {
+                var modalInstance = $modal.open({
+                    templateUrl: 'static/view/common/query/user.html',
+                    controller: 'UserQueryCtrl',
+                    backdrop: "static",
+                    resolve: {
+                        enterprise: function () {
+                            return enterprise;
+                        }
+                    },
+                    windowClass: 'modal-large'
+                });
+                return modalInstance;
+            }
+        };
+    }]).controller('UserQueryCtrl', ['$scope', '$modalInstance', '$http', '$filter', 'enterprise', 'ngTableParams', function ($scope, $modalInstance, $http, $filter, enterprise, ngTableParams) {
+        $scope.enterprise = enterprise;
+
+        $scope.tableParams = new ngTableParams({
+            page: 1,
+            total: 1,
+            count: 500,
+            sorting: {
                 'userName': 'asc'
             },
             filter: {
-            	'enabled': 1
+                'enabled': 1
             }
-		}, {
-			groupBy : 'role',
-			counts: [],
-			getData : function($defer, params) {
-				$http.get('user/' + enterprise.uu + '/users').success(function(users){
-					if(users) {
-						var data = params.filter() ? $filter('filter')(users, params.filter()) : users;
-						params.total(data.length);
-						data = params.sorting() ? $filter('orderBy')(data, $scope.tableParams.orderBy()) : data;
+        }, {
+            groupBy: 'role',
+            counts: [],
+            getData: function ($defer, params) {
+                $http.get('user/' + enterprise.uu + '/users').success(function (users) {
+                    if (users) {
+                        var data = params.filter() ? $filter('filter')(users, params.filter()) : users;
+                        params.total(data.length);
+                        data = params.sorting() ? $filter('orderBy')(data, $scope.tableParams.orderBy()) : data;
                         $defer.resolve(data.slice((params.page() - 1) * params.count(), params.page() * params.count()));
-					}
-				}).error(function(){
-					
-				});
-			}
-		});
+                    }
+                }).error(function () {
 
-		// 关闭模态窗
-		$scope.close = function() {
-			$modalInstance.close();
-		};
-		// 选中user
-		$scope.select = function(user) {
-			$modalInstance.close(angular.copy(user));
-		};
-	}]).factory('User', ['$resource', function($resource) {
-		return $resource('basic/user/personal', {}, {
-			postImageUrl: {
-				url : 'basic/user/setImageUrl',
-				method : 'POST'
-			},
-			getUser: {
-				method : 'GET'
-			},
-			getUserByUU: {
-				url: 'basic/user/getUserByUU',
-				method : 'GET'
-			},
-			checkPassword: {
-				url: 'basic/user/checkPassword',
-				method: 'GET'
-			},
-			updatePassword: {
-				url: 'basic/user/updatePassword',
-				method: 'POST'
-			},
-			update: {
-				url: 'basic/user',
-				method: 'PUT'
-			},
+                });
+            }
+        });
+
+        // 关闭模态窗
+        $scope.close = function () {
+            $modalInstance.close();
+        };
+        // 选中user
+        $scope.select = function (user) {
+            $modalInstance.close(angular.copy(user));
+        };
+    }]).factory('User', ['$resource', function ($resource) {
+        return $resource('basic/user/personal', {}, {
+            postImageUrl: {
+                url: 'basic/user/setImageUrl',
+                method: 'POST'
+            },
+            getUser: {
+                method: 'GET'
+            },
+            getUserByUU: {
+                url: 'basic/user/getUserByUU',
+                method: 'GET'
+            },
+            checkPassword: {
+                url: 'basic/user/checkPassword',
+                method: 'GET'
+            },
+            updatePassword: {
+                url: 'basic/user/updatePassword',
+                method: 'POST'
+            },
+            update: {
+                url: 'basic/user',
+                method: 'PUT'
+            },
             checkUserEmail: {
                 url: 'basic/user/checkUserEmail',
                 method: 'GET'
             },
-            sendCheckCode:{
+            sendCheckCode: {
                 url: 'basic/user/sendCheckCode',
                 method: 'GET'
             },
-            emailEnable:{
+            emailEnable: {
                 url: 'basic/user/emailEnable',
                 method: 'GET'
-			},
-            validCheckCode:{
+            },
+            validCheckCode: {
                 url: 'basic/user/validCheckCode',
                 method: 'GET'
             },
-            updateUserEmail:{
+            updateUserEmail: {
                 url: 'basic/user/updateUserEmail',
                 method: 'POST'
-			},
-			checkUserTel:{
+            },
+            checkUserTel: {
                 url: 'basic/user/checkUserTel',
                 method: 'GET'
-			},
-            telEnable:{
+            },
+            telEnable: {
                 url: 'basic/user/telEnable',
                 method: 'GET'
             },
-            getPageToken:{
+            getPageToken: {
                 url: 'basic/user/getPageToken',
                 method: 'GET'
             },
@@ -116,55 +116,61 @@ define([ 'angular', 'ui-bootstrap', 'ngResource' ], function(angular) {
                 url: 'basic/user/sendTelCheckCode',
                 method: 'GET'
             },
-            validTelCheckCode:{
+            validTelCheckCode: {
                 url: 'basic/user/validTelCheckCode',
                 method: 'GET'
-			},
-            updateUserTel:{
+            },
+            updateUserTel: {
                 url: 'basic/user/updateUserTel',
                 method: 'POST'
             },
-            checkHaveUserPay:{
+            checkHaveUserPay: {
                 url: 'basic/user/checkHaveUserPay',
                 method: 'GET'
-			},
-            checkUserPay:{
+            },
+            checkUserPay: {
                 url: 'basic/user/checkUserPay',
                 method: 'GET'
-			},
-            updateUserPay:{
+            },
+            updateUserPay: {
                 url: 'basic/user/updateUserPay',
                 method: 'POST'
-			},
-            updateUserQuestion:{
+            },
+            updateUserQuestion: {
                 url: 'basic/user/updateUserQuestion',
-            	  method: 'POST'
-			},
-            getUserQuestion:{
-							 url: 'basic/user/getUserQuestion',
+                method: 'POST'
+            },
+            getUserQuestion: {
+                url: 'basic/user/getUserQuestion',
                 method: 'GET',
-              isArray : true
-						},
-      updateRealAuth:{
-        url: 'basic/user/updateRealAuth',
-        method: 'POST'
-			},
-      getPageStatusRealAuth:{
-        url: 'basic/user/getPageStatusRealAuth',
-        method: 'GET'
-			},
-			updateIdEnable:{
-        url: 'basic/user/updateIdEnable',
-        method: 'POST'
-			},
-			getAllSecQuestion:{
-				url:'user/secQuestion/getPageInfo',
-				method:'GET'
-			}
-		});
-	}]).factory('AccountResource', ['$resource', function($resource) {
+                isArray: true
+            },
+            updateRealAuth: {
+                url: 'basic/user/updateRealAuth',
+                method: 'POST'
+            },
+            getPageStatusRealAuth: {
+                url: 'basic/user/getPageStatusRealAuth',
+                method: 'GET'
+            },
+            updateIdEnable: {
+                url: 'basic/user/updateIdEnable',
+                method: 'POST'
+            },
+            getAllSecQuestion: {
+                url: 'user/secQuestion/getPageInfo',
+                method: 'GET'
+            }
+        });
+    }]).factory('AccountResource', ['$resource', function ($resource) {
         return $resource('account/resource', {});
-    }]).factory('AccountRole', ['$resource', function($resource) {
-        return $resource('account/role/:id');
+    }]).factory('AccountRole', ['$resource', function ($resource) {
+        return $resource('account/role/:id',{},{
+            getByExistRoleAndEnuu: {
+                url: 'account/role/existRole',
+                method: 'GET',
+                isArray: true
+            }
+        });
     }]);
 });

+ 9 - 6
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_account_management_ctrl.js

@@ -15,6 +15,7 @@ define(['app/app'], function (app) {
         };
         $scope.userInfo = $rootScope.userInfo;
         $scope.updateState = false;
+        $scope.filterRole = 'all';
         // 获取企业信息
         Enterprise.getEnterpriseInfo({enuu: $scope.userInfo.enterprise.uu}, function (data) {
             $scope.enterpriseInfo = data;
@@ -54,8 +55,8 @@ define(['app/app'], function (app) {
                 }
                 else {
                     param.keyword = $scope.keyword;
-                    if ($scope.filterRole !=='all'){
-                        param.roleId = $scope.filterRole;
+                    if (filterRolejs !== 1){
+                        param.roleId = filterRolejs;
                     }
                     Enterprise.findUsersByKeyword(param,function (page) {
                         if (page) {
@@ -71,10 +72,12 @@ define(['app/app'], function (app) {
                 }
             }
         });
-        $scope.filterRole = 'all';
 
-        $scope.onSearch = function (keyword) {
-            if (keyword != null && keyword != '') {
+        var filterRolejs = 1;
+        $scope.onSearch = function (keyword,filterRole) {
+            filterRolejs = 1;
+            if ((keyword != null && keyword != '') || filterRole !== 'all') {
+                filterRolejs = filterRole;
                 $scope.searchMthod = true;
                 $scope.keyword = keyword;
             } else {
@@ -455,7 +458,7 @@ define(['app/app'], function (app) {
             $scope.resources = data;
         });
         var getData = function () {
-            AccountRole.query({}, function (data) {
+            AccountRole.getByExistRoleAndEnuu({}, function (data) {
                 var defaults = [], custom = [];
                 angular.forEach(data, function (d) {
                     if (d.isdefault == 1)

+ 1 - 2
src/main/webapp/resources/view/vendor/forstore/vendor_account_management.html

@@ -970,8 +970,7 @@
                 <div class="searchUser-group">
                     <span ng-click="onSearch(keyword,filterRole)">搜索</span>
 
-                    <input type="text"  ng-model="keyword"
-                           ng-search="onSearch(keyword)" placeholder="输入人员姓名、电话号码、邮箱或UU号进行搜索"/>
+                    <input type="text" ng-model="keyword" placeholder="输入人员姓名、电话号码、邮箱或UU号进行搜索"/>
                     <!--<input type="text">-->
                     <div>
                         <select ng-model="filterRole" >