CloudAuthoritySetCtrl.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. angular.module('push')
  2. .controller('CloudAuthoritySetCtrl', function ($scope, UtilService, CloudFolderService, $timeout, AuthorityModelService) {
  3. $scope.cloudfolder = {name: "", authoritylist: ""};
  4. //权限列表初始化
  5. var getAuthorityList = function () {
  6. $scope.showLoadingToast();
  7. CloudFolderService.getCloudAutListForFolder("").then(function (response) {
  8. if(angular.isDefined(response.cloautlist)){
  9. $scope.AuthorityList = response.cloautlist;
  10. }else {
  11. $scope.AuthorityList = [];
  12. }
  13. $scope.hideLoadingToast();
  14. }, function () {
  15. $scope.hideLoadingToast();
  16. $scope.AuthorityList = [];
  17. UtilService.showMess("网络不给力,请稍后重试");
  18. })
  19. };
  20. getAuthorityList();
  21. $scope.chooseNewUndid = function (Authority, index) {
  22. $scope.AuthorityList[index].checked = !$scope.AuthorityList[index].checked;
  23. };
  24. $scope.saveCloudFolder = function () {
  25. if(!UtilService.isDefined($scope.cloudfolder.name)){
  26. UtilService.showMess("文件夹名称不能为空");
  27. return;
  28. }
  29. $scope.cloudfolder.authoritylist = "";
  30. angular.forEach($scope.AuthorityList, function (data, index) {
  31. if (data.checked) {
  32. var tempstr = data.id + ":" + data.comefrom;
  33. if ($scope.cloudfolder.authoritylist.length == 0) {
  34. $scope.cloudfolder.authoritylist = tempstr;
  35. } else {
  36. $scope.cloudfolder.authoritylist = $scope.cloudfolder.authoritylist + "," + tempstr;
  37. }
  38. }
  39. });
  40. if(!UtilService.isDefined($scope.cloudfolder.authoritylist)){
  41. UtilService.showMess("权限不能为空");
  42. return;
  43. }
  44. $scope.showLoadingToast();
  45. // console.log($scope.cloudfolder);
  46. CloudFolderService.createCloudFolder($scope.cloudfolder).then(function (response) {
  47. UtilService.showMess("新建成功");
  48. $timeout(function () {
  49. $scope.goback();
  50. }, 1500);
  51. $scope.hideLoadingToast();
  52. }, function () {
  53. $scope.hideLoadingToast();
  54. UtilService.showMess("网络不给力,请稍后重试");
  55. })
  56. };
  57. //创建权限
  58. $scope.creatAuthority = function () {
  59. AuthorityModelService.resetData();
  60. $scope.go('creatAuthority');
  61. };
  62. });