authoritySetMangerCtrl.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. angular.module('push')
  2. .controller('authoritySetMangerCtrl', function ($scope, AuthorityModel, UtilService) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. $scope.memberlist = AuthorityModel.getMemberList();
  7. var adminnum = 0;
  8. var adminlist = [];
  9. var countAdminNum = function () {
  10. adminnum = 0;
  11. adminlist = [];
  12. angular.forEach($scope.memberlist, function (value, index) {
  13. if (value.iscreator == 2) {
  14. adminnum++;
  15. adminlist.push(value);
  16. }
  17. });
  18. AuthorityModel.setAdminList(adminlist);
  19. };
  20. countAdminNum();
  21. $scope.chooseAdmin = function (member, index) {
  22. // console.log(adminnum);
  23. if ($scope.memberlist[index].iscreator == 1) {
  24. return;
  25. }
  26. if ($scope.memberlist[index].iscreator == 2) {
  27. $scope.memberlist[index].iscreator = 0;
  28. } else {
  29. if (adminnum == 5) {
  30. UtilService.showMess("请设置5个以内管理员!");
  31. return;
  32. }
  33. $scope.memberlist[index].iscreator = 2;
  34. }
  35. countAdminNum();
  36. };
  37. });