myIncidentCtrl.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. app.controller('myIncidentCtrl', ["$rootScope", "$scope", '$aside', '$stateParams', '$http', '$state', '$stateParams', '$timeout', '$ionicPopover', '$ionicLoading', '$ionicScrollDelegate', 'api_bpm_domain', 'Restangular', 'getLoginUser', function($rootScope, $scope, $aside, $stateParams, $http, $state, $stateParams, $timeout, $ionicPopover, $ionicLoading, $ionicScrollDelegate, api_bpm_domain, Restangular, getLoginUser) {
  2. console.log('myIncidentCtrl is load');
  3. //弹出框
  4. // 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>';
  5. // $scope.popover = $ionicPopover.fromTemplate(template, {
  6. // scope: $scope
  7. // });
  8. // .fromTemplateUrl() method
  9. // if(){
  10. // }
  11. $scope.statecolor = [];
  12. $scope.goBack = function() {
  13. $state.go('tab.requesterDashboard');
  14. }
  15. $scope.load = {
  16. 'pageIndex': 0, //第几页
  17. 'pageSum': 10, //每页条数
  18. 'pageCount': 0 //总页数
  19. };
  20. $ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
  21. scope: $scope
  22. }).then(function(popover) {
  23. $scope.popover = popover;
  24. });
  25. $scope.openPopover = function($event) {
  26. $scope.popover.show($event);
  27. };
  28. $scope.closePopover = function() {
  29. $scope.popover.hide();
  30. };
  31. //Cleanup the popover when we're done with it!
  32. $scope.$on('$destroy', function() {
  33. $scope.popover.remove();
  34. });
  35. // Execute action on hidden popover
  36. $scope.$on('popover.hidden', function() {
  37. // Execute action
  38. });
  39. // Execute action on remove popover
  40. $scope.$on('popover.removed', function() {
  41. // Execute action
  42. });
  43. $scope.statuses = [
  44. { status: -2, label: '全部', idName: 'a', active: false },
  45. { status: 0, label: '未受理', idName: 'b', active: true },
  46. { status: 2, label: '处理中', idName: 'c', active: false },
  47. { status: 3, label: '待评价', idName: 'd', active: false },
  48. { status: 4, label: '已解决', idName: 'e', active: false }
  49. // { status: 's', label: '已驳回', idName: 'e' },
  50. // { status: '6', label: '已拒绝', idName: 'f' }
  51. ];
  52. $scope.searchstate = { status: -2, label: '全部', idName: 'a', active: false };
  53. $scope.inputclick = function() {
  54. var modalInstance = $aside.open({
  55. // templateUrl: 'assets/views/customform/tpl/searchright.html',
  56. templateUrl: 'assets/views/customform/tpl/bottomlist.html',
  57. placement: 'bottom',
  58. backdrop: true,
  59. controller: function($scope, $modalInstance, scope) {
  60. $scope.statuses = [
  61. { status: -2, label: '全部', idName: 'a', active: false },
  62. { status: 0, label: '未受理', idName: 'b', active: true },
  63. { status: 2, label: '处理中', idName: 'c', active: false },
  64. { status: 3, label: '待评价', idName: 'd', active: false },
  65. { status: 4, label: '已解决', idName: 'e', active: false },
  66. ];
  67. $scope.ok = function(item) {
  68. $modalInstance.close(item);
  69. }
  70. $scope.cancel = function() {
  71. $modalInstance.dismiss('cancel');
  72. }
  73. },
  74. size: 'sm',
  75. resolve: {
  76. scope: function() {
  77. return $scope;
  78. }
  79. }
  80. });
  81. modalInstance.result.then(function(selectedItem) {
  82. $ionicScrollDelegate.scrollTop();
  83. $scope.searchstate = selectedItem;
  84. angular.forEach($scope.statuses, function(item) {
  85. if (selectedItem.status == item.status) {
  86. item.active = true;
  87. } else {
  88. item.active = false;
  89. }
  90. })
  91. $scope.refreshListData({
  92. 'state': selectedItem.status,
  93. 'idx': 0
  94. });
  95. });
  96. }
  97. $scope.searchTypeFunction = function(searchType) {
  98. $ionicScrollDelegate.scrollTop();
  99. angular.forEach($scope.statuses, function(item) {
  100. if (searchType == item.status) {
  101. item.active = true;
  102. } else {
  103. item.active = false;
  104. }
  105. })
  106. $scope.refreshListData({
  107. 'state': -2,
  108. 'idx': 0
  109. });
  110. }
  111. // $scope.loginForm = {};
  112. // var loginUser = $rootScope.user;
  113. //获取login中的数据
  114. // var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  115. // var loginUser = sessionLogin.user;
  116. //定义流程代号
  117. // var pdKey = $state.current.pdKey;
  118. var pdKey = '';
  119. // var incidentListMobileParameter = {
  120. // 'assignee': loginUser.id,
  121. // 'idx': 0,
  122. // 'sum': 10,
  123. // 'status': '',
  124. // 'count': 0,
  125. // 'currentPage': 1,
  126. // 'endPage': 0,
  127. // 'pages': []
  128. // };
  129. //默认数据
  130. // var defaultData = {
  131. // 'assignee': loginUser.account,
  132. // 'idx': 0,
  133. // 'sum': 10,
  134. // };
  135. //页面数据容器
  136. $scope.myData = [];
  137. //是否加载上拉刷新
  138. $scope.domore = false;
  139. //填充数据
  140. // $scope.filterData = {
  141. // 'assignee': loginUser.account,
  142. // 'idx': 0,
  143. // 'sum': 10,
  144. // };
  145. $scope.newFunction = function() {
  146. $state.go('tab.customFormIndex', {
  147. 'formKey': 'requestMobileEditor'
  148. });
  149. };
  150. //本地数据初始化
  151. // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  152. //新增数据
  153. $scope.addData = function() {
  154. var data = JSON.parse(sessionStorage.incidentListMobileParameter);
  155. if (data.formUiEdit) {
  156. var formUiEdit = data.formUiEdit;
  157. };
  158. if (data.formUiName) {
  159. var formUiName = data.formUiName;
  160. };
  161. if (data.processKey) {
  162. var pdKey = data.processKey;
  163. };
  164. if (data.formUiStart) {
  165. var formUiStart = data.formUiStart;
  166. };
  167. if (pdKey) {
  168. $state.go('app.incidentMobile.incidentEditorMobile', {
  169. 'pdKey': pdKey,
  170. 'formUiEdit': formUiEdit,
  171. 'formUiName': formUiName,
  172. 'formUiStart': formUiStart,
  173. 'userId': data.status
  174. });
  175. } else {
  176. SweetAlert.swal({
  177. title: "当前服务类型不可新建",
  178. // text: myData.data,
  179. type: "warning"
  180. });
  181. }
  182. };
  183. //跳转到编辑列表
  184. $scope.editorFunction = function(data) {
  185. // $state.go('app.inspection.inspectListEditor', {
  186. // "taskId": data.taskId,
  187. // "processInstanceId": data.processInstanceId,
  188. // "pdKey": data.processKey,
  189. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  190. // // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  191. // });
  192. $state.go('app.incidentMobile.incidentEditorMobile', {
  193. taskId: data.taskId,
  194. processInstanceId: data.processInstanceId
  195. });
  196. };
  197. //跳转到查看列表
  198. $scope.lookFunction = function(data) {
  199. // $state.go('tab.incidentHandlerCustomFormDetail', {
  200. // "formKey": 'requester_detail',
  201. // "pdKey": 'bpm_incident',
  202. // "dataId": data.id,
  203. // "taskId": data.taskId,
  204. // "processInstanceId": data.processInstanceId
  205. // });
  206. $state.go('tab.myIncidentDetail', {
  207. 'item': JSON.stringify(data)
  208. });
  209. };
  210. //跳转到评价页面
  211. $scope.degreeFunction = function(data) {
  212. $state.go('tab.requesterDegree', {
  213. "formKey": 'requesterDegree',
  214. "incidentid": data.id,
  215. });
  216. };
  217. //页面刷新
  218. $scope.reload = function() {
  219. $scope.refreshListData();
  220. }
  221. //下拉刷新
  222. $scope.doRefresh = function() {
  223. $scope.filterData.idx = 0;
  224. var idx = {
  225. 'idx': $scope.filterData.idx
  226. }
  227. $scope.refreshListData(idx, 'down');
  228. $scope.domore = false;
  229. };
  230. //上拉加载
  231. $scope.loadMore = function() {
  232. //开启上拉加载
  233. $scope.domore = false;
  234. //数据列表加1
  235. // $scope.filterData.idx += 1;
  236. $scope.load.pageIndex += 1;
  237. //定时器
  238. var timer = null;
  239. //参数
  240. var showData = $scope.defaultData;
  241. angular.extend(showData, { 'idx': $scope.load.pageIndex });
  242. //加载
  243. // api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  244. if ($scope.load.pageIndex < $scope.load.pageCount) {
  245. api_bpm_domain.weChatFetchServiceTasks(pdKey, showData).then(function(data) {
  246. var myData = Restangular.stripRestangular(data);
  247. $scope.statecolor(myData.data);
  248. if (angular.isArray(myData.data) && myData.data.length > 0) {
  249. angular.forEach(myData.data, function(item) {
  250. $scope.myData.push(item);
  251. });
  252. $scope.$broadcast('scroll.infiniteScrollComplete');
  253. } else {
  254. $scope.domore = true;
  255. $scope.$broadcast('scroll.infiniteScrollComplete');
  256. }
  257. }, function(data) {});
  258. } else {
  259. $scope.domore = true;
  260. $scope.$broadcast('scroll.infiniteScrollComplete');
  261. }
  262. };
  263. $scope.isgetdata = true;
  264. //数据加载
  265. $scope.refreshListData = function(filterData, loadStyle) {
  266. $scope.isgetdata = false;
  267. //获取本地数据
  268. // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  269. //对接口参数进行重新组装
  270. // var showData = {
  271. // 'assignee': filterData.assignee,
  272. // // 'idx': filterData.currentPage ? filterData.currentPage - 1 : 0,
  273. // 'idx': filterData.idx,
  274. // 'searchType': filterData.searchType,
  275. // 'status': filterData.status,
  276. // 'sum': filterData.sum,
  277. // };
  278. var showData = {};
  279. if (filterData) {
  280. showData = angular.extend($scope.defaultData, filterData);
  281. } else {
  282. showData = $scope.defaultData;
  283. }
  284. // if (filterData.candidateGroups) {
  285. // angular.extend(showData, { 'candidateGroups': filterData.candidateGroups });
  286. // };
  287. // api_bpm_domain.fetchtask(pdKey, showData).then(function(data) {
  288. //遮罩层开启
  289. $ionicLoading.show({
  290. template: 'Loading...'
  291. });
  292. $scope.statecolor = function(myData) {
  293. angular.forEach(myData, function(item, index) {
  294. if (item.state == '未受理') {
  295. myData[index].statecolor = "state-wrap-basetwo"
  296. } else if (item.state == "处理中") {
  297. myData[index].statecolor = "state-wrap-basethree"
  298. } else if (item.state == "待评价") {
  299. myData[index].statecolor = "state-wrap-basefour"
  300. } else if (item.state == "已解决") {
  301. myData[index].statecolor = "state-wrap-baseone"
  302. }
  303. });
  304. }
  305. // var ceshi={"assignee":"dsadmin","idx":"0","state":"-2","sum":"10"};
  306. api_bpm_domain.weChatFetchServiceTasks(pdKey, showData).then(function(data) {
  307. // api_bpm_domain.weChatFetchServiceTasks(pdKey, ceshi).then(function(data) {
  308. var myData = Restangular.stripRestangular(data);
  309. // filterData.count = myData.resultCount;
  310. // if (angular.isArray(myData.data) && myData.data.length > 0) {
  311. if (angular.isArray(myData.data)) {
  312. $scope.statecolor(myData.data);
  313. $scope.myData = myData.data;
  314. $scope.load.pageIndex = myData.pageIndex;
  315. $scope.load.pageCount = Math.ceil(myData.resultCount / myData.pageSize);
  316. if (loadStyle == 'down') {
  317. $scope.$broadcast('scroll.refreshComplete');
  318. }
  319. } else {
  320. // SweetAlert.swal({
  321. // title: "数据为空",
  322. // text: myData.data,
  323. // type: "warning"
  324. // });
  325. // if ($scope.paginationList || $scope.paginationList.count) {
  326. // $scope.paginationList.count = 0;
  327. // }
  328. $scope.listShow = false;
  329. }
  330. $scope.domore = false;
  331. $scope.isgetdata = true;
  332. //遮罩层关闭
  333. $ionicLoading.hide();
  334. },
  335. function() {
  336. $ionicLoading.hide();
  337. });
  338. }
  339. //页面加载
  340. // $scope.reload();
  341. //跳转成功刷新页面
  342. // $scope.$on('$stateChangeSucess', $scope.reload())
  343. if (!sessionStorage.sessionLogin) {
  344. var promise = getLoginUser.query();
  345. promise.then(function(sessionLogin) { //返回成功
  346. $scope.tokenType = sessionLogin.tokenType;
  347. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  348. var loginUser = sessionLogin.user;
  349. $scope.sessionLogin = sessionLogin
  350. $rootScope.user = sessionLogin.user;
  351. $scope.defaultData = {
  352. 'assignee': loginUser.id,
  353. // 'account': loginUser.account,
  354. 'idx': 0,
  355. 'sum': 10,
  356. 'state': -2,
  357. // 'candidateGroups': loginUser.group["0"].id
  358. };
  359. $scope.filterData = {
  360. 'assignee': loginUser.id,
  361. // 'account': loginUser.account,
  362. 'idx': 0,
  363. 'sum': 10,
  364. 'state': -2
  365. };
  366. if (sessionStorage.getItem("toMyIncident") || sessionStorage.getItem("toMyIncident") != null) {
  367. var toMyIncident = JSON.parse(sessionStorage.getItem("toMyIncident"));
  368. if (toMyIncident.isClick == true) {
  369. $scope.searchTypeFunction(toMyIncident.searchType);
  370. sessionStorage.setItem("toMyIncident", null);
  371. }
  372. } else {
  373. $scope.reload()
  374. }
  375. }, function(data) { //返回失败
  376. });
  377. } else {
  378. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  379. var loginUser = sessionLogin.user;
  380. $scope.sessionLogin = sessionLogin
  381. $rootScope.user = sessionLogin.user;
  382. $scope.defaultData = {
  383. 'assignee': loginUser.id,
  384. // 'account': loginUser.account,
  385. 'idx': 0,
  386. 'sum': 10,
  387. 'state': -2,
  388. // 'candidateGroups': loginUser.group["0"].id
  389. };
  390. $scope.filterData = {
  391. 'assignee': loginUser.id,
  392. // 'account': loginUser.account,
  393. 'idx': 0,
  394. 'sum': 10,
  395. 'state': -2
  396. };
  397. if (sessionStorage.getItem("toMyIncident")) {
  398. var toMyIncident = JSON.parse(sessionStorage.getItem("toMyIncident"));
  399. if (toMyIncident.isClick == true) {
  400. $scope.searchTypeFunction(toMyIncident.searchType);
  401. sessionStorage.removeItem("toMyIncident");
  402. }
  403. } else {
  404. $scope.reload()
  405. }
  406. }
  407. }]);
  408. //过滤状态
  409. // app.filter('filterStatus', function() {
  410. // return function(text) {
  411. // if (text == '待接单' || text == '未受理') {
  412. // return '待受理'
  413. // } else if (text == '请求重新分派' || text == '处理中' || text == '待审核') {
  414. // return '受理中'
  415. // } else if (text == '已解决') {
  416. // return '待评价'
  417. // } else if (text == '已关闭' || text == '不受理') {
  418. // return '已关闭'
  419. // }
  420. // }
  421. // });