incidentListMobileCtrl.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. app.controller('incidentListMobileCtrl', ["$rootScope", "$scope", "i18nService", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_user_data", "api_solution", "api_bpm_domain", "api_bpm_data", "$aside", function($rootScope, $scope, i18nService, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_solution, api_bpm_domain, api_bpm_data, $aside) {
  2. $scope.langs = i18nService.getAllLangs();
  3. $scope.lang = 'zh-cn';
  4. i18nService.setCurrentLang($scope.lang);
  5. var loginUser = $rootScope.user;
  6. var pdKey = $state.current.pdKey;
  7. // $rootScope.app.topTitle = '事件列表';
  8. var incidentListMobileParameter = {
  9. 'assignee': loginUser.id,
  10. 'idx': 0,
  11. 'sum': 10,
  12. 'status': '',
  13. 'count': 0,
  14. 'currentPage': 1,
  15. 'endPage': 0,
  16. 'pages': []
  17. }
  18. //本地数据初始化
  19. sessionStorage.incidentListMobileParameter = JSON.stringify(incidentListMobileParameter);
  20. if ($rootScope.user.group) {
  21. if ($rootScope.user.group.length == 0) {
  22. SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
  23. } else {
  24. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  25. angular.extend(filterData, { "candidateGroups": $rootScope.user.group[0].id, });
  26. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  27. }
  28. }
  29. $scope.transferTime = function(time) {
  30. return moment(time).format('YYYY-MM-DD ');
  31. }
  32. $scope.transferStatus = function(status) {};
  33. $scope.paginationList = {};
  34. //新增数据
  35. $scope.addData = function() {
  36. var data = JSON.parse(sessionStorage.incidentListMobileParameter);
  37. if (data.formUiEdit) {
  38. var formUiEdit = data.formUiEdit;
  39. };
  40. if (data.formUiName) {
  41. var formUiName = data.formUiName;
  42. };
  43. if (data.processKey) {
  44. var pdKey = data.processKey;
  45. };
  46. if (data.formUiStart) {
  47. var formUiStart = data.formUiStart;
  48. };
  49. if (pdKey) {
  50. $state.go('app.incidentMobile.incidentEditorMobile', {
  51. 'pdKey': pdKey,
  52. 'formUiEdit': formUiEdit,
  53. 'formUiName': formUiName,
  54. 'formUiStart': formUiStart,
  55. 'userId': data.status
  56. });
  57. } else {
  58. SweetAlert.swal({
  59. title: "当前服务类型不可新建",
  60. // text: myData.data,
  61. type: "warning"
  62. });
  63. }
  64. };
  65. // $scope.newincident = function(data) {
  66. // $state.go('app.incident.editor', {});
  67. // };
  68. // $scope.selectRowFunction = function(data) {
  69. // $state.go('app.incident.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId });
  70. // };
  71. // $scope.followFunction = function(data) {
  72. // //console.log('data='+JSON.stringify(data));
  73. // $state.go('app.detail', { formKey: 'statusform', pdKey: 'incident', dataId: data.id, processInstanceId: data.processInstanceId });
  74. // };
  75. $scope.addNewFunction = function() {
  76. $state.go('app.incidentMobile.incidentEditorMobile', {});
  77. };
  78. //跳转到编辑列表
  79. $scope.editorFunction = function(data) {
  80. // $state.go('app.inspection.inspectListEditor', {
  81. // "taskId": data.taskId,
  82. // "processInstanceId": data.processInstanceId,
  83. // "pdKey": data.processKey,
  84. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  85. // // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  86. // });
  87. $state.go('app.incidentMobile.incidentEditorMobile', {
  88. taskId: data.taskId,
  89. processInstanceId: data.processInstanceId
  90. });
  91. };
  92. //跳转到查看列表
  93. $scope.lookFunction = function(data) {
  94. $state.go('app.incidentMobile.incidentDetailMobile', {
  95. // "formKey": data.inspection.inspectionTypeDTO.formUiName,
  96. // "dataId": data.id,
  97. // "taskId": data.taskId,
  98. // "processInstanceId": data.processInstanceId,
  99. // "pdKey": data.processKey,
  100. // "formUiEdit": data.inspection.inspectionTypeDTO.formUiEdit,
  101. // "formUiName": data.inspection.inspectionTypeDTO.formUiName,
  102. "formKey": 'incident_back',
  103. "pdKey": 'incident',
  104. "dataId": data.id,
  105. "taskId": data.taskId,
  106. "processInstanceId": data.processInstanceId
  107. });
  108. };
  109. //页面刷新
  110. $scope.reload = function() {
  111. $scope.refreshListData('expand-right');
  112. }
  113. //前往第一页按钮
  114. $scope.paginationFristPage = function() {
  115. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  116. filterData.currentPage = 1;
  117. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  118. $scope.refreshListData('expand-right');
  119. }
  120. //前往最后一页按钮
  121. $scope.paginationLastPage = function() {
  122. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  123. filterData.currentPage = filterData.endPage;
  124. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  125. $scope.refreshListData('expand-right');
  126. }
  127. //加载某一页
  128. $scope.paginationLoadPage = function(page) {
  129. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  130. filterData.currentPage = page;
  131. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  132. $scope.refreshListData('expand-right');
  133. }
  134. //初始化分页栏
  135. var reloadPno = function() {
  136. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  137. filterData.pages = calculateIndexes(filterData.currentPage, filterData.endPage, 4);
  138. $scope.paginationList = filterData;
  139. };
  140. //分页算法
  141. var calculateIndexes = function(current, length, displayLength) {
  142. var indexes = [];
  143. var start = Math.round(current - displayLength / 2);
  144. var end = Math.round(current + displayLength / 2);
  145. if (start <= 1) {
  146. start = 1;
  147. end = start + displayLength - 1;
  148. if (end >= length - 1) {
  149. end = length - 1;
  150. }
  151. }
  152. if (end >= length - 1) {
  153. end = length;
  154. start = end - displayLength + 1;
  155. if (start <= 1) {
  156. start = 1;
  157. }
  158. }
  159. for (var i = start; i <= end; i++) {
  160. indexes.push(i);
  161. }
  162. return indexes;
  163. };
  164. //数据加载
  165. $scope.ldloading = {};
  166. $scope.refreshListData = function(style) {
  167. //刷新按钮动画
  168. $scope.ldloading[style.replace('-', '_')] = true;
  169. //获取本地数据
  170. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  171. //对接口参数进行重新组装
  172. var showData = {
  173. 'assignee': filterData.assignee,
  174. 'idx': filterData.currentPage ? filterData.currentPage - 1 : 0,
  175. 'searchType': filterData.searchType,
  176. 'status': filterData.status,
  177. 'sum': filterData.sum,
  178. };
  179. if (filterData.candidateGroups) {
  180. angular.extend(showData, { 'candidateGroups': filterData.candidateGroups });
  181. };
  182. $scope.myData = [];
  183. api_bpm_domain.fetchtask(pdKey, showData).then(function(data) {
  184. var myData = Restangular.stripRestangular(data);
  185. filterData.count = myData.resultCount;
  186. if (angular.isArray(myData.data) && myData.data.length > 0) {
  187. $scope.myData = myData.data;
  188. $scope.listShow = true;
  189. filterData.endPage = Math.ceil(filterData.count / filterData.sum);
  190. // filterData.currentPage = filterData.pageIndex + 1;
  191. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  192. reloadPno();
  193. angular.forEach($scope.myData, function(ObjIndex) {
  194. if (angular.isUndefined(ObjIndex.extendStatus)) {
  195. angular.extend(ObjIndex, { 'extendStatus': false })
  196. }
  197. });
  198. } else {
  199. // SweetAlert.swal({
  200. // title: "数据为空",
  201. // text: myData.data,
  202. // type: "warning"
  203. // });
  204. // if ($scope.paginationList || $scope.paginationList.count) {
  205. // $scope.paginationList.count = 0;
  206. // }
  207. $scope.listShow = false;
  208. }
  209. $scope.ldloading[style.replace('-', '_')] = false;
  210. }, function() {
  211. $scope.ldloading[style.replace('-', '_')] = false;
  212. });
  213. }
  214. $scope.openAside = function(position) {
  215. var asideOpen = $aside.open({
  216. templateUrl: 'assets/views/incident/incidentListMoblieDetail.html',
  217. placement: position,
  218. size: 'sm',
  219. backdrop: true,
  220. controller: function($scope, $modalInstance, api_user_data, api_solution, inspectListMobileCtrlTree) {
  221. var searchCriteria = {
  222. // 'searchType': '',
  223. // 'status': '',
  224. };
  225. // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  226. // searchCriteria.searchType = "";
  227. // searchCriteria.status = "";
  228. $scope.ok = function(e) {
  229. $modalInstance.close(searchCriteria);
  230. // e.stopPropagation();
  231. };
  232. $scope.cancel = function(e) {
  233. $modalInstance.dismiss();
  234. // e.stopPropagation();
  235. };
  236. $scope.statuses = [
  237. { status: 'all', label: '全部的事件', idName: 'a' },
  238. { status: 'todo', label: '待我处理的', idName: 'b' },
  239. { status: 'create', label: '我创建的', idName: 'c' },
  240. { status: 'done', label: '我处理过的', idName: 'd' },
  241. // { status: 's', label: '已驳回', idName: 'e' },
  242. // { status: '6', label: '已拒绝', idName: 'f' }
  243. ];
  244. //获取服务请求类型
  245. $scope.onChange = function(searchType) {
  246. // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  247. if (angular.isUndefined(searchType)) {
  248. searchCriteria.searchType = $scope.searchType;
  249. } else {
  250. searchCriteria.searchType = searchType;
  251. }
  252. // sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  253. }
  254. //通过树型控件获取服务请求分类
  255. $scope.my_tree_handler = function(branch) {
  256. // var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  257. var filterData = {};
  258. searchCriteria.status = branch.id;
  259. if (branch.formUiEdit) {
  260. filterData.formUiEdit = branch.formUiEdit;
  261. };
  262. if (branch.formUiName) {
  263. filterData.formUiName = branch.formUiName;
  264. };
  265. if (branch.processKey) {
  266. filterData.processKey = branch.processKey;
  267. };
  268. if (branch.formUiStart) {
  269. filterData.formUiStart = branch.formUiStart;
  270. };
  271. searchCriteria.idx = 0;
  272. angular.extend(searchCriteria, filterData);
  273. // sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  274. };
  275. $scope.my_data = [];
  276. $scope.tree_data = [];
  277. $scope.my_tree = tree = {};
  278. $scope.try_async_load = function() {
  279. api_bpm_data.fetchDataList('incidentType', { "idx": 0, "sum": 1000 }).then(function(response) {
  280. var responseData = inspectListMobileCtrlTree(response);
  281. $scope.my_data = responseData.my_data;
  282. $scope.tree_data = responseData.tree_data;
  283. });
  284. }
  285. $scope.try_async_load();
  286. }
  287. });
  288. asideOpen.result.then(function(searchCriteria) {
  289. if (searchCriteria.searchType || searchCriteria.status) {
  290. var filterData = JSON.parse(sessionStorage.incidentListMobileParameter);
  291. angular.extend(filterData, searchCriteria);
  292. sessionStorage.incidentListMobileParameter = JSON.stringify(filterData);
  293. $scope.refreshListData('expand-right');
  294. } else {
  295. SweetAlert.swal({
  296. title: "条件未选",
  297. text: "请选择服务请求条件",
  298. type: "warning"
  299. });
  300. }
  301. });
  302. };
  303. $scope.refreshListData('expand_right');
  304. // $scope.try_async_load();
  305. }]);
  306. app.factory('inspectListMobileCtrlTree', ['api_bpm_data', function(api_bpm_data) {
  307. function convertListToTree(data, treeMap) {
  308. var idToNodeMap = {};
  309. var root = null;
  310. var parentNode = null;
  311. for (var i = 0; i < data.length; i++) {
  312. var datum = data[i];
  313. datum.children = [];
  314. idToNodeMap[datum.id] = datum;
  315. if (typeof datum.parent === "undefined" || datum.parent == null) {
  316. root = datum;
  317. treeMap[datum.id] = root;
  318. } else {
  319. parentNode = idToNodeMap[datum.parent];
  320. delete datum.parent;
  321. parentNode.children.push(datum);
  322. }
  323. }
  324. return root;
  325. };
  326. function convertParentToChildList(data) {
  327. var treeMap = {};
  328. var list = [];
  329. convertListToTree(data, treeMap);
  330. angular.forEach(treeMap, function(item) {
  331. list.push(item);
  332. });
  333. return list;
  334. };
  335. var forEachEelement = function forEachEelement(response) {
  336. var objects = [];
  337. angular.forEach(response.list, function(ObjIndex, index, destObj) {
  338. var object = {};
  339. object.id = ObjIndex.id;
  340. object.label = ObjIndex.type;
  341. if (ObjIndex.parent && ObjIndex.parent.id != 0) {
  342. object.parent = ObjIndex.parent.id;
  343. };
  344. if (ObjIndex.formUiEdit) {
  345. object.formUiEdit = ObjIndex.formUiEdit;
  346. };
  347. if (ObjIndex.formUiName) {
  348. object.formUiName = ObjIndex.formUiName;
  349. };
  350. if (ObjIndex.processKey) {
  351. object.processKey = ObjIndex.processKey;
  352. };
  353. if (ObjIndex.formUiStart) {
  354. object.formUiStart = ObjIndex.formUiStart;
  355. };
  356. objects.push(object);
  357. });
  358. var my_data = convertParentToChildList(objects);
  359. var tree_data = angular.copy(my_data);
  360. return {
  361. 'my_data': my_data,
  362. 'tree_data': tree_data
  363. }
  364. }
  365. return forEachEelement;
  366. }]);
  367. app.controller('IncidentOperCtrl', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
  368. if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  369. if ($rootScope.user.id == $scope.item.handlerUser.id) {
  370. $scope.item.chaozuoPower = true;
  371. }
  372. };
  373. // $rootScope.callid = $scope.item.callID;
  374. // if ($scope.item.callID) {
  375. // $scope.item.listen = true;
  376. // } else { $scope.item.listen = false; }
  377. // if ($scope.item.state.id != 6 && $scope.item.handlerUser == null) {
  378. // $scope.item.tiquPower = true;
  379. // };
  380. $scope.look = function() {
  381. $scope.$parent.$parent.$parent.lookFunction($scope.item);
  382. };
  383. $scope.edit = function() {
  384. $scope.$parent.$parent.$parent.editorFunction($scope.item);
  385. // console.log('$scope.item='+JSON.stringify($scope.item));
  386. };
  387. // $scope.print = function() { //print
  388. // $scope.colobject.grid.appScope.open($scope.item);
  389. // $scope.doEdit($scope.item.id);
  390. // };
  391. // $scope.record = function() { //record
  392. // $scope.colobject.grid.appScope.play($scope.item);
  393. // $scope.doEdit($scope.item.id);
  394. // };
  395. // $scope.handler = function() {
  396. // $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  397. // $scope.doComment($scope.item.id);
  398. // };
  399. // $scope.follow = function() {
  400. // $scope.colobject.grid.appScope.followFunction($scope.item);
  401. // };
  402. }]);
  403. // app.directive('incidentoperator', function() {
  404. // return {
  405. // restrict: 'E',
  406. // scope: {
  407. // item: '=',
  408. // colobject: '='
  409. // },
  410. // controller: 'IncidentOperCtrl',
  411. // template: '<div><div class="w-3 pull-left paddingIcon center">' +
  412. // '<a ng-click="look()">' +
  413. // '<i class="ti-eye"></i>' +
  414. // '<p class="fontSI">查看</p>' +
  415. // '</a>' +
  416. // '</div>' +
  417. // '<div class="w-3 pull-left paddingIcon center">' +
  418. // '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}">' +
  419. // '<i class="fa fa-pencil"></i>' +
  420. // '<p class="fontSI">操作</p>' +
  421. // '</a>' +
  422. // '</div></div>'
  423. // // '<div><div class="links cl-effect-1 ui-grid-cell-contents" style="height:27px;background-color:{{item.colourInfo.rgb}}">' +
  424. // // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>'+
  425. // // '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip="操作" tooltip-placement="right"><i class="fa fa-pencil-square-o"></i></a>' +
  426. // //'<a ng-click="print()" tooltip="打印" tooltip-placement="left"><i class="ti-printer"></i></a>' +
  427. // //'<a ng-click="record()" ng-show="{{item.listen}}" tooltip="录音" tooltip-placement="left"><i class="ti-microphone"></i></a>' +
  428. // // '<a class="ui-grid-cell-contents" ng-click="grid.appScope.open(row.entity)" tooltip="打印" tooltip-placement="left"><i class="ti-printer"></i></a>'+
  429. // // '<a ng-click="grid.appScope.play(row.entity)"ng-if="row.entity.callID" tooltip="播放录音" tooltip-placement="left"><i class="ti-microphone"></i></a>'+
  430. // // '<a ng-click="handler()" ng-show="{{item.tiquPower}}" tooltip="提取" tooltip-placement="left"><i class="fa fa-pencil"></i></a>'+
  431. // // '<a ng-click="follow()" tooltip="状态跟踪" tooltip-placement="left"><i class="fa fa-location-arrow"></i></a>'+
  432. // //'</div></div>'
  433. // };
  434. // });