CloudFolderDetailCtrl.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. angular.module('push')
  2. .controller('CloudFolderDetailCtrl', function ($scope, $stateParams, ModelService, UtilService, $ionicHistory, ShareService, ResourceLibraryService,
  3. DockingService, $ionicActionSheet, UserService, $timeout, $ionicListDelegate) {
  4. //TODO
  5. if($scope.app){
  6. $scope.setStatusBar(0);
  7. }
  8. var cloudfolder = angular.fromJson($stateParams.folder);
  9. $scope.name = cloudfolder.name;
  10. var checkedresource = {};//单个分享时选中的资源
  11. var checkedindex = -1;//多个分享时第一个选择的索引
  12. $scope.checkedresourcelist = [];//多个分享时选中的资源
  13. $scope.userid = UserService.id;
  14. $scope.isload = false;
  15. var currentPage = 1;
  16. //获取云文件夹内容
  17. $scope.initConninfoList = function () {
  18. currentPage = 1;
  19. $scope.showLoadingToast();
  20. DockingService.newGetConnInfoList(cloudfolder.id, cloudfolder.level, currentPage).then(function (response) {
  21. // console.log(response);
  22. // isSet 是否有权限设置:0无 1有
  23. $scope.isSet = response.isSet;
  24. $scope.smallfolderlist = response.connFolderlist;
  25. $scope.recordList = response.list;
  26. //判断是否有下一页
  27. $timeout(function () {
  28. if (currentPage >= response.page.totalPage) {
  29. $scope.isload = false;
  30. } else {
  31. $scope.isload = true;
  32. currentPage = 2;
  33. }
  34. }, 1000);
  35. }, function () {
  36. }).finally(function () {
  37. $scope.hideLoadingToast();
  38. $scope.$broadcast('scroll.refreshComplete');
  39. });
  40. };
  41. $scope.initConninfoList();
  42. $scope.loadMore = function () {
  43. $scope.isload = false;
  44. $scope.showLoadingToast();
  45. DockingService.newGetConnInfoList(cloudfolder.id, cloudfolder.level, currentPage).then(function (response) {
  46. // console.log(response);
  47. if (response.list.length > 0) {
  48. $scope.recordList = $scope.recordList.concat(response.list);
  49. }
  50. //判断是否有下一页
  51. $timeout(function () {
  52. if (currentPage >= response.page.totalPage) {
  53. $scope.isload = false;
  54. } else {
  55. $scope.isload = true;
  56. currentPage++;
  57. }
  58. }, 1000);
  59. }, function () {
  60. }).finally(function () {
  61. $scope.hideLoadingToast();
  62. $scope.$broadcast('scroll.infiniteScrollComplete');
  63. });
  64. };
  65. $scope.showMoreAction = true;
  66. $scope.showAction = function () {
  67. $scope.showMoreAction = !$scope.showMoreAction;
  68. };
  69. //新建记录
  70. $scope.createConninfo = function () {
  71. ModelService.setCreateType(1);
  72. $scope.go('cloudAddConnInfo');
  73. };
  74. //创建子文件夹
  75. $scope.createFolder = function () {
  76. $scope.go("authorityCreate", {
  77. parentid: cloudfolder.id,
  78. level: cloudfolder.level,
  79. authorityid: cloudfolder.authorityid,
  80. authoritycomefrom: cloudfolder.authoritycomefrom,
  81. templettype: 1
  82. });
  83. };
  84. //进入分类详情,记录列表
  85. $scope.queryFolder = function (folder) {
  86. $scope.go('cloudFolderDetail', {folder: angular.toJson(folder)});
  87. };
  88. //侧滑设置文件夹
  89. $scope.goAutoritySet = function (folder) {
  90. $scope.go("authoritySet", {
  91. reclibid: folder.id,
  92. authorityid: folder.authorityid,
  93. authoritycomefrom: folder.authoritycomefrom,
  94. name: folder.name,
  95. content: folder.content,
  96. sort: folder.sort,
  97. goflg: 0,
  98. type: 0,
  99. parentid: folder.parentid
  100. });
  101. };
  102. //修改云文件夹
  103. $scope.editCloudFolder = function () {
  104. $ionicActionSheet.show({
  105. buttons: [{text: '<a class="action-sheet-push">设置</a>'}],
  106. cancelText: '取消',
  107. buttonClicked: function (index) {
  108. if (index == 0) {
  109. $scope.go("authoritySet", {
  110. reclibid: cloudfolder.id,
  111. authorityid: cloudfolder.authorityid,
  112. authoritycomefrom: cloudfolder.authoritycomefrom,
  113. name: cloudfolder.name,
  114. content: cloudfolder.content,
  115. sort: cloudfolder.sort,
  116. goflg: 1,
  117. type: 0,
  118. parentid: cloudfolder.parentid
  119. });
  120. }
  121. return true;
  122. }
  123. });
  124. };
  125. //点击进入对接详情
  126. $scope.goDockingdetails = function (rec, ind) {
  127. // 走企业模版
  128. if(rec.templettype == 2){
  129. $scope.go("technicalBrokerCompanyInfo", {connid: rec.id});
  130. }else if(rec.templettype == 1){
  131. if (selectflg) {
  132. selectResource(rec, ind);
  133. } else {
  134. $scope.go("cloudDockingdetail", {infoid: rec.id, infocomefrom: rec.creatorcomefrom, creator: rec.creator});
  135. }
  136. }
  137. };
  138. $scope.shareflg = false;
  139. $scope.openShare = function (tempobj, ind) {
  140. $timeout(function () {
  141. $ionicListDelegate.closeOptionButtons();
  142. }, 200);
  143. if (UserService.viplevel == 1) {
  144. ResourceLibraryService.getVisitAuthority(0, tempobj.id, tempobj.creator, "000000000", 81).then(function (response) {
  145. // isedit:是否可以编辑资源,isset:是否可以设置权限,bl:是否可以访问
  146. if (response.bl) {
  147. $scope.go('chooseShareFolder', {
  148. chereslist: angular.toJson([tempobj.id]),
  149. folderid: cloudfolder.id,
  150. isCloud: cloudfolder.isCloud
  151. });
  152. } else {
  153. UtilService.showMess("您没有该条记录的权限,暂时无法复制");
  154. }
  155. }, function () {
  156. UtilService.showMess("网络不给力,请稍后重试");
  157. });
  158. } else {
  159. $scope.go('chooseShareFolder', {
  160. chereslist: angular.toJson([tempobj.id]),
  161. folderid: cloudfolder.id,
  162. isCloud: cloudfolder.isCloud
  163. });
  164. }
  165. /*$scope.shareflg = true;
  166. $(".resource_wrap").css("left", "0%");
  167. $(".pay_list_c2").css("left", "-35px");
  168. $("#collect-bottom").css("display", "none");
  169. checkedresource = tempobj;
  170. checkedindex = ind;*/
  171. };
  172. $scope.closeShare = function () {
  173. $timeout(function () {
  174. $ionicListDelegate.closeOptionButtons();
  175. }, 10);
  176. $scope.shareflg = false;
  177. };
  178. //分享选择操作表
  179. var selectflg = false;//列表选择打开标志
  180. $scope.openCollectShare = function () {
  181. selectflg = true;
  182. $scope.recordList[checkedindex].value = true;
  183. var tempres = {
  184. infoid: checkedresource.id,
  185. infocomefrom: checkedresource.creatorcomefrom,
  186. infoType: 81,
  187. claid: cloudfolder.id
  188. };
  189. $scope.checkedresourcelist.push(tempres);
  190. $(".item-options").addClass("invisible");
  191. $(".resource_wrap").css("left", "10%");
  192. $(".pay_list_c2").css("left", "4%");
  193. $(".item-content").css("transform", "translate3d(0px, 0px, 0px)");
  194. $("#collect-bottom").css("display", "block");
  195. $scope.closeShare();
  196. };
  197. //取消分享
  198. $scope.cancelShare = function () {
  199. angular.forEach($scope.recordList, function (value, ind) {
  200. $scope.recordList[ind].value = false;
  201. });
  202. $scope.checkedresourcelist = [];
  203. $(".resource_wrap").css("left", "0%");
  204. $(".pay_list_c2").css("left", "-35px");
  205. $("#collect-bottom").css("display", "none");
  206. selectflg = false;
  207. };
  208. var selectResource = function (rec, ind) {
  209. var tempres = {
  210. infoid: rec.id,
  211. infocomefrom: rec.creatorcomefrom,
  212. infoType: 81,
  213. claid: cloudfolder.id
  214. };
  215. var chind = -1;
  216. angular.forEach($scope.checkedresourcelist, function (value, index) {
  217. if (value.infoid == rec.id) {
  218. chind = index;
  219. }
  220. });
  221. if (chind == -1) {
  222. $scope.recordList[ind].value = true;
  223. $scope.checkedresourcelist.unshift(tempres);
  224. } else {
  225. $scope.recordList[ind].value = false;
  226. $scope.checkedresourcelist.splice(chind, 1);
  227. }
  228. // console.log($scope.checkedresourcelist);
  229. };
  230. $scope.shareResourceToPrilib = function () {
  231. $scope.go('chooseShareFolder', {
  232. chereslist: angular.toJson($scope.checkedresourcelist),
  233. folderid: cloudfolder.id
  234. });
  235. };
  236. //跳转工具搜索
  237. $scope.goToolsSearch = function () {
  238. $timeout(function () {
  239. $scope.go("connsearch", {folderid: cloudfolder.id});
  240. }, 300);
  241. };
  242. //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
  243. $scope.shareMessage = function (type) {
  244. $scope.shareflg = false;
  245. $scope.showLoadingToast();
  246. var imagurl = "http://test.ubitech.cn/000000000/themes/avatar_save/1490753632823.jpg";
  247. if (checkedresource.image.length > 0) {
  248. imagurl = $scope.imgUrl + checkedresource.image;
  249. }
  250. var message = {
  251. title: checkedresource.title,
  252. description: checkedresource.content.substring(0, 19),
  253. url: checkedresource.share_url,
  254. imageurl: imagurl
  255. };
  256. switch (type) {
  257. case 0:
  258. case 1:
  259. ShareService.shareToQQ(type, message).then(function () {
  260. UtilService.showMess("QQ分享成功");
  261. $scope.hideLoadingToast();
  262. }, function (error) {
  263. UtilService.showMess(error);
  264. $scope.hideLoadingToast();
  265. });
  266. break;
  267. case 2:
  268. case 3:
  269. ShareService.shareToWechat(0, message).then(function () {
  270. UtilService.showMess("微信分享成功");
  271. $scope.hideLoadingToast();
  272. }, function (error) {
  273. UtilService.showMess(error);
  274. $scope.hideLoadingToast();
  275. });
  276. break;
  277. default:
  278. break;
  279. }
  280. $timeout(function () {
  281. $scope.hideLoadingToast();
  282. }, 10000);
  283. };
  284. $scope.refreshDate = function () {
  285. $scope.initConninfoList();
  286. $scope.$broadcast('scroll.refreshComplete');
  287. var trHtml = "<div class='refresh_tip_div'>更新了" + $scope.recordList.length + "条内容</div>";
  288. $timeout(function () {
  289. $(".resourcelistDiv .list").prepend(trHtml);
  290. $(".refresh_tip_div").animate({width: 100 + "%"}, 150);
  291. }, 800);
  292. $timeout(function () {
  293. $(".refresh_tip_div").slideUp();
  294. }, 1200);
  295. };
  296. //页面加载完成,设置当前文件夹为选中文件夹
  297. $scope.$on('$ionicView.afterEnter', function () {
  298. ModelService.setCheckdeFolder(cloudfolder);
  299. });
  300. });