CloudFolderEditCtrl.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. angular.module('push')
  2. .controller('CloudFolderEditCtrl', function ($scope, $stateParams, CloudFolderService, UtilService, $timeout, UserService) {
  3. $scope.cloudfolder = $stateParams.clfolder;
  4. $scope.name = angular.copy($scope.cloudfolder.name);
  5. //权限列表初始化
  6. var getAuthorityList = function () {
  7. $scope.showLoadingToast();
  8. CloudFolderService.getCloudAutListForFolder($scope.cloudfolder.id).then(function (response) {
  9. $scope.AuthorityList = response.cloautlist;
  10. $scope.hideLoadingToast();
  11. }, function () {
  12. $scope.hideLoadingToast();
  13. UtilService.showMess("网络不给力,请稍后重试");
  14. })
  15. };
  16. getAuthorityList();
  17. var changeflg = false;
  18. $scope.chooseNewUndid = function (Authority, index) {
  19. changeflg = true;
  20. $scope.AuthorityList[index].isSelect = $scope.AuthorityList[index].isSelect == 1 ? 0 : 1;
  21. };
  22. var crclfoflg = 0;
  23. $scope.editCloudFolder = function () {
  24. if (!UtilService.isDefined($scope.cloudfolder.name)) {
  25. UtilService.showMess("文件夹名称不能为空");
  26. return;
  27. }
  28. $scope.cloudfolder.authoritylist = "";
  29. if(changeflg){
  30. angular.forEach($scope.AuthorityList, function (data, index) {
  31. if (data.isSelect == 1) {
  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. }
  45. if (crclfoflg != 0) {
  46. return;
  47. }
  48. crclfoflg = 1;
  49. $scope.showLoadingToast();
  50. // console.log($scope.cloudfolder);
  51. CloudFolderService.updateCloudFolder($scope.cloudfolder).then(function (response) {
  52. UtilService.showMess("修改成功");
  53. $timeout(function () {
  54. $scope.backViews(-2);
  55. crclfoflg = 0;
  56. }, 1500);
  57. $scope.hideLoadingToast();
  58. }, function () {
  59. crclfoflg = 0;
  60. $scope.hideLoadingToast();
  61. UtilService.showMess("网络不给力,请稍后重试");
  62. })
  63. };
  64. });