authorityAddSuperAdminCtrl.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. angular.module('push')
  2. .controller('authorityAddSuperAdminCtrl', function ($scope, $stateParams, AuthorityModel, UtilService) {
  3. $scope.memberlist = AuthorityModel.getMemberList();//权限成员列表
  4. $scope.superadminids = AuthorityModel.getSuperAdminList();//权限超级管理员列表
  5. var useridlist = "";
  6. angular.forEach($scope.superadminids, function (value, index) {
  7. var tempid = "'" + value.userId + "'";
  8. useridlist = useridlist + tempid + ",";
  9. });
  10. angular.forEach($scope.memberlist, function (data, index) {
  11. var tempid = "'" + data.userId + "'";
  12. if (useridlist.indexOf(tempid) != -1) {
  13. $scope.memberlist[index].isExisits = 1;
  14. } else {
  15. $scope.memberlist[index].isExisits = 0;
  16. }
  17. });
  18. //添加超级管理员
  19. $scope.addSuperAdmin = function (member, index) {
  20. if ($scope.superadminids.length >= 5) {
  21. UtilService.showMess("不可设置多于5个超级管理员");
  22. return;
  23. }
  24. var tempindex = -1;
  25. angular.forEach($scope.superadminids, function (value, ind) {
  26. if (value.userId == member.userId) {
  27. tempindex = ind;
  28. }
  29. });
  30. if (tempindex != -1) {
  31. UtilService.showMess("已添加为超级管理员");
  32. $scope.memberlist[index].isExisits = 1;
  33. } else {
  34. $scope.memberlist[index].isExisits = 1;
  35. var tempobj = {
  36. userName: member.userName,
  37. photo: member.photo,
  38. userId: member.userId, //用户id
  39. parentid: 1
  40. };
  41. $scope.superadminids.push(tempobj);
  42. }
  43. AuthorityModel.setSuperAdminList($scope.superadminids);
  44. };
  45. //删除超级管理员
  46. $scope.delSuperAdmin = function (member, index) {
  47. angular.forEach($scope.memberlist, function (value, ind) {
  48. if (value.parentid != 0 && value.userId == member.userId) {
  49. $scope.memberlist[ind].isExisits = 0;
  50. }
  51. });
  52. angular.forEach($scope.superadminids, function (value, ind) {
  53. if (value.parentid != 0 && value.userId == member.userId) {
  54. $scope.superadminids.splice(ind, 1);
  55. }
  56. });
  57. AuthorityModel.setSuperAdminList($scope.superadminids);
  58. };
  59. $scope.addResourceMember = function () {
  60. $scope.go("addMember");
  61. };
  62. $scope.goUserSearch = function () {
  63. $scope.go('userSearch', {searchtype: 1, isset: 0});
  64. };
  65. });