123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- angular.module('push')
- .controller('authorityAddSuperAdminCtrl', function ($scope, $stateParams, AuthorityModel, UtilService) {
- $scope.memberlist = AuthorityModel.getMemberList();//权限成员列表
- $scope.superadminids = AuthorityModel.getSuperAdminList();//权限超级管理员列表
- var useridlist = "";
- angular.forEach($scope.superadminids, function (value, index) {
- var tempid = "'" + value.userId + "'";
- useridlist = useridlist + tempid + ",";
- });
- angular.forEach($scope.memberlist, function (data, index) {
- var tempid = "'" + data.userId + "'";
- if (useridlist.indexOf(tempid) != -1) {
- $scope.memberlist[index].isExisits = 1;
- } else {
- $scope.memberlist[index].isExisits = 0;
- }
- });
- //添加超级管理员
- $scope.addSuperAdmin = function (member, index) {
- if ($scope.superadminids.length >= 5) {
- UtilService.showMess("不可设置多于5个超级管理员");
- return;
- }
- var tempindex = -1;
- angular.forEach($scope.superadminids, function (value, ind) {
- if (value.userId == member.userId) {
- tempindex = ind;
- }
- });
- if (tempindex != -1) {
- UtilService.showMess("已添加为超级管理员");
- $scope.memberlist[index].isExisits = 1;
- } else {
- $scope.memberlist[index].isExisits = 1;
- var tempobj = {
- userName: member.userName,
- photo: member.photo,
- userId: member.userId, //用户id
- parentid: 1
- };
- $scope.superadminids.push(tempobj);
- }
- AuthorityModel.setSuperAdminList($scope.superadminids);
- };
- //删除超级管理员
- $scope.delSuperAdmin = function (member, index) {
- angular.forEach($scope.memberlist, function (value, ind) {
- if (value.parentid != 0 && value.userId == member.userId) {
- $scope.memberlist[ind].isExisits = 0;
- }
- });
- angular.forEach($scope.superadminids, function (value, ind) {
- if (value.parentid != 0 && value.userId == member.userId) {
- $scope.superadminids.splice(ind, 1);
- }
- });
- AuthorityModel.setSuperAdminList($scope.superadminids);
- };
- $scope.addResourceMember = function () {
- $scope.go("addMember");
- };
- $scope.goUserSearch = function () {
- $scope.go('userSearch', {searchtype: 1, isset: 0});
- };
- });
|