angular.module('push') .controller('CloudFolderEditCtrl', function ($scope, $stateParams, CloudFolderService, UtilService, $timeout, UserService) { $scope.cloudfolder = $stateParams.clfolder; $scope.name = angular.copy($scope.cloudfolder.name); //权限列表初始化 var getAuthorityList = function () { $scope.showLoadingToast(); CloudFolderService.getCloudAutListForFolder($scope.cloudfolder.id).then(function (response) { $scope.AuthorityList = response.cloautlist; $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); UtilService.showMess("网络不给力,请稍后重试"); }) }; getAuthorityList(); var changeflg = false; $scope.chooseNewUndid = function (Authority, index) { changeflg = true; $scope.AuthorityList[index].isSelect = $scope.AuthorityList[index].isSelect == 1 ? 0 : 1; }; var crclfoflg = 0; $scope.editCloudFolder = function () { if (!UtilService.isDefined($scope.cloudfolder.name)) { UtilService.showMess("文件夹名称不能为空"); return; } $scope.cloudfolder.authoritylist = ""; if(changeflg){ angular.forEach($scope.AuthorityList, function (data, index) { if (data.isSelect == 1) { var tempstr = data.id + ":" + data.comefrom; if ($scope.cloudfolder.authoritylist.length == 0) { $scope.cloudfolder.authoritylist = tempstr; } else { $scope.cloudfolder.authoritylist = $scope.cloudfolder.authoritylist + "," + tempstr; } } }); if (!UtilService.isDefined($scope.cloudfolder.authoritylist)) { UtilService.showMess("权限不能为空"); return; } } if (crclfoflg != 0) { return; } crclfoflg = 1; $scope.showLoadingToast(); // console.log($scope.cloudfolder); CloudFolderService.updateCloudFolder($scope.cloudfolder).then(function (response) { UtilService.showMess("修改成功"); $timeout(function () { $scope.backViews(-2); crclfoflg = 0; }, 1500); $scope.hideLoadingToast(); }, function () { crclfoflg = 0; $scope.hideLoadingToast(); UtilService.showMess("网络不给力,请稍后重试"); }) }; });