problemCtrl.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. 'use strict';
  2. app.controller('problemListCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", function($scope, i18nService, $rootScope, $state, $timeout, $interval, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. var pdKey = $state.current.pdKey;
  7. $scope.gridOptions = {};
  8. $scope.gridOptions.data = 'myData';
  9. $scope.gridOptions.enableColumnResizing = true;
  10. $scope.gridOptions.enableFiltering = true;
  11. $scope.gridOptions.enableGridMenu = true;
  12. $scope.gridOptions.enableRowSelection = true;
  13. $scope.gridOptions.showGridFooter = true;
  14. $scope.gridOptions.showColumnFooter = true;
  15. $scope.gridOptions.fastWatch = true;
  16. $scope.gridOptions.useExternalFiltering = true;
  17. $scope.gridOptions.useExternalPagination = true;
  18. $scope.gridOptions.paginationPageSizes = [10];
  19. $scope.gridOptions.paginationPageSize = 10;
  20. $scope.gridOptions.multiSelect = false;
  21. $scope.gridOptions.rowTemplate = "<div ng-dblclick=\"grid.appScope.pdList.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.uid\" ui-grid-one-bind-id-grid=\"rowRenderIndex + '-' + col.uid + '-cell'\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" role=\"{{col.isRowHeader ? 'rowheader' : 'gridcell'}}\" ui-grid-cell></div>";
  22. //
  23. $scope.gridOptions.rowIdentity = function(row) {
  24. return row.id;
  25. };
  26. $scope.gridOptions.getRowIdentity = function(row) {
  27. return row.id;
  28. };
  29. $scope.gridOptions.columnDefs = [
  30. {
  31. name: 'item',
  32. displayName: '序号',
  33. width: '3%',
  34. cellTemplate: '<div>' +
  35. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  36. '</div>', enableFiltering: false
  37. },
  38. { name: 'problemsign', displayName: '问题单号', width: '8%', enableFiltering: false },
  39. { name: 'title', displayName: '问题标题', width: '10%', enableFiltering: false },
  40. { name: 'proposePerson.name', displayName: '问题提出人', width: '6%', enableFiltering: false },
  41. { name: 'incident.incidentsign', displayName: '关联事件单号', width: '8%', enableFiltering: false },
  42. { name: 'des', displayName: '问题描述', width: '15%', enableFiltering: false },
  43. { name: 'influence', displayName: '问题影响', width: '10%', enableFiltering: false },
  44. { name: 'priority.name', displayName: '优先级', width: '5%', enableFiltering: false },
  45. { name: 'manager.name', displayName: '问题经理', width: '5%', enableFiltering: false },
  46. { name: 'largeClassification.name', displayName: '问题大类', width: '7%', enableFiltering: false },
  47. { name: 'currentStage.name', displayName: '问题状态', width: '5%', enableFiltering: false },
  48. { name: 'openingTime', displayName: '问题开启时间', width: '12%', enableFiltering: false },
  49. { name: '操作', cellTemplate: '<problemoperator item="row.entity" colobject="col">', width: 100, enableFiltering: false }
  50. ];
  51. $scope.searchstate = 'todo';
  52. $scope.states = [
  53. { id: "all", name: '全部的问题' },
  54. { id: "todo", name: '待我处理的问题' },
  55. { id: "create", name: '我创建的问题' },
  56. { id: "done", name: '我处理过的问题' }
  57. ];
  58. $scope.onChange = function(searchType) {
  59. $scope.searchstate = searchType;
  60. defaultFilterData = $scope.memoryfilterData;
  61. defaultFilterData['searchType'] = searchType;
  62. $scope.refreshData('expand-right', defaultFilterData);
  63. }
  64. $scope.clear = function() {
  65. $scope.searchkeys = {};
  66. // $scope.try_async_load();
  67. var fildata = JSON.parse(sessionStorage.getItem("searchproblem"));
  68. fildata.assignee = $rootScope.user.id;
  69. fildata.candidateGroups = $rootScope.user.group[0].id;
  70. fildata.idx = 0;
  71. fildata.sum = 10;
  72. delete fildata.problem;
  73. // var fildata = {
  74. // // "assignee": $rootScope.user.id,
  75. // // "candidateGroups": loginuserGroup,
  76. // // "searchType": JSON.parse(sessionStorage.getItem("searchproblem")).searchType,
  77. // // "idx": JSON.parse(sessionStorage.getItem("searchproblem")).idx,
  78. // // "sum": JSON.parse(sessionStorage.getItem("searchproblem")).sum
  79. // "assignee": $rootScope.user.id,
  80. // "candidateGroups": $rootScope.user.group[0].id,
  81. // "idx": 0,
  82. // "sum": 10,
  83. // }
  84. sessionStorage.removeItem("searchproblem");
  85. $scope.memoryfilterData = fildata;
  86. $scope.refreshData('expand-right', fildata);
  87. }
  88. $scope.chiceIncident = function(item, stateid) {
  89. // if (stateid && stateid.code) {
  90. // item.statusId = stateid.code;
  91. // } else {
  92. // item.statusId = undefined;
  93. // }
  94. var fildata = {};
  95. if (sessionStorage.searchproblem) {
  96. fildata = JSON.parse(sessionStorage.getItem("searchproblem"));
  97. $scope.gridOptions.paginationCurrentPage = 1;
  98. fildata.idx = 0;
  99. } else {
  100. fildata = defaultFilterData;
  101. }
  102. // $scope.memoryfilterData = fildata;
  103. if (!fildata.problem) {
  104. fildata['problem'] = {};
  105. }
  106. // if (item.acceptDate) {
  107. // item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD HH:mm:ss');
  108. // }
  109. // if (item.acceptDateEnd) {
  110. // // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD HH:mm:ss');
  111. // item.acceptDateEnd = moment(new Date(item.acceptDateEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss');
  112. // }
  113. if (item) {
  114. var transitiondata = angular.copy(item);
  115. angular.extend(fildata.problem, transitiondata)
  116. sessionStorage['searchproblem'] = angular.copy(JSON.stringify(fildata));
  117. }
  118. $scope.memoryfilterData = fildata;
  119. $scope.refreshData('expand-right', fildata);
  120. }
  121. $scope.gridOptions.onRegisterApi = function(gridApi) {
  122. $scope.gridApi = gridApi;
  123. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  124. var filtersData = $scope.memoryfilterData;
  125. filtersData.idx = newPage - 1;
  126. filtersData.sum = pageSize;
  127. $scope.refreshData('expand-right', filtersData);
  128. });
  129. gridApi.core.on.filterChanged($scope, function() {
  130. var grid = this.grid;
  131. var filtersData = {
  132. "assignee": $rootScope.user.id,
  133. "candidateGroups": $rootScope.user.group[0].id,
  134. idx: 0,
  135. sum: 10
  136. };
  137. angular.forEach(grid.columns, function(item) {
  138. if (item.enableFiltering) {
  139. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  140. // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
  141. if (angular.isUndefined(filtersData['problem'])) {
  142. filtersData['problem'] = {};
  143. }
  144. filtersData['problem'][item.field] = item.filters[0].term;
  145. }
  146. }
  147. });
  148. $scope.memoryfilterData = filtersData;
  149. $scope.refreshData('expand-right', filtersData);
  150. });
  151. };
  152. $scope.memoryfilterData = defaultFilterData = {
  153. "assignee": $rootScope.user.id,
  154. "candidateGroups": $rootScope.user.group[0].id,
  155. "idx": 0,
  156. "sum": 10
  157. };
  158. $scope.selectRowFunction = function(data) {
  159. console.log(data);
  160. // $state.go('app.process.modeler',{modelId:data.id});
  161. $state.go('app.problem.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId });
  162. };
  163. $scope.onDblClick = function(data) {
  164. //console.log(row.entity);
  165. $state.go('app.detail', { formKey: 'problemDetail', pdKey: 'problem', dataId: data.entity.id, taskId: data.entity.taskId, processInstanceId: data.entity.processInstanceId });
  166. };
  167. /*
  168. appScopeProvider: {
  169. onDblClick : function(row) {
  170. var url = '//google.com';
  171. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  172. }
  173. },
  174. rowTemplate: "<div ng-dblclick=\"grid.appScope.onDblClick(row)\" ng-repeat=\"(colRenderIndex, col) in colContainer.renderedColumns track by col.colDef.name\" class=\"ui-grid-cell\" ng-class=\"{ 'ui-grid-row-header-cell': col.isRowHeader }\" ui-grid-cell ></div>"
  175. */
  176. this.removeRowFunction = function(data) {
  177. //TODO $translate('key')
  178. SweetAlert.swal({
  179. title: "确认删除?",
  180. text: "删除以后,你将不能恢复该数据!",
  181. type: "warning",
  182. cancelButtonText: "取消",
  183. showCancelButton: true,
  184. confirmButtonColor: "#DD6B55",
  185. confirmButtonText: "确认删除!"
  186. }, function(isConfirm) {
  187. if (isConfirm) {
  188. // api_bpm_domain.removemodel(data.id).then(function(response){
  189. // if(response){
  190. // $scope.refreshData();
  191. // SweetAlert.swal({
  192. // title: "删除成功!",
  193. // confirmButtonColor: "#007AFF"
  194. // });
  195. // }
  196. // });
  197. } else {
  198. }
  199. });
  200. }
  201. //$scope.callsPending = 0;
  202. //var i = 0;
  203. var defaultFilterData = {
  204. "assignee": $rootScope.user.id,
  205. "candidateGroups": $rootScope.user.group[0].id,
  206. "idx": 0,
  207. "sum": 10,
  208. };
  209. if (angular.isDefined($rootScope['searchproblem'])) {
  210. defaultFilterData['searchType'] = $rootScope['searchproblem'];
  211. $scope.searchTypes = $rootScope['searchproblem']
  212. }
  213. $scope.ldloading = {};
  214. $scope.refreshData = function(style, filterData) {
  215. $scope.ldloading[style.replace('-', '_')] = true;
  216. if (angular.isUndefined(filterData)) {
  217. filterData = defaultFilterData;
  218. }
  219. if (angular.isDefined($scope.searchTypes)) {
  220. filterData['searchType'] = $scope.searchTypes;
  221. $rootScope['searchproblem'] = $scope.searchTypes;
  222. sessionStorage['searchproblem'] = $scope.searchTypes;
  223. }
  224. $scope.myData = [];
  225. //var start = new Date();
  226. //var sec = $interval(function () {
  227. //$scope.callsPending++;
  228. api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  229. $scope.callsPending--;
  230. // console.log('filterData='+JSON.stringify(filterData));
  231. var myData = Restangular.stripRestangular(data);
  232. $scope.gridOptions.totalItems = myData.resultCount;
  233. $scope.myData = myData.data;
  234. $scope.ldloading[style.replace('-', '_')] = false;
  235. for (var i = 0; i < $scope.myData.length; i++) {
  236. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  237. }
  238. }, function() {
  239. $scope.ldloading[style.replace('-', '_')] = false;
  240. });
  241. };
  242. $scope.refreshData('expand-right', defaultFilterData);
  243. }]);
  244. app.controller('ProblemOperCtrl', ['$rootScope', '$http', '$scope', function($rootScope, $http, $scope, $event) {
  245. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  246. if ($scope.item.handlerUser != null) {
  247. if ($rootScope.user.id == $scope.item.handlerUser.id) {
  248. $scope.item.chaozuoPower = true;
  249. }
  250. }
  251. $scope.look = function() {
  252. $scope.colobject.grid.appScope.onDblClick($scope.item);
  253. // console.log('$scope.item='+JSON.stringify($scope.item));
  254. }
  255. $scope.edit = function() {
  256. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  257. // console.log('$scope.item='+JSON.stringify($scope.item));
  258. $scope.doEdit($scope.item.id);
  259. }
  260. }]);
  261. app.directive('problemoperator', function() {
  262. return {
  263. restrict: 'E',
  264. scope: {
  265. item: '=',
  266. colobject: '='
  267. },
  268. controller: 'ProblemOperCtrl',
  269. template: '<div class="links cl-effect-1">' +
  270. // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
  271. '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip-placement="left" class="jry_bj">处理</a>' +
  272. '</div>'
  273. };
  274. });