angular.module('push') .controller('CloudFolderCreateCtrl', function ($scope, UtilService, CloudFolderService, $timeout, AuthorityModelService) { $scope.cloudfolder = {name: AuthorityModelService.getCloudFolderName(), authoritylist: ""}; //权限列表初始化 var getAuthorityList = function () { $scope.showLoadingToast(); CloudFolderService.getCloudAutListForFolder("").then(function (response) { if (angular.isDefined(response.cloautlist)) { $scope.AuthorityList = response.cloautlist; } else { $scope.AuthorityList = []; } var templist = AuthorityModelService.getCloudAuthorityList(); angular.forEach(templist, function (data, ind) { angular.forEach($scope.AuthorityList, function (value, index) { if (data.id == value.id) { $scope.AuthorityList[index] = templist[ind]; } }) }); $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); $scope.AuthorityList = []; UtilService.showMess("网络不给力,请稍后重试"); }) }; getAuthorityList(); $scope.chooseNewUndid = function (Authority, index) { $scope.AuthorityList[index].checked = !$scope.AuthorityList[index].checked; }; var crclfoflg = 0; $scope.saveCloudFolder = function () { if (!UtilService.isDefined($scope.cloudfolder.name)) { UtilService.showMess("文件夹名称不能为空"); return; } $scope.cloudfolder.authoritylist = ""; angular.forEach($scope.AuthorityList, function (data, index) { if (data.checked) { 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(); CloudFolderService.createCloudFolder($scope.cloudfolder).then(function (response) { UtilService.showMess("新建成功"); AuthorityModelService.setCloudFolderName(""); $timeout(function () { $scope.goback(); crclfoflg = 0; }, 1500); $scope.hideLoadingToast(); }, function () { crclfoflg = 0; $scope.hideLoadingToast(); UtilService.showMess("网络不给力,请稍后重试"); }) }; //创建权限 $scope.creatAuthority = function () { AuthorityModelService.resetData(); AuthorityModelService.setCloudFolderName($scope.cloudfolder.name); AuthorityModelService.setCloudAuthorityList($scope.AuthorityList); $scope.go('creatAuthority'); }; $scope.settingsList = [ {text: " 权限管理者可编辑", checked: true}, {text: "权限创建者可编辑", checked: false} ]; });