CloudFolderCreateCtrl.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. angular.module('push')
  2. .controller('CloudFolderCreateCtrl', function ($scope, UtilService, CloudFolderService, $timeout, AuthorityModelService) {
  3. $scope.cloudfolder = {name: AuthorityModelService.getCloudFolderName(), 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. var templist = AuthorityModelService.getCloudAuthorityList();
  14. angular.forEach(templist, function (data, ind) {
  15. angular.forEach($scope.AuthorityList, function (value, index) {
  16. if (data.id == value.id) {
  17. $scope.AuthorityList[index] = templist[ind];
  18. }
  19. })
  20. });
  21. $scope.hideLoadingToast();
  22. }, function () {
  23. $scope.hideLoadingToast();
  24. $scope.AuthorityList = [];
  25. UtilService.showMess("网络不给力,请稍后重试");
  26. })
  27. };
  28. getAuthorityList();
  29. $scope.chooseNewUndid = function (Authority, index) {
  30. $scope.AuthorityList[index].checked = !$scope.AuthorityList[index].checked;
  31. };
  32. var crclfoflg = 0;
  33. $scope.saveCloudFolder = function () {
  34. if (!UtilService.isDefined($scope.cloudfolder.name)) {
  35. UtilService.showMess("文件夹名称不能为空");
  36. return;
  37. }
  38. $scope.cloudfolder.authoritylist = "";
  39. angular.forEach($scope.AuthorityList, function (data, index) {
  40. if (data.checked) {
  41. var tempstr = data.id + ":" + data.comefrom;
  42. if ($scope.cloudfolder.authoritylist.length == 0) {
  43. $scope.cloudfolder.authoritylist = tempstr;
  44. } else {
  45. $scope.cloudfolder.authoritylist = $scope.cloudfolder.authoritylist + "," + tempstr;
  46. }
  47. }
  48. });
  49. if (!UtilService.isDefined($scope.cloudfolder.authoritylist)) {
  50. UtilService.showMess("权限不能为空");
  51. return;
  52. }
  53. if (crclfoflg != 0) {
  54. return;
  55. }
  56. crclfoflg = 1;
  57. $scope.showLoadingToast();
  58. CloudFolderService.createCloudFolder($scope.cloudfolder).then(function (response) {
  59. UtilService.showMess("新建成功");
  60. AuthorityModelService.setCloudFolderName("");
  61. $timeout(function () {
  62. $scope.goback();
  63. crclfoflg = 0;
  64. }, 1500);
  65. $scope.hideLoadingToast();
  66. }, function () {
  67. crclfoflg = 0;
  68. $scope.hideLoadingToast();
  69. UtilService.showMess("网络不给力,请稍后重试");
  70. })
  71. };
  72. //创建权限
  73. $scope.creatAuthority = function () {
  74. AuthorityModelService.resetData();
  75. AuthorityModelService.setCloudFolderName($scope.cloudfolder.name);
  76. AuthorityModelService.setCloudAuthorityList($scope.AuthorityList);
  77. $scope.go('creatAuthority');
  78. };
  79. $scope.settingsList = [
  80. {text: " 权限管理者可编辑", checked: true},
  81. {text: "权限创建者可编辑", checked: false}
  82. ];
  83. });