userRole.js
3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/**
* Created by cjl on 2018/4/23.
*/
(function () {
"user strict";
var userRoleController = function($scope,$modal,$http,$location,$interval,dialogService,railwayService){
$scope.$emit('navShow', 7);
$scope.settingShow = 7;
$scope.vm = {
account: '',
totalCount : 0,
pageNumber : 1,
pageSize : 10,
userId : ''
};
$scope.getList = function(){
railwayService.findUserRoleList($scope.vm).success(function(data){
if (data.errors == null || data.errors.length > 0) {
dialogService.tip(data.errors);
}else{
$scope.userRoleList = data.result;
$scope.vm.totalCount = data.totalCount;
}
})
};
$scope.getList();
$scope.doSearch = function(){
$scope.vm.pageNumber = 1;
$scope.getList();
};
};
var assignRoleController = function($scope,$modal,$http,$location,$interval,dialogService,railwayService,toolsService){
$scope.$emit('navShow', 7);
$scope.settingShow = 7;
var id = toolsService.parameter("id", $location.absUrl());
$scope.vm = {
id: '',
account: '',
roleId: '',
roleName: ''
};
//查找权限
$scope.permissionOptions = {
pageNumber: 1,
pageSize: 10,
methodName: "getRoleList"
};
$scope.permission = {
name: '无印良品1',
id: '1'
};
$scope.user = {};
$scope.permission = {};
$scope.getUserAndPermission = function(){
railwayService.findUserRoleList($scope.vm).success(function(data){
if (data.errors == null || data.errors.length > 0) {
dialogService.tip(data.errors);
}else{
$scope.user = data.result.user;
$scope.permission = data.result.permission;
}
})
};
// 获取当前用户的权限信息
$scope.getUserAndPermission();
$scope.allPermission = {};
$scope.request = {};
$scope.getPermissionList = function(){
railwayService.getAllPermissionList($scope.request).success(function(data){
if (data.errors == null || data.errors.length > 0) {
dialogService.tip(data.errors);
}else{
$scope.allPermission = data.result;
}
})
};
// 获取所有权限
$scope.getPermissionList();
$scope.getPermissionList = function (item) {
var param = {
fieldList : ["name"],
value : item.data.keyword,
allList : [$scope.allPermission],
pageSize: item.data.pageSize,
pageNumber:item.data.pageNumber
};
var returnValue = $scope.foregroundPaging(param);
$scope.permissionList = returnValue.result;
$scope.permissionOptions.totalCount = returnValue.totalCount;
item.deferred.resolve({itemList:returnValue.result,totalCount:returnValue.totalCount});
};
$scope.selectPermission = function(permission){
$scope.vm.permissionName = permission.name;
$scope.vm.permissionId = permission.id;
};
$scope.doReturn = function(){
$scope.vm.pageNumber = 1;
$scope.getList();
};
};
angular.module("xn.page", ["xn.directive.form"])
.controller("UserRoleController",["$scope","$modal","$http","$interval","dialogService","RailwayService",userRoleController])
.controller("AssignRoleController",["$scope","$modal","$http","$location","$interval","dialogService","RailwayService","toolsService",assignRoleController])
})();