|
@@ -4,9 +4,10 @@
|
|
|
*/
|
|
*/
|
|
|
define(['app/app'], function (app) {
|
|
define(['app/app'], function (app) {
|
|
|
"use strict";
|
|
"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';
|
|
$rootScope.active = 'sso_permission';
|
|
|
document.title = '角色权限';
|
|
document.title = '角色权限';
|
|
|
|
|
+ $scope.tab = 'b2c';
|
|
|
$scope.addingUser = false;
|
|
$scope.addingUser = false;
|
|
|
$scope.setAddingUser = function (status) {
|
|
$scope.setAddingUser = function (status) {
|
|
|
$scope.addingUser = status;
|
|
$scope.addingUser = status;
|
|
@@ -363,30 +364,50 @@ define(['app/app'], function (app) {
|
|
|
$scope.resources = data;
|
|
$scope.resources = data;
|
|
|
});
|
|
});
|
|
|
var getData = function () {
|
|
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();
|
|
getData();
|
|
|
|
|
+ $scope.setTab = function (tab) {
|
|
|
|
|
+ $scope.tab = tab;
|
|
|
|
|
+ getData();
|
|
|
|
|
+ }
|
|
|
$scope.editRole = function (role) {
|
|
$scope.editRole = function (role) {
|
|
|
var modalInstance = $modal.open({
|
|
var modalInstance = $modal.open({
|
|
|
animation: true,
|
|
animation: true,
|
|
@@ -395,6 +416,9 @@ define(['app/app'], function (app) {
|
|
|
resolve: {
|
|
resolve: {
|
|
|
role: function () {
|
|
role: function () {
|
|
|
return role;
|
|
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();
|
|
BaseService.scrollBackToTop();
|
|
|
$scope.role = angular.copy(role || {});
|
|
$scope.role = angular.copy(role || {});
|
|
|
$scope.master = angular.copy($scope.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) {
|
|
if (data && data.length > 0) {
|
|
|
var rs = [];// 已分配的资源的id
|
|
var rs = [];// 已分配的资源的id
|
|
|
if (role && role.resourceItems) {
|
|
if (role && role.resourceItems) {
|
|
@@ -714,7 +748,7 @@ define(['app/app'], function (app) {
|
|
|
if (!$scope.master.color || $scope.master.color == '') {
|
|
if (!$scope.master.color || $scope.master.color == '') {
|
|
|
$scope.master.color = parseInt(Math.random() * 5) + 1 + '';
|
|
$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 ? '添加' : '修改') + '成功');
|
|
toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 资料' + (isNew ? '添加' : '修改') + '成功');
|
|
|
$modalInstance.close(true);
|
|
$modalInstance.close(true);
|
|
|
}, function (response) {
|
|
}, function (response) {
|
|
@@ -723,7 +757,7 @@ define(['app/app'], function (app) {
|
|
|
};
|
|
};
|
|
|
$scope.del = function () {
|
|
$scope.del = function () {
|
|
|
if (confirm('确定删除角色(' + $scope.role.desc + ')吗?')) {
|
|
if (confirm('确定删除角色(' + $scope.role.desc + ')吗?')) {
|
|
|
- AccountRole.remove({id: role.id}, function () {
|
|
|
|
|
|
|
+ queryObj.AccountRole.remove({id: role.id}, function () {
|
|
|
toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
|
|
toaster.pop('success', '提示', '角色:' + $scope.role.desc + ' 删除成功');
|
|
|
$modalInstance.close(true);
|
|
$modalInstance.close(true);
|
|
|
}, function (response) {
|
|
}, function (response) {
|