problemCtrl.js 12 KB

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