buildNewFolderCtrl.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. angular.module('push')
  2. .controller('buildNewFolderCtrl', function ($scope, $stateParams, AuthorityService, AuthorityModel, UtilService, $timeout, $ionicPopup) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. var reclibid = $stateParams.reclibid;
  7. var authorityid = $stateParams.authorityid;
  8. var authoritycomefrom = $stateParams.authoritycomefrom;
  9. $scope.reclib = {
  10. name: AuthorityModel.getReclibName() == "" ? $stateParams.name : AuthorityModel.getReclibName(),
  11. content: AuthorityModel.getContent() == "" ? $stateParams.content : AuthorityModel.getContent()
  12. };
  13. //获取权限信息
  14. var getAuthorityInfomation = function () {
  15. AuthorityService.getAuthorityInfomation(authorityid, authoritycomefrom).then(function (response) {
  16. // console.log(response);
  17. $scope.authority = response;
  18. $scope.memberlist = response.userList;
  19. $scope.adminlist = response.adminList;
  20. $scope.identity = response.identity;
  21. AuthorityModel.invite_url = response.invite_url;
  22. AuthorityModel.setIdentity($scope.identity);
  23. $scope.ownername = $scope.authority.creator.userName;
  24. AuthorityModel.setOwnerName($scope.ownername);
  25. $scope.ownerid = $scope.authority.creator.userId;
  26. $scope.oldownerid = angular.copy($scope.authority.creator.userId);
  27. AuthorityModel.setOldOwnerId($scope.ownerid);
  28. AuthorityModel.setOwnerId($scope.ownerid);
  29. }, function () {
  30. UtilService.showMess("网络不给力,请重试");
  31. })
  32. };
  33. //恢复临时数据
  34. if (AuthorityModel.getReclibName() == "") {
  35. getAuthorityInfomation();
  36. } else {
  37. $scope.memberlist = AuthorityModel.getMemberList();
  38. $scope.adminlist = AuthorityModel.getAdminList();
  39. $scope.identity = AuthorityModel.getIdentity();
  40. $scope.oldownerid = AuthorityModel.getOldOwnerId();
  41. $scope.ownerid = AuthorityModel.getOwnerId();
  42. $scope.ownername = AuthorityModel.getOwnerName();
  43. }
  44. //置顶按钮
  45. if (AuthorityModel.getToggle() == "unchecked") {
  46. $scope.settingsList = {
  47. checked: $stateParams.sort != 0
  48. };
  49. } else {
  50. $scope.settingsList = {
  51. checked: AuthorityModel.getToggle()
  52. }
  53. }
  54. var showConfirm = function () {
  55. $ionicPopup.show({
  56. title: "确认退出",
  57. template: "<p style='text-align: center;'>退出此文件夹将不再列表中显示</p>" +
  58. "<p style='text-align: center;font-weight: bold;'>可设置所有权给其他成员</p>",
  59. scope: $scope,
  60. buttons: [
  61. {text: "直接退出"},
  62. {
  63. text: '<span class="ionicAction_span">去设置</span>',
  64. type: "button-positive",
  65. onTap: function () {
  66. quitAuth(1);
  67. }
  68. }
  69. ]
  70. });
  71. };
  72. if (AuthorityModel.quitauthflg == 2) {
  73. showConfirm();
  74. AuthorityModel.quitauthflg = 1;
  75. }
  76. //获取成员列表
  77. var getMemberlist = function () {
  78. AuthorityService.getAuthorityDetail(authorityid, authoritycomefrom).then(function (response) {
  79. // console.log(response);
  80. $scope.memberlist = response.userList;
  81. AuthorityModel.setMemberList($scope.memberlist);
  82. AuthorityModel.editmemberflg = false;
  83. }, function () {
  84. UtilService.showMess("网络不给力,请稍后重试");
  85. });
  86. };
  87. //成员变动时重新获取成员列表
  88. if (AuthorityModel.editmemberflg) {
  89. getMemberlist();
  90. }
  91. //编辑权限
  92. $scope.editAuthInfo = function () {
  93. if (!UtilService.isDefined($scope.reclib.name)) {
  94. UtilService.showMess("资源库名称不能为空");
  95. return;
  96. }
  97. var adminids = [];
  98. angular.forEach($scope.adminlist, function (value, index) {
  99. adminids.push(value.userId);
  100. });
  101. var tempbool = AuthorityModel.getToggle();
  102. var sort;
  103. if (tempbool) {
  104. sort = 1;
  105. } else {
  106. sort = 0;
  107. }
  108. if (tempbool == "unchecked") {
  109. sort = -1;
  110. }
  111. AuthorityService.editAuthorityInfomation(reclibid, authorityid, authoritycomefrom, adminids, $scope.reclib.name, $scope.reclib.content, AuthorityModel.getOwnerId(), sort).then(function (response) {
  112. // console.log(response);
  113. UtilService.showMess("设置成功");
  114. $timeout(function () {
  115. AuthorityModel.resetAuthorityData();
  116. // AuthorityModel.editmemberflg = false;
  117. // AuthorityModel.quitauthflg = 0;
  118. // AuthorityModel.invite_url = "";
  119. $scope.goback();
  120. }, 1000);
  121. }, function () {
  122. UtilService.showMess("网络不给力,请重试");
  123. })
  124. };
  125. //选择/取消 置顶
  126. $scope.cloudToggle = function () {
  127. // console.log($scope.settingsList.checked);
  128. AuthorityModel.setToggle($scope.settingsList.checked);
  129. };
  130. //保存临时数据
  131. var saveTempData = function () {
  132. AuthorityModel.setReclibName($scope.reclib.name);
  133. AuthorityModel.setContent($scope.reclib.content);
  134. AuthorityModel.setMemberList($scope.memberlist);
  135. AuthorityModel.setAdminList($scope.adminlist);
  136. // AuthorityModel.setOwnerId($scope.ownerid);
  137. // AuthorityModel.setOwnerName($scope.ownername);
  138. // AuthorityModel.setIdentity($scope.identity);
  139. };
  140. var quitAuth = function (type) {
  141. AuthorityService.quitAuthority(type, authorityid, authoritycomefrom, $scope.ownerid).then(function (response) {
  142. // console.log(response);
  143. UtilService.showMess("退出成功");
  144. $timeout(function () {
  145. // AuthorityModel.editmemberflg = false;
  146. // AuthorityModel.quitauthflg = 0;
  147. // AuthorityModel.invite_url = "";
  148. AuthorityModel.resetAuthorityData();
  149. $scope.goback();
  150. }, 1000);
  151. }, function () {
  152. UtilService.showMess("网络不给力,请稍后重试");
  153. });
  154. };
  155. $scope.quitAuthority = function () {
  156. if ($scope.identity == 1) {
  157. if ($scope.ownerid != $scope.oldownerid) {
  158. showConfirm();
  159. } else {
  160. $ionicPopup.show({
  161. title: '退出提示',
  162. template: '请先设置所有权给其他成员后才可以退出',
  163. buttons: [
  164. {
  165. text: '<span class="ionicAction_span">去设置所有权</span>',
  166. type: "button-positive",
  167. onTap: function (e) {
  168. saveTempData();
  169. AuthorityModel.quitauthflg = 1;
  170. $scope.go("authoritySetOwner");
  171. }
  172. }
  173. ]
  174. });
  175. }
  176. } else {
  177. quitAuth(2);
  178. }
  179. };
  180. //返回
  181. $scope.gobackback = function () {
  182. AuthorityModel.resetAuthorityData();
  183. $scope.goback();
  184. };
  185. //跳转至添加成员页面
  186. $scope.addResourceMember = function () {
  187. saveTempData();
  188. $scope.go("authorityAddMember", {authid: authorityid, authcomefrom: authoritycomefrom});
  189. };
  190. //跳转至设置管理员页面
  191. $scope.goSetManger = function () {
  192. if ($scope.identity == 0) {
  193. return;
  194. }
  195. saveTempData();
  196. $scope.go("authoritySetManger");
  197. };
  198. //跳转至设置所有者页面
  199. $scope.goSetOwner = function () {
  200. if ($scope.identity != 1) {
  201. return;
  202. }
  203. saveTempData();
  204. AuthorityModel.quitauthflg = 0;
  205. $scope.go("authoritySetOwner");
  206. };
  207. //跳转到成员页面
  208. $scope.goResourceMember = function () {
  209. saveTempData();
  210. $scope.go("authorityMember", {identity: $scope.identity, authid: authorityid, authcomefrom: authoritycomefrom});
  211. };
  212. $scope.goPublisher = function (member) {
  213. saveTempData();
  214. $scope.go('publisher', {Id: member.userId})
  215. };
  216. });