myNoticeCtrl.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. app.controller('myNoticeCtrl', ["$rootScope", "$scope", '$stateParams', '$http', '$state', '$timeout', '$ionicPopover', '$ionicPopup', '$ionicLoading', 'api_bpm_domain', 'Restangular', 'api_solution', 'api_user_data', 'getLoginUser', function($rootScope, $scope, $stateParams, $http, $state, $timeout, $ionicPopover, $ionicPopup, $ionicLoading, api_bpm_domain, Restangular, api_solution, api_user_data, getLoginUser) {
  2. console.log('myNoticeCtrl is load');
  3. $scope.goBack = function() {
  4. if ($scope.sessionLogin.tokenType == 'user') {
  5. $state.go('tab.handlerDashboard');
  6. } else {
  7. $state.go('tab.requesterDashboard');
  8. }
  9. }
  10. $scope.load = {
  11. 'pageIndex': 0, //第几页
  12. 'pageSum': 10, //每页条数
  13. 'pageCount': 0 //总页数
  14. };
  15. $scope.search = {
  16. 'pageIndex': 0, //第几页
  17. 'pageSum': 10, //每页条数
  18. 'pageCount': 0 //总页数
  19. };
  20. //弹出框
  21. // var template = '<ion-popover-view><ion-header-bar> <h1 class="title">My Popover Title</h1> </ion-header-bar> <ion-content> Hello! </ion-content></ion-popover-view>';
  22. // $scope.popover = $ionicPopover.fromTemplate(template, {
  23. // scope: $scope
  24. // });
  25. // .fromTemplateUrl() method
  26. $ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
  27. scope: $scope
  28. }).then(function(popover) {
  29. $scope.popover = popover;
  30. });
  31. $scope.openPopover = function($event) {
  32. $scope.popover.show($event);
  33. };
  34. $scope.closePopover = function() {
  35. $scope.popover.hide();
  36. };
  37. //Cleanup the popover when we're done with it!
  38. $scope.$on('$destroy', function() {
  39. $scope.popover.remove();
  40. });
  41. // Execute action on hidden popover
  42. $scope.$on('popover.hidden', function() {
  43. // Execute action
  44. });
  45. // Execute action on remove popover
  46. $scope.$on('popover.removed', function() {
  47. // Execute action
  48. });
  49. $scope.statuses = [
  50. { status: 'all', label: '全部的事件', idName: 'a' },
  51. { status: 'todo', label: '待我处理的', idName: 'b' },
  52. { status: 'create', label: '我创建的', idName: 'c' },
  53. { status: 'done', label: '我处理过的', idName: 'd' },
  54. // { status: 's', label: '已驳回', idName: 'e' },
  55. // { status: '6', label: '已拒绝', idName: 'f' }
  56. ];
  57. $scope.searchTypeFunction = function(searchType) {
  58. $scope.refreshListData({
  59. 'searchType': searchType,
  60. 'idx': 0,
  61. });
  62. $scope.popover.hide();
  63. }
  64. // $scope.loginForm = {};
  65. // var loginUser = $rootScope.user;
  66. //获取login中的数据
  67. // var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  68. // var loginUser = sessionLogin.user;
  69. //定义流程代号
  70. // var pdKey = $state.current.pdKey;
  71. var pdKey = 'bpm_incident';
  72. // var incidentListMobileParameter = {
  73. // 'assignee': loginUser.id,
  74. // 'idx': 0,
  75. // 'sum': 10,
  76. // 'status': '',
  77. // 'count': 0,
  78. // 'currentPage': 1,
  79. // 'endPage': 0,
  80. // 'pages': []
  81. // };
  82. //默认数据
  83. // var defaultData = {
  84. // 'assignee': loginUser.id,
  85. // 'idx': 0,
  86. // 'sum': 10,
  87. // };
  88. //页面数据容器
  89. $scope.myData = [];
  90. //是否加载上拉刷新
  91. $scope.domore = false;
  92. //填充数据
  93. // $scope.filterData = {
  94. // 'assignee': loginUser.id,
  95. // 'idx': 0,
  96. // 'sum': 10,
  97. // };
  98. //本地数据初始化
  99. // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  100. //搜索栏
  101. $scope.searchSolution = function(searchInput) {
  102. //遮罩层开启
  103. $ionicLoading.show({
  104. template: 'Loading...'
  105. });
  106. var filterData = { idx: 0, sum: 10, notice: { title: searchInput, content: searchInput } }
  107. if (angular.isString(searchInput) && searchInput != '') {
  108. api_user_data.fetchDataList('notice', filterData).then(function(data) {
  109. var myData = Restangular.stripRestangular(data);
  110. if (angular.isArray(myData.list) && myData.list.length > 0) {
  111. $scope.myData = myData.list;
  112. //计算总页数
  113. $scope.search.pageCount = Math.ceil(myData.totalNum / $scope.search.pageSum);
  114. } else {
  115. $ionicPopup.alert({
  116. title: '对不起,没有搜索到相关内容!',
  117. })
  118. $scope.listShow = false;
  119. $ionicLoading.hide();
  120. }
  121. //遮罩层关闭
  122. $ionicLoading.hide();
  123. });
  124. }
  125. }
  126. //新增数据
  127. $scope.addData = function() {
  128. var data = JSON.parse(sessionStorage.incidentListMobileParameter);
  129. if (data.formUiEdit) {
  130. var formUiEdit = data.formUiEdit;
  131. };
  132. if (data.formUiName) {
  133. var formUiName = data.formUiName;
  134. };
  135. if (data.processKey) {
  136. var pdKey = data.processKey;
  137. };
  138. if (data.formUiStart) {
  139. var formUiStart = data.formUiStart;
  140. };
  141. if (pdKey) {
  142. $state.go('app.incidentMobile.incidentEditorMobile', {
  143. 'pdKey': pdKey,
  144. 'formUiEdit': formUiEdit,
  145. 'formUiName': formUiName,
  146. 'formUiStart': formUiStart,
  147. 'userId': data.status
  148. });
  149. } else {
  150. SweetAlert.swal({
  151. title: "当前服务类型不可新建",
  152. // text: myData.data,
  153. type: "warning"
  154. });
  155. }
  156. };
  157. //跳转到编辑列表
  158. $scope.editorFunction = function(data) {
  159. // $state.go('app.inspection.inspectListEditor', {
  160. // "taskId": data.taskId,
  161. // "processInstanceId": data.processInstanceId,
  162. // "pdKey": data.processKey,
  163. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  164. // // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  165. // });
  166. $state.go('app.incidentMobile.incidentEditorMobile', {
  167. taskId: data.taskId,
  168. processInstanceId: data.processInstanceId
  169. });
  170. };
  171. //跳转到查看列表
  172. $scope.lookFunction = function(data) {
  173. $state.go('tab.myNoticeDetail', {
  174. 'item': JSON.stringify(data)
  175. });
  176. };
  177. //页面刷新
  178. $scope.reload = function() {
  179. $scope.refreshListData();
  180. }
  181. //下拉刷新
  182. $scope.doRefresh = function() {
  183. $scope.load.pageIndex = 0;
  184. $scope.refreshListData('', 'down');
  185. $scope.domore = false;
  186. if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
  187. $scope.searchInput = '';
  188. }
  189. };
  190. //上拉加载
  191. $scope.loadMore = function() {
  192. //开启上拉加载
  193. $scope.domore = false;
  194. //数据列表加1
  195. // $scope.load.pageIndex += 1;
  196. //定时器
  197. var timer = null;
  198. //参数
  199. var filterData = $scope.defaultData;
  200. angular.extend(filterData, { 'idx': $scope.filterData.idx });
  201. //加载
  202. if (angular.isString($scope.searchInput) && $scope.searchInput != '') {
  203. $scope.search.pageIndex += 1;
  204. if ($scope.search.pageIndex < $scope.search.pageCount) {
  205. api_user_data.fetchDataList('notice', filterData).then(function(data) {
  206. var myData = Restangular.stripRestangular(data);
  207. if (angular.isArray(myData.list) && myData.list.length > 0) {
  208. angular.forEach(myData.list, function(item) {
  209. $scope.myData.push(item);
  210. });
  211. }
  212. $scope.$broadcast('scroll.infiniteScrollComplete');
  213. }, function(data) {
  214. });
  215. } else {
  216. $scope.domore = true;
  217. $scope.$broadcast('scroll.infiniteScrollComplete');
  218. }
  219. } else {
  220. $scope.load.pageIndex += 1;
  221. if ($scope.load.pageIndex < $scope.load.pageCount) {
  222. api_user_data.fetchDataList('notice', filterData).then(function(data) {
  223. var myData = Restangular.stripRestangular(data);
  224. if (angular.isArray(myData.list) && myData.list.length > 0) {
  225. angular.forEach(myData.list, function(item) {
  226. $scope.myData.push(item);
  227. });
  228. }
  229. $scope.$broadcast('scroll.infiniteScrollComplete');
  230. }, function(data) {
  231. });
  232. } else {
  233. $scope.domore = true;
  234. $scope.$broadcast('scroll.infiniteScrollComplete');
  235. }
  236. }
  237. };
  238. //数据加载
  239. $scope.refreshListData = function(filterData, loadStyle) {
  240. var showData = {};
  241. if (filterData) {
  242. filterData = angular.extend($scope.defaultData, filterData);
  243. } else {
  244. filterData = $scope.defaultData;
  245. }
  246. //遮罩层开启
  247. $ionicLoading.show({
  248. template: 'Loading...'
  249. });
  250. api_user_data.fetchDataList('notice', filterData).then(function(data) {
  251. var myData = Restangular.stripRestangular(data);
  252. if (angular.isArray(myData.list) && myData.list.length > 0) {
  253. $scope.myData = myData.list;
  254. //计算总页数
  255. $scope.load.pageCount = Math.ceil(myData.totalNum / $scope.load.pageSum);
  256. if (loadStyle == 'down') {
  257. $scope.$broadcast('scroll.refreshComplete');
  258. }
  259. } else {
  260. $scope.listShow = false;
  261. }
  262. //遮罩层关闭
  263. $ionicLoading.hide();
  264. }, function() {
  265. //遮罩层关闭
  266. $ionicLoading.hide();
  267. });
  268. }
  269. //页面加载
  270. // $scope.reload();
  271. //跳转成功刷新页面
  272. // $scope.$on('$stateChangeSucess', $scope.reload())
  273. if (!sessionStorage.sessionLogin) {
  274. var promise = getLoginUser.query();
  275. promise.then(function(sessionLogin) { //返回成功
  276. $scope.tokenType = sessionLogin.tokenType;
  277. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  278. var loginUser = sessionLogin.user;
  279. $scope.sessionLogin = sessionLogin
  280. $rootScope.user = sessionLogin.user;
  281. $scope.defaultData = {
  282. // 'assignee': loginUser.account,
  283. 'idx': 0,
  284. 'sum': 10,
  285. // 'candidateGroups': loginUser.group["0"].id
  286. };
  287. $scope.filterData = {
  288. // 'assignee': loginUser.account,
  289. 'idx': 0,
  290. 'sum': 10,
  291. };
  292. $scope.reload()
  293. }, function(data) { //返回失败
  294. });
  295. } else {
  296. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  297. var loginUser = sessionLogin.user;
  298. $scope.sessionLogin = sessionLogin
  299. $rootScope.user = sessionLogin.user;
  300. $scope.defaultData = {
  301. // 'assignee': loginUser.account,
  302. 'idx': 0,
  303. 'sum': 10,
  304. // 'candidateGroups': loginUser.group["0"].id
  305. };
  306. $scope.filterData = {
  307. // 'assignee': loginUser.account,
  308. 'idx': 0,
  309. 'sum': 10,
  310. };
  311. $scope.reload()
  312. }
  313. }])