123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- angular.module('push')
- .controller('authoritySetCtrl', function ($scope, $stateParams, AuthorityService, AuthorityModel, UtilService, $timeout, $ionicPopup, UserService) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- var reclibid = $stateParams.reclibid;
- var authorityid = $stateParams.authorityid;
- var authoritycomefrom = $stateParams.authoritycomefrom;
- var parentid = $stateParams.parentid;
- $scope.type = $stateParams.type;//0:记录,1:资源
- $scope.viplevel = UserService.viplevel;
- $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.issuperadmin = response.issuperadmin;
- $scope.memberlist = response.userList;
- $scope.adminlist = response.adminList;
- $scope.superadminids = response.superadminList;//超级管理员列表
- $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.issuperadmin = AuthorityModel.getIsSuperAdmin();
- $scope.superadminids = AuthorityModel.getSuperAdminList();
- $scope.identity = AuthorityModel.getIdentity();
- angular.forEach($scope.memberlist, function (value, index) {
- if (value.iscreator == 1) {
- $scope.ownerid = value.userId;
- $scope.ownername = value.userName;
- }
- });
- $scope.oldownerid = AuthorityModel.getOldOwnerId();
- }
- //置顶按钮
- 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;'>确认将所有权转让给\"" + $scope.ownername + "\",退出将不再列表中显示</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, parentid, $scope.superadminids).then(function (response) {
- // console.log(response);
- UtilService.showMess("设置成功");
- $timeout(function () {
- AuthorityModel.resetAuthorityData();
- // AuthorityModel.editmemberflg = false;
- // AuthorityModel.quitauthflg = 0;
- // AuthorityModel.invite_url = "";
- if ($stateParams.goflg == 1) {
- $scope.backViews(-2);
- } else {
- $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.setIsSuperAdmin($scope.issuperadmin);
- AuthorityModel.setSuperAdminList($scope.superadminids);
- AuthorityModel.setOwnerId($scope.ownerid);
- AuthorityModel.setOwnerName($scope.ownername);
- AuthorityModel.setIdentity($scope.identity);
- };
- var quitAuth = function (type) {
- AuthorityService.quitAuthority(type, reclibid, 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();
- if ($stateParams.goflg == 1) {
- $scope.backViews(-2);
- } else {
- $scope.goback();
- }
- }, 1000);
- }, function () {
- UtilService.showMess("网络不给力,请稍后重试");
- });
- };
- //退出身份判断
- $scope.quitAuthority = function () {
- if ($scope.identity == 1) {
- if ($scope.ownerid != $scope.oldownerid) {
- showConfirm();
- } else {
- if ($scope.memberlist.length > 1) {
- $ionicPopup.show({
- title: '退出提示',
- template: "<p style='text-align: center;margin: 0;'>请先设置所有权给其他成员后</p><p style='text-align: center;margin-bottom: 5px;'>才可以退出</p>",
- buttons: [
- {text: "取消"},
- {
- text: '<span class="ionicAction_span">去设置所有权</span>',
- type: "button-positive",
- onTap: function (e) {
- saveTempData();
- AuthorityModel.quitauthflg = 1;
- $scope.go("authoritySetOwner");
- }
- }
- ]
- });
- } else {
- $ionicPopup.show({
- title: "确认退出此文件夹",
- template: "<p style='text-align: center;'>退出后文件夹将不再显示在列表中</p>",
- scope: $scope,
- buttons: [
- {text: "取消"},
- {
- text: '<span class="ionicAction_span">确认</span>',
- type: "button-positive",
- onTap: function () {
- quitAuth(3);
- }
- }
- ]
- })
- }
- }
- } else {
- $ionicPopup.show({
- title: "确认退出此文件夹",
- template: "<p style='text-align: center;'>退出后文件夹将不再显示在列表中</p>",
- scope: $scope,
- buttons: [
- {text: "取消"},
- {
- text: '<span class="ionicAction_span">确认</span>',
- type: "button-positive",
- onTap: function () {
- 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 != 1 && $scope.identity != 3) || $scope.memberlist.length <= 1) {
- return;
- }
- saveTempData();
- $scope.go("authoritySetManger");
- };
- //跳转至设置所有者页面
- $scope.goSetOwner = function () {
- if (($scope.identity != 1 && $scope.identity != 3) || $scope.memberlist.length <= 1) {
- return;
- }
- saveTempData();
- AuthorityModel.quitauthflg = 0;
- $scope.go("authoritySetOwner", {identity: $scope.identity});
- };
- $scope.goSetSuperAdmin = function () {
- saveTempData();
- $scope.go("accountSetChild");
- };
- //跳转到成员页面
- $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})
- };
- });
|