inspectCtrl.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. // app.controller('inspectCtrl', ["$rootScope", "$scope", '$stateParams', '$http', '$aside', '$state', '$timeout', '$ionicPopover', '$ionicPopup', '$ionicLoading', '$ionicScrollDelegate', 'api_bpm_domain', 'api_bpm_data', 'Restangular', 'loginService', 'getLoginUser', function($rootScope, $scope, $stateParams, $http, $aside, $state, $timeout, $ionicPopover, $ionicPopup, $ionicLoading, $ionicScrollDelegate, api_bpm_domain, api_bpm_data, Restangular, loginService, getLoginUser, ) {
  2. app.controller('inspectCtrl', ["$rootScope", "$scope", '$aside', '$stateParams', '$http', '$state', '$stateParams', '$timeout', '$ionicPopover', '$ionicLoading', '$ionicScrollDelegate', 'api_bpm_domain', 'api_bpm_data', 'Restangular', 'getLoginUser', function($rootScope, $scope, $aside, $stateParams, $http, $state, $stateParams, $timeout, $ionicPopover, $ionicLoading, $ionicScrollDelegate, api_bpm_domain, api_bpm_data, Restangular, getLoginUser) {
  3. // console.log('inspectCtrl is load');
  4. //弹出框
  5. // .fromTemplate() method
  6. // 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>';
  7. // $scope.popover = $ionicPopover.fromTemplate(template, {
  8. // scope: $scope
  9. // });
  10. // if ($scope.item.state == 0 && $rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) {
  11. // $scope.item.chaozuoPower = true;
  12. // }
  13. // if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  14. // if ($rootScope.user.id == $scope.item.handlerUser.id) {
  15. // $scope.item.chaozuoPower = true;
  16. // }
  17. // }
  18. $scope.look = function(item) {
  19. if (item.state == 0 && $rootScope.user.id && $rootScope.user.id == item.handlerUser.id) {
  20. $scope.editorFunction(item);
  21. } else {
  22. $scope.lookFunction(item);
  23. }
  24. };
  25. // $scope.edit = function() {
  26. // $scope.editorFunction($scope.item);
  27. // };
  28. // .fromTemplateUrl() method
  29. $scope.goBack = function() {
  30. $state.go('tab.handlerDashboard');
  31. }
  32. $scope.newFunction = function() {
  33. $state.go('tab.customFormIndex', {
  34. 'formKey': 'requestMobileEditor'
  35. });
  36. };
  37. $scope.load = {
  38. 'pageIndex': 0, //第几页
  39. 'pageSum': 10, //每页条数
  40. 'pageCount': 0 //总页数
  41. };
  42. $ionicPopover.fromTemplateUrl('assets/views/weChat/myIncident/popover.html', {
  43. scope: $scope
  44. }).then(function(popover) {
  45. $scope.popover = popover;
  46. });
  47. $scope.openPopover = function($event) {
  48. $scope.popover.show($event);
  49. };
  50. $scope.closePopover = function() {
  51. $scope.popover.hide();
  52. };
  53. //Cleanup the popover when we're done with it!
  54. $scope.$on('$destroy', function() {
  55. $scope.popover.remove();
  56. });
  57. // Execute action on hidden popover
  58. $scope.$on('popover.hidden', function(res) {
  59. // Execute action
  60. });
  61. // Execute action on remove popover
  62. $scope.$on('popover.removed', function() {
  63. // Execute action
  64. });
  65. $scope.statuses = [
  66. { status: 'all', label: '全部', idName: 'a', active: false },
  67. { status: 'todo', label: '待处理', idName: 'b', active: true },
  68. // { status: 'create', label: '我创建的', idName: 'c' },
  69. { status: 'done', label: '已处理', idName: 'd', active: false },
  70. // { status: 's', label: '已驳回', idName: 'e' },
  71. // { status: '6', label: '已拒绝', idName: 'f' }
  72. ];
  73. $scope.searchstate = { status: 'todo', label: '待处理', idName: 'b', active: true };
  74. $scope.searchTypeFunction = function(searchType) {
  75. $ionicScrollDelegate.scrollTop();
  76. angular.forEach($scope.statuses, function(item) {
  77. if (searchType == item.status) {
  78. item.active = true;
  79. } else {
  80. item.active = false;
  81. }
  82. })
  83. $scope.refreshListData({
  84. 'searchType': searchType,
  85. 'idx': 0
  86. });
  87. }
  88. // 一个精心制作的自定义弹窗
  89. // var myPopup = $ionicPopup.show({
  90. // template: '<input type="password" ng-model="data.wifi">',
  91. // title: 'Enter Wi-Fi Password',
  92. // subTitle: 'Please use normal things',
  93. // scope: $scope,
  94. // buttons: [
  95. // { text: 'Cancel' },
  96. // {
  97. // text: '<b>Save</b>',
  98. // type: 'button-positive',
  99. // onTap: function(e) {
  100. // if (!$scope.data.wifi) {
  101. // //不允许用户关闭,除非他键入wifi密码
  102. // e.preventDefault();
  103. // } else {
  104. // return $scope.data.wifi;
  105. // }
  106. // }
  107. // },
  108. // ]
  109. // });
  110. // myPopup.then(function(res) {
  111. // console.log('Tapped!', res);
  112. // });
  113. // $timeout(function() {
  114. // myPopup.close(); //由于某种原因3秒后关闭弹出
  115. // }, 3000);
  116. // 一个确认对话框
  117. $scope.showConfirm = function() {
  118. var confirmPopup = $ionicPopup.confirm({
  119. title: 'Consume Ice Cream',
  120. template: 'Are you sure you want to eat this ice cream?'
  121. });
  122. confirmPopup.then(function(res) {
  123. if (res) {
  124. console.log('You are sure');
  125. } else {
  126. console.log('You are not sure');
  127. }
  128. });
  129. };
  130. //状态选择
  131. $scope.searchstate = { status: 'todo', label: '待处理', idName: 'b', active: true };
  132. $scope.inputclick = function() {
  133. var modalInstance = $aside.open({
  134. templateUrl: 'assets/views/customform/tpl/bottomlist.html',
  135. placement: 'bottom',
  136. backdrop: true,
  137. controller: function($scope, $modalInstance, scope) {
  138. $scope.statuses = [
  139. { status: 'all', label: '全部', idName: 'a', active: false },
  140. { status: 'todo', label: '待处理', idName: 'b', active: true },
  141. { status: 'done', label: '已处理', idName: 'd', active: false },
  142. ];
  143. $scope.ok = function(item) {
  144. $modalInstance.close(item);
  145. }
  146. $scope.cancel = function() {
  147. $modalInstance.dismiss('cancel');
  148. }
  149. },
  150. size: 'sm',
  151. resolve: {
  152. scope: function() {
  153. return $scope;
  154. }
  155. }
  156. });
  157. modalInstance.result.then(function(selectedItem) {
  158. $ionicScrollDelegate.scrollTop();
  159. $scope.searchstate = selectedItem;
  160. angular.forEach($scope.statuses, function(item) {
  161. if (selectedItem.status == item.status) {
  162. item.active = true;
  163. } else {
  164. item.active = false;
  165. }
  166. })
  167. $scope.refreshListData({
  168. 'searchType': selectedItem.status,
  169. 'idx': 0
  170. });
  171. });
  172. }
  173. // 一个提示对话框
  174. $scope.showAlert = function() {
  175. var alertPopup = $ionicPopup.alert({
  176. title: 'Don\'t eat that!',
  177. template: 'It might taste good'
  178. });
  179. alertPopup.then(function(res) {
  180. console.log('Thank you for not eating my delicious ice cream cone');
  181. });
  182. };
  183. // $scope.loginForm = {};
  184. // var loginUser = $rootScope.user;
  185. //获取login中的数据
  186. // var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  187. // var loginUser = sessionLogin.user;
  188. // $rootScope.user = sessionLogin.user;
  189. //定义流程代号
  190. // var pdKey = $state.current.pdKey;
  191. var pdKey = 'bpm_incident';
  192. // var incidentListMobileParameter = {
  193. // 'assignee': loginUser.id,
  194. // 'idx': 0,
  195. // 'sum': 10,
  196. // 'status': '',
  197. // 'count': 0,
  198. // 'currentPage': 1,
  199. // 'endPage': 0,
  200. // 'pages': []
  201. // };
  202. //默认数据
  203. // var defaultData = {
  204. // 'assignee': loginUser.id,
  205. // 'idx': 0,
  206. // 'sum': 10,
  207. // };
  208. //页面数据容器
  209. $scope.myData = [];
  210. //是否加载上拉刷新
  211. $scope.domore = false;
  212. //填充数据
  213. // $scope.filterData = {
  214. // 'assignee': loginUser.id,
  215. // 'idx': 0,
  216. // 'sum': 10,
  217. // };
  218. //本地数据初始化
  219. // sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  220. //新增数据
  221. $scope.addData = function() {
  222. var data = JSON.parse(sessionStorage.incidentListMobileParameter);
  223. if (data.formUiEdit) {
  224. var formUiEdit = data.formUiEdit;
  225. };
  226. if (data.formUiName) {
  227. var formUiName = data.formUiName;
  228. };
  229. if (data.processKey) {
  230. var pdKey = data.processKey;
  231. };
  232. if (data.formUiStart) {
  233. var formUiStart = data.formUiStart;
  234. };
  235. if (pdKey) {
  236. $state.go('app.incidentMobile.incidentEditorMobile', {
  237. 'pdKey': pdKey,
  238. 'formUiEdit': formUiEdit,
  239. 'formUiName': formUiName,
  240. 'formUiStart': formUiStart,
  241. 'userId': data.status
  242. });
  243. } else {
  244. SweetAlert.swal({
  245. title: "当前服务类型不可新建",
  246. // text: myData.data,
  247. type: "warning"
  248. });
  249. }
  250. };
  251. //跳转到编辑列表
  252. $scope.editorFunction = function(data) {
  253. $state.go('tab.reServiceCustomFormIndex', {
  254. "taskId": data.taskId,
  255. "processInstanceId": data.processInstanceId,
  256. "pdKey": data.processKey,
  257. "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  258. // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  259. });
  260. };
  261. //跳转到查看列表
  262. $scope.lookFunction = function(data) {
  263. $state.go('tab.reServiceCustomFormDetail', {
  264. "formKey": data.inspection.inspectionTypeDTO.formUiName,
  265. "dataId": data.id,
  266. "taskId": data.taskId,
  267. "processInstanceId": data.processInstanceId,
  268. "pdKey": data.processKey,
  269. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  270. "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  271. });
  272. };
  273. //页面刷新
  274. $scope.reload = function() {
  275. $scope.refreshListData();
  276. }
  277. //下拉刷新
  278. $scope.doRefresh = function() {
  279. $scope.filterData.idx = 0;
  280. var idx = {
  281. 'idx': $scope.filterData.idx
  282. }
  283. $scope.refreshListData(idx, 'down');
  284. $scope.domore = false;
  285. };
  286. //上拉加载
  287. $scope.loadMore = function() {
  288. //开启上拉加载
  289. $scope.domore = false;
  290. //数据列表加1
  291. // $scope.filterData.idx += 1;
  292. $scope.load.pageIndex += 1;
  293. //定时器
  294. var timer = null;
  295. //参数
  296. var filterData = $scope.defaultData;
  297. angular.extend(filterData, { 'idx': $scope.load.pageIndex });
  298. //加载
  299. if ($scope.load.pageIndex < $scope.load.pageCount) {
  300. api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  301. var myData = Restangular.stripRestangular(data);
  302. if (myData.pageIndex <= myData.pageCount) {
  303. if (angular.isArray(myData.data) && myData.data.length > 0) {
  304. angular.forEach(myData.data, function(item) {
  305. $scope.myData.push(item);
  306. });
  307. }
  308. $scope.$broadcast('scroll.infiniteScrollComplete');
  309. } else {
  310. $scope.domore = true;
  311. $scope.$broadcast('scroll.infiniteScrollComplete');
  312. }
  313. }, function(data) {});
  314. } else {
  315. $scope.domore = true;
  316. $scope.$broadcast('scroll.infiniteScrollComplete');
  317. }
  318. };
  319. //数据加载
  320. $scope.refreshListData = function(filterData, loadStyle) {
  321. //获取本地数据
  322. // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  323. //对接口参数进行重新组装
  324. // var showData = {
  325. // 'assignee': filterData.assignee,
  326. // // 'idx': filterData.currentPage ? filterData.currentPage - 1 : 0,
  327. // 'idx': filterData.idx,
  328. // 'searchType': filterData.searchType,
  329. // 'status': filterData.status,
  330. // 'sum': filterData.sum,
  331. // };
  332. var showData = {};
  333. if (filterData) {
  334. showData = angular.extend($scope.defaultData, filterData);
  335. } else {
  336. showData = $scope.defaultData;
  337. }
  338. // if (filterData.candidateGroups) {
  339. // angular.extend(showData, { 'candidateGroups': filterData.candidateGroups });
  340. // };
  341. //遮罩层开启
  342. $ionicLoading.show({
  343. template: 'Loading...'
  344. });
  345. // api_bpm_data.fetchServiceTasks(showData.status, showData).then(function(data) {
  346. api_bpm_data.fetchInspectServiceTasks(showData.status, showData).then(function(data) {
  347. var myData = Restangular.stripRestangular(data);
  348. // filterData.count = myData.resultCount;
  349. // if (angular.isArray(myData.data) && myData.data.length > 0) {
  350. if (angular.isArray(myData.data)) {
  351. $scope.myData = myData.data;
  352. $scope.load.pageIndex = myData.pageIndex;
  353. $scope.load.pageCount = myData.pageCount;
  354. if (loadStyle == 'down') {
  355. $scope.$broadcast('scroll.refreshComplete');
  356. }
  357. } else {
  358. // SweetAlert.swal({
  359. // title: "数据为空",
  360. // text: myData.data,
  361. // type: "warning"
  362. // });
  363. // if ($scope.paginationList || $scope.paginationList.count) {
  364. // $scope.paginationList.count = 0;
  365. // }
  366. $scope.listShow = false;
  367. }
  368. $scope.domore = false;
  369. //遮罩层关闭
  370. $ionicLoading.hide();
  371. }, function() {
  372. $ionicLoading.hide();
  373. });
  374. }
  375. //页面加载
  376. // $scope.reload();
  377. //跳转成功刷新页面
  378. // $scope.$on('$stateChangeSucess', $scope.reload());
  379. if (!sessionStorage.sessionLogin) {
  380. var promise = getLoginUser.query();
  381. promise.then(function(sessionLogin) { //返回成功
  382. $scope.tokenType = sessionLogin.tokenType;
  383. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  384. var loginUser = sessionLogin.user;
  385. $scope.sessionLogin = sessionLogin
  386. $rootScope.user = sessionLogin.user;
  387. $scope.defaultData = {
  388. 'assignee': loginUser.id,
  389. 'idx': 0,
  390. 'sum': 10,
  391. // 'candidateGroups': loginUser.group["0"].id
  392. };
  393. $scope.filterData = {
  394. 'assignee': loginUser.id,
  395. 'idx': 0,
  396. 'sum': 10,
  397. };
  398. $scope.reload()
  399. }, function(data) { //返回失败
  400. });
  401. } else {
  402. var sessionLogin = JSON.parse(sessionStorage.sessionLogin);
  403. var loginUser = sessionLogin.user;
  404. $scope.sessionLogin = sessionLogin
  405. $rootScope.user = sessionLogin.user;
  406. $scope.defaultData = {
  407. 'assignee': loginUser.id,
  408. 'idx': 0,
  409. 'sum': 10,
  410. // 'candidateGroups': loginUser.group["0"].id
  411. };
  412. $scope.filterData = {
  413. 'assignee': loginUser.id,
  414. 'idx': 0,
  415. 'sum': 10,
  416. };
  417. $scope.reload()
  418. }
  419. }]);
  420. app.controller('handlerExtendCtrl', ['$scope', '$rootScope', '$http', function($scope, $rootScope, $http) {
  421. //判断当前事件状态
  422. // if ($scope.item.state.id != null && $scope.item.state.id != 6 && $scope.item.handlerUser != null) {
  423. // if ($rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) {
  424. // $scope.item.chaozuoPower = true;
  425. // } else {
  426. // // angular.forEach($rootScope.user.group, function(userItem) {
  427. // // angular.forEach($scope.item.handlerUser.group, function(handlerUserItem) {
  428. // // if (handlerUserItem == userItem.id) {
  429. // // $scope.item.chaozuoPower = true;
  430. // // }
  431. // // });
  432. // // });
  433. // }
  434. // }
  435. // if ($scope.item.state && $scope.item.state != null) {
  436. // $scope.item.chaozuoPower = true;
  437. // }
  438. if ($scope.item.state == 0 && $rootScope.user.id && $rootScope.user.id == $scope.item.handlerUser.id) {
  439. $scope.item.chaozuoPower = true;
  440. }
  441. // if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  442. // if ($rootScope.user.id == $scope.item.handlerUser.id) {
  443. // $scope.item.chaozuoPower = true;
  444. // }
  445. // }
  446. $scope.look = function() {
  447. $scope.$parent.$parent.$parent.lookFunction($scope.item);
  448. };
  449. $scope.edit = function() {
  450. $scope.$parent.$parent.$parent.editorFunction($scope.item);
  451. };
  452. }]);