123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- angular.module('push')
- .controller('buildNewFolderCtrl', function ($scope, $stateParams, AuthorityService, AuthorityModel, UtilService, $timeout, $ionicPopup) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- var reclibid = $stateParams.reclibid;
- var authorityid = $stateParams.authorityid;
- var authoritycomefrom = $stateParams.authoritycomefrom;
- $scope.reclib = {
- name: AuthorityModel.getReclibName() == "" ? $stateParams.name : AuthorityModel.getReclibName(),
- content: AuthorityModel.getContent() == "" ? $stateParams.content : AuthorityModel.getContent()
- };
- //获取权限信息
- var getAuthorityInfomation = function () {
- AuthorityService.getAuthorityInfomation(authorityid, authoritycomefrom).then(function (response) {
- // console.log(response);
- $scope.authority = response;
- $scope.memberlist = response.userList;
- $scope.adminlist = response.adminList;
- $scope.identity = response.identity;
- AuthorityModel.invite_url = response.invite_url;
- AuthorityModel.setIdentity($scope.identity);
- $scope.ownername = $scope.authority.creator.userName;
- AuthorityModel.setOwnerName($scope.ownername);
- $scope.ownerid = $scope.authority.creator.userId;
- $scope.oldownerid = angular.copy($scope.authority.creator.userId);
- AuthorityModel.setOldOwnerId($scope.ownerid);
- AuthorityModel.setOwnerId($scope.ownerid);
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- })
- };
- //恢复临时数据
- if (AuthorityModel.getReclibName() == "") {
- getAuthorityInfomation();
- } else {
- $scope.memberlist = AuthorityModel.getMemberList();
- $scope.adminlist = AuthorityModel.getAdminList();
- $scope.identity = AuthorityModel.getIdentity();
- $scope.oldownerid = AuthorityModel.getOldOwnerId();
- $scope.ownerid = AuthorityModel.getOwnerId();
- $scope.ownername = AuthorityModel.getOwnerName();
- }
- //置顶按钮
- if (AuthorityModel.getToggle() == "unchecked") {
- $scope.settingsList = {
- checked: $stateParams.sort != 0
- };
- } else {
- $scope.settingsList = {
- checked: AuthorityModel.getToggle()
- }
- }
- var showConfirm = function () {
- $ionicPopup.show({
- title: "确认退出",
- template: "<p style='text-align: center;'>退出此文件夹将不再列表中显示</p>" +
- "<p style='text-align: center;font-weight: bold;'>可设置所有权给其他成员</p>",
- scope: $scope,
- buttons: [
- {text: "直接退出"},
- {
- text: '<span class="ionicAction_span">去设置</span>',
- type: "button-positive",
- onTap: function () {
- quitAuth(1);
- }
- }
- ]
- });
- };
- if (AuthorityModel.quitauthflg == 2) {
- showConfirm();
- AuthorityModel.quitauthflg = 1;
- }
- //获取成员列表
- var getMemberlist = function () {
- AuthorityService.getAuthorityDetail(authorityid, authoritycomefrom).then(function (response) {
- // console.log(response);
- $scope.memberlist = response.userList;
- AuthorityModel.setMemberList($scope.memberlist);
- AuthorityModel.editmemberflg = false;
- }, function () {
- UtilService.showMess("网络不给力,请稍后重试");
- });
- };
- //成员变动时重新获取成员列表
- if (AuthorityModel.editmemberflg) {
- getMemberlist();
- }
- //编辑权限
- $scope.editAuthInfo = function () {
- if (!UtilService.isDefined($scope.reclib.name)) {
- UtilService.showMess("资源库名称不能为空");
- return;
- }
- var adminids = [];
- angular.forEach($scope.adminlist, function (value, index) {
- adminids.push(value.userId);
- });
- var tempbool = AuthorityModel.getToggle();
- var sort;
- if (tempbool) {
- sort = 1;
- } else {
- sort = 0;
- }
- if (tempbool == "unchecked") {
- sort = -1;
- }
- AuthorityService.editAuthorityInfomation(reclibid, authorityid, authoritycomefrom, adminids, $scope.reclib.name, $scope.reclib.content, AuthorityModel.getOwnerId(), sort).then(function (response) {
- // console.log(response);
- UtilService.showMess("设置成功");
- $timeout(function () {
- AuthorityModel.resetAuthorityData();
- // AuthorityModel.editmemberflg = false;
- // AuthorityModel.quitauthflg = 0;
- // AuthorityModel.invite_url = "";
- $scope.goback();
- }, 1000);
- }, function () {
- UtilService.showMess("网络不给力,请重试");
- })
- };
- //选择/取消 置顶
- $scope.cloudToggle = function () {
- // console.log($scope.settingsList.checked);
- AuthorityModel.setToggle($scope.settingsList.checked);
- };
- //保存临时数据
- var saveTempData = function () {
- AuthorityModel.setReclibName($scope.reclib.name);
- AuthorityModel.setContent($scope.reclib.content);
- AuthorityModel.setMemberList($scope.memberlist);
- AuthorityModel.setAdminList($scope.adminlist);
- // AuthorityModel.setOwnerId($scope.ownerid);
- // AuthorityModel.setOwnerName($scope.ownername);
- // AuthorityModel.setIdentity($scope.identity);
- };
- var quitAuth = function (type) {
- AuthorityService.quitAuthority(type, authorityid, authoritycomefrom, $scope.ownerid).then(function (response) {
- // console.log(response);
- UtilService.showMess("退出成功");
- $timeout(function () {
- // AuthorityModel.editmemberflg = false;
- // AuthorityModel.quitauthflg = 0;
- // AuthorityModel.invite_url = "";
- AuthorityModel.resetAuthorityData();
- $scope.goback();
- }, 1000);
- }, function () {
- UtilService.showMess("网络不给力,请稍后重试");
- });
- };
- $scope.quitAuthority = function () {
- if ($scope.identity == 1) {
- if ($scope.ownerid != $scope.oldownerid) {
- showConfirm();
- } else {
- $ionicPopup.show({
- title: '退出提示',
- template: '请先设置所有权给其他成员后才可以退出',
- buttons: [
- {
- text: '<span class="ionicAction_span">去设置所有权</span>',
- type: "button-positive",
- onTap: function (e) {
- saveTempData();
- AuthorityModel.quitauthflg = 1;
- $scope.go("authoritySetOwner");
- }
- }
- ]
- });
- }
- } else {
- quitAuth(2);
- }
- };
- //返回
- $scope.gobackback = function () {
- AuthorityModel.resetAuthorityData();
- $scope.goback();
- };
- //跳转至添加成员页面
- $scope.addResourceMember = function () {
- saveTempData();
- $scope.go("authorityAddMember", {authid: authorityid, authcomefrom: authoritycomefrom});
- };
- //跳转至设置管理员页面
- $scope.goSetManger = function () {
- if ($scope.identity == 0) {
- return;
- }
- saveTempData();
- $scope.go("authoritySetManger");
- };
- //跳转至设置所有者页面
- $scope.goSetOwner = function () {
- if ($scope.identity != 1) {
- return;
- }
- saveTempData();
- AuthorityModel.quitauthflg = 0;
- $scope.go("authoritySetOwner");
- };
- //跳转到成员页面
- $scope.goResourceMember = function () {
- saveTempData();
- $scope.go("authorityMember", {identity: $scope.identity, authid: authorityid, authcomefrom: authoritycomefrom});
- };
- $scope.goPublisher = function (member) {
- saveTempData();
- $scope.go('publisher', {Id: member.userId})
- };
- });
|