123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- angular.module('push')
- .controller('authorityRecordSetCtrl', function ($scope, $stateParams, AuthorityService, AuthorityModel, UtilService, $timeout, $ionicPopup, UserService) {
- var authoritydata = angular.fromJson($stateParams.authoritydata);
- $scope.type = authoritydata.recourcetype;
- $scope.viplevel = UserService.viplevel;
- var authorityid = 0;
- var authoritycomefrom = "";
- $scope.reclib = {
- name: AuthorityModel.getReclibName() == "" ? authoritydata.title : AuthorityModel.getReclibName()
- };
- //获取权限信息
- var getAuthorityInfomation = function () {
- AuthorityService.getRecordAuthority(1, authoritydata).then(function (response) {
- $scope.authority = response;
- $scope.memberlist = response.userList;//成员列表
- $scope.adminlist = response.adminList;//管理员列表
- $scope.issuperadmin = response.issuperadmin;
- $scope.superadminids = response.superadminList;//超级管理员列表
- $scope.identity = response.identity;//当前用户身份 0:普通成员,1:所有者,2:管理员,3:系统管理员
- $scope.ownername = $scope.authority.creator.userName;//所有者name
- $scope.ownerid = $scope.authority.creator.userId;//所有者id
- $scope.oldownerid = angular.copy($scope.authority.creator.userId);//旧所有者id
- $scope.settingsList = {
- checked: response.sort != 0,//置顶
- publicflg: response.ispublic == 2
- };
- $scope.reclib.content = UtilService.isDefined(response.intro) ? response.intro : "";
- //获取当前权限id,comefrom
- authorityid = response.cid;
- authoritycomefrom = response.ccomefrom;
- //保存权限信息
- AuthorityModel.invite_url = response.invite_url;//邀请链接
- AuthorityModel.setIdentity($scope.identity);
- AuthorityModel.setOwnerName($scope.ownername);
- AuthorityModel.setOldOwnerId($scope.ownerid);
- AuthorityModel.setOwnerId($scope.ownerid);
- AuthorityModel.setAuthorityId(authorityid);
- AuthorityModel.setAuthorityComefrom(authoritycomefrom);
- AuthorityModel.setContent(response.intro);
- }, 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();
- $scope.oldownerid = AuthorityModel.getOldOwnerId();
- $scope.ownerid = AuthorityModel.getOwnerId();
- $scope.ownername = AuthorityModel.getOwnerName();
- $scope.reclib.content = AuthorityModel.getContent();
- authorityid = AuthorityModel.getAuthorityId();
- authoritycomefrom = AuthorityModel.getAuthorityComefrom();
- $scope.settingsList = {
- checked: AuthorityModel.getToggle(),
- publicflg: AuthorityModel.getPublicFlg()
- }
- }
- /*//置顶按钮
- if (AuthorityModel.getToggle() != "unchecked") {
- $scope.settingsList = {
- checked: AuthorityModel.getToggle(),
- publicflg:AuthorityModel.getPublicFlg()
- }
- }*/
- 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) {
- $scope.memberlist = response.userList;
- AuthorityModel.setMemberList($scope.memberlist);
- AuthorityModel.editmemberflg = false;
- }, function () {
- UtilService.showMess("网络不给力,请稍后重试");
- });
- };
- //成员变动时重新获取成员列表
- if (AuthorityModel.editmemberflg) {
- getMemberlist();
- }
- //编辑权限
- $scope.setauthisover = 0;
- $scope.editAuthInfo = function () {
- var adminids = [];
- angular.forEach($scope.adminlist, function (value, index) {
- adminids.push(value.userId);
- });
- AuthorityService.infoEditAdmin(authorityid, authoritycomefrom, adminids, $scope.ownerid, authoritydata, $scope.superadminids).then(function (response) {
- $scope.setauthisover++;
- }, function () {
- $scope.setauthisover += 3;
- });
- /*--------------------------------以上修改管理员,所有权;以下修改置顶,简介------------------------------------------*/
- //判断置顶按钮
- var tempbool = AuthorityModel.getToggle();
- var sort;
- if (tempbool) {
- sort = 1;
- } else {
- sort = 0;
- }
- if (tempbool == "unchecked") {
- sort = -1;
- }
- var tempcon = UtilService.isDefined($scope.reclib.content) ? $scope.reclib.content : "";
- var ispublic = $scope.settingsList.publicflg ? 2 : 1;
- //组装参数
- var tempobj = {
- sort: sort,
- ispublic: ispublic,
- infoid: authoritydata.recourceid,
- infotype: authoritydata.recourcetype,
- infocomefrom: authoritydata.recourcecomefrom,
- introtype: AuthorityModel.getIntroType(),//是否修了权限简介 1:修改,2:未修改
- cid: authorityid,
- ccomefrom: authoritycomefrom,
- intro: encodeURI(tempcon),
- userid: UserService.id
- };
- AuthorityService.editIntro(tempobj).then(function (response) {
- $scope.setauthisover++;
- }, function () {
- $scope.setauthisover += 3;
- });
- };
- //--监听编辑是否结束
- var authwatch = $scope.$watch("setauthisover", function (newValue) {
- if (newValue == 2) {
- UtilService.showMess("设置成功");
- $timeout(function () {
- AuthorityModel.resetAuthorityData();
- $scope.goback();
- }, 1000);
- $scope.setauthisover = 0;
- authwatch();
- }
- if (newValue > 3) {
- UtilService.showMess("网络不给力,请重试");
- $scope.setauthisover = 0;
- }
- });
- //打开/关闭 公开开关
- $scope.openPublic = function () {
- AuthorityModel.setIntroType(1);
- AuthorityModel.setPublicFlg($scope.settingsList.publicflg);
- };
- //选择/取消 置顶
- $scope.cloudToggle = function () {
- AuthorityModel.setToggle($scope.settingsList.checked);
- };
- //保存临时数据
- var saveTempData = function () {
- AuthorityModel.setReclibName($scope.reclib.name);
- 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);
- AuthorityModel.setToggle($scope.settingsList.checked);
- AuthorityModel.setPublicFlg($scope.settingsList.publicflg);
- };
- var quitAuth = function (type) {
- AuthorityService.InfoAuthorityExit(type, authoritydata.recourceid, authoritydata.recourcetype, authorityid, authoritycomefrom, $scope.ownerid).then(function (response) {
- UtilService.showMess("退出成功");
- $timeout(function () {
- // AuthorityModel.editmemberflg = false;
- // AuthorityModel.quitauthflg = 0;
- // AuthorityModel.invite_url = "";
- AuthorityModel.resetAuthorityData();
- $scope.backViews(-2);
- }, 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) {
- return;
- }
- saveTempData();
- $scope.go("authoritySetManger");
- };
- //跳转至设置所有者页面
- $scope.goSetOwner = function () {
- if ($scope.identity != 1 && $scope.identity != 3) {
- return;
- }
- saveTempData();
- AuthorityModel.quitauthflg = 0;
- $scope.go("authoritySetOwner");
- };
- //跳转到成员页面
- $scope.goResourceMember = function () {
- saveTempData();
- $scope.go("authorityMember", {identity: $scope.identity, authid: authorityid, authcomefrom: authoritycomefrom});
- };
- $scope.setIntroType2 = function () {
- AuthorityModel.setIntroType(1);
- };
- $scope.goPublisher = function (member) {
- saveTempData();
- $scope.go('publisher', {Id: member.userId})
- };
- $scope.goSetSuperAdmin = function () {
- saveTempData();
- $scope.go("accountSetChild");
- };
- });
|