problemCtrl.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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, 20, 50, 100];
  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: 'item',
  31. displayName: '序号',
  32. width: '5%',
  33. cellTemplate: '<div>' +
  34. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  35. '</div>',
  36. enableFiltering: false
  37. },
  38. {
  39. name: 'problemsign',
  40. displayName: '问题单号',
  41. width: '125',
  42. enableFiltering: false
  43. },
  44. {
  45. name: 'title',
  46. displayName: '问题标题',
  47. width: '10%',
  48. enableFiltering: false
  49. },
  50. {
  51. name: 'proposePerson.name',
  52. displayName: '问题提出人',
  53. width: '10%',
  54. enableFiltering: false
  55. },
  56. {
  57. name: 'incident.incidentsign',
  58. displayName: '关联事件单号',
  59. width: '130',
  60. enableFiltering: false
  61. },
  62. {
  63. name: 'des',
  64. displayName: '问题描述',
  65. width: '15%',
  66. enableFiltering: false
  67. },
  68. {
  69. name: 'influence',
  70. displayName: '问题影响',
  71. width: '15%',
  72. enableFiltering: false
  73. },
  74. {
  75. name: 'priority.name',
  76. displayName: '优先级',
  77. width: '6%',
  78. minWidth:'55',
  79. enableFiltering: false
  80. },
  81. {
  82. name: 'manager.name',
  83. displayName: '问题经理',
  84. width: '8%',
  85. minWidth:'75',
  86. enableFiltering: false
  87. },
  88. {
  89. name: 'largeClassification.name',
  90. displayName: '问题大类',
  91. width: '9%',
  92. minWidth:'83',
  93. enableFiltering: false
  94. },
  95. {
  96. name: 'currentStage.name',
  97. displayName: '问题状态',
  98. width: '8%',
  99. minWidth:'75',
  100. enableFiltering: false
  101. },
  102. {
  103. name: 'openingTime',
  104. displayName: '问题开启时间',
  105. width: '12%',
  106. minWidth: '150',
  107. enableFiltering: false,
  108. cellTemplate: '<div>' +
  109. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center">{{grid.appScope.transferTime(row.entity.openingTime)}}</div>' +
  110. '</div>'
  111. },
  112. {
  113. name: '操作',
  114. cellTemplate: '<problemoperator item="row.entity" colobject="col">',
  115. width: 100,
  116. enableFiltering: false
  117. }
  118. ];
  119. $scope.searchstate = 'todo';
  120. $scope.states = [{
  121. id: "all",
  122. name: '全部的问题'
  123. },
  124. {
  125. id: "todo",
  126. name: '待我处理的问题'
  127. },
  128. {
  129. id: "create",
  130. name: '我创建的问题'
  131. },
  132. {
  133. id: "done",
  134. name: '我处理过的问题'
  135. }
  136. ];
  137. $scope.onChange = function (searchType) {
  138. $scope.searchstate = searchType;
  139. defaultFilterData = $scope.memoryfilterData;
  140. defaultFilterData['searchType'] = searchType;
  141. $scope.refreshData('expand-right', defaultFilterData);
  142. }
  143. $scope.transferTime = function(time) {
  144. return moment(time).format('YYYY-MM-DD HH:mm');
  145. }
  146. $scope.clear = function () {
  147. $scope.searchkeys = {};
  148. // $scope.try_async_load();
  149. var fildata = JSON.parse(sessionStorage.getItem("searchproblem"));
  150. fildata.assignee = $rootScope.user.id;
  151. fildata.candidateGroups = $rootScope.user.group[0].id;
  152. fildata.idx = 0;
  153. fildata.sum = 10;
  154. delete fildata.problem;
  155. // var fildata = {
  156. // // "assignee": $rootScope.user.id,
  157. // // "candidateGroups": loginuserGroup,
  158. // // "searchType": JSON.parse(sessionStorage.getItem("searchproblem")).searchType,
  159. // // "idx": JSON.parse(sessionStorage.getItem("searchproblem")).idx,
  160. // // "sum": JSON.parse(sessionStorage.getItem("searchproblem")).sum
  161. // "assignee": $rootScope.user.id,
  162. // "candidateGroups": $rootScope.user.group[0].id,
  163. // "idx": 0,
  164. // "sum": 10,
  165. // }
  166. sessionStorage.removeItem("searchproblem");
  167. $scope.memoryfilterData = fildata;
  168. $scope.refreshData('expand-right', fildata);
  169. }
  170. $scope.chiceIncident = function (item, stateid) {
  171. // if (stateid && stateid.code) {
  172. // item.statusId = stateid.code;
  173. // } else {
  174. // item.statusId = undefined;
  175. // }
  176. var fildata = {};
  177. if (sessionStorage.searchproblem) {
  178. fildata = JSON.parse(sessionStorage.getItem("searchproblem"));
  179. $scope.gridOptions.paginationCurrentPage = 1;
  180. fildata.idx = 0;
  181. } else {
  182. fildata = defaultFilterData;
  183. }
  184. // $scope.memoryfilterData = fildata;
  185. if (!fildata.problem) {
  186. fildata['problem'] = {};
  187. }
  188. // if (item.acceptDate) {
  189. // item.acceptDate = moment(item.acceptDate).format('YYYY-MM-DD HH:mm:ss');
  190. // }
  191. // if (item.acceptDateEnd) {
  192. // // item.acceptDateEnd = moment(item.acceptDateEnd).format('YYYY-MM-DD HH:mm:ss');
  193. // item.acceptDateEnd = moment(new Date(item.acceptDateEnd).getTime() + 86399999).format('YYYY-MM-DD HH:mm:ss');
  194. // }
  195. if (item) {
  196. var transitiondata = angular.copy(item);
  197. angular.extend(fildata.problem, transitiondata)
  198. sessionStorage['searchproblem'] = angular.copy(JSON.stringify(fildata));
  199. }
  200. $scope.memoryfilterData = fildata;
  201. $scope.refreshData('expand-right', fildata);
  202. }
  203. $scope.gridOptions.onRegisterApi = function (gridApi) {
  204. $scope.gridApi = gridApi;
  205. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  206. var filtersData = $scope.memoryfilterData;
  207. filtersData.idx = newPage - 1;
  208. filtersData.sum = pageSize;
  209. $scope.refreshData('expand-right', filtersData);
  210. });
  211. gridApi.core.on.filterChanged($scope, function () {
  212. var grid = this.grid;
  213. var filtersData = {
  214. "assignee": $rootScope.user.id,
  215. "candidateGroups": $rootScope.user.group[0].id,
  216. idx: 0,
  217. sum: 10
  218. };
  219. angular.forEach(grid.columns, function (item) {
  220. if (item.enableFiltering) {
  221. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  222. // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
  223. if (angular.isUndefined(filtersData['problem'])) {
  224. filtersData['problem'] = {};
  225. }
  226. filtersData['problem'][item.field] = item.filters[0].term;
  227. }
  228. }
  229. });
  230. $scope.memoryfilterData = filtersData;
  231. $scope.refreshData('expand-right', filtersData);
  232. });
  233. };
  234. $scope.memoryfilterData = defaultFilterData = {
  235. "assignee": $rootScope.user.id,
  236. "candidateGroups": $rootScope.user.group[0].id,
  237. "idx": 0,
  238. "sum": 10
  239. };
  240. $scope.selectRowFunction = function (data) {
  241. console.log(data);
  242. // $state.go('app.process.modeler',{modelId:data.id});
  243. $state.go('app.problem.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId,dataId:data.id});
  244. };
  245. $scope.onDblClick = function (data) {
  246. //console.log(row.entity);
  247. $state.go('app.detail', {
  248. formKey: 'problemDetail',
  249. pdKey: 'problem',
  250. dataId: data.entity.id,
  251. taskId: data.entity.taskId,
  252. processInstanceId: data.entity.processInstanceId
  253. });
  254. };
  255. /*
  256. appScopeProvider: {
  257. onDblClick : function(row) {
  258. var url = '//google.com';
  259. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  260. }
  261. },
  262. 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>"
  263. */
  264. this.removeRowFunction = function (data) {
  265. //TODO $translate('key')
  266. SweetAlert.swal({
  267. title: "确认删除?",
  268. text: "删除以后,你将不能恢复该数据!",
  269. type: "warning",
  270. cancelButtonText: "取消",
  271. showCancelButton: true,
  272. confirmButtonColor: "#DD6B55",
  273. confirmButtonText: "确认删除!"
  274. }, function (isConfirm) {
  275. if (isConfirm) {
  276. // api_bpm_domain.removemodel(data.id).then(function(response){
  277. // if(response){
  278. // $scope.refreshData();
  279. // SweetAlert.swal({
  280. // title: "删除成功!",
  281. // confirmButtonColor: "#007AFF"
  282. // });
  283. // }
  284. // });
  285. } else {
  286. }
  287. });
  288. }
  289. //$scope.callsPending = 0;
  290. //var i = 0;
  291. var defaultFilterData = {
  292. "assignee": $rootScope.user.id,
  293. "candidateGroups": $rootScope.user.group[0].id,
  294. "idx": 0,
  295. "sum": 10,
  296. };
  297. if (angular.isDefined($rootScope['searchproblem'])) {
  298. defaultFilterData['searchType'] = $rootScope['searchproblem'];
  299. $scope.searchTypes = $rootScope['searchproblem']
  300. }
  301. $scope.ldloading = {};
  302. $scope.refreshData = function (style, filterData) {
  303. $scope.ldloading[style.replace('-', '_')] = true;
  304. if (angular.isUndefined(filterData)) {
  305. filterData = defaultFilterData;
  306. }
  307. if (angular.isDefined($scope.searchTypes)) {
  308. filterData['searchType'] = $scope.searchTypes;
  309. $rootScope['searchproblem'] = $scope.searchTypes;
  310. sessionStorage['searchproblem'] = $scope.searchTypes;
  311. }
  312. $scope.myData = [];
  313. //var start = new Date();
  314. //var sec = $interval(function () {
  315. //$scope.callsPending++;
  316. api_bpm_domain.fetchtask(pdKey, filterData).then(function (data) {
  317. $scope.callsPending--;
  318. // console.log('filterData='+JSON.stringify(filterData));
  319. var myData = Restangular.stripRestangular(data);
  320. $scope.gridOptions.totalItems = myData.resultCount;
  321. $scope.myData = myData.data;
  322. $scope.ldloading[style.replace('-', '_')] = false;
  323. for (var i = 0; i < $scope.myData.length; i++) {
  324. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  325. }
  326. }, function () {
  327. $scope.ldloading[style.replace('-', '_')] = false;
  328. });
  329. };
  330. $scope.refreshData('expand-right', defaultFilterData);
  331. }]);
  332. app.controller('ProblemOperCtrl', ['$rootScope', '$http', '$scope', function ($rootScope, $http, $scope, $event) {
  333. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  334. if ($scope.item.handlerUser != null) {
  335. if ($rootScope.user.id == $scope.item.handlerUser.id) {
  336. $scope.item.chaozuoPower = true;
  337. }
  338. }
  339. $scope.look = function () {
  340. $scope.colobject.grid.appScope.onDblClick($scope.item);
  341. // console.log('$scope.item='+JSON.stringify($scope.item));
  342. }
  343. $scope.edit = function () {
  344. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  345. // console.log('$scope.item='+JSON.stringify($scope.item));
  346. $scope.doEdit($scope.item.id);
  347. }
  348. }]);
  349. app.directive('problemoperator', function () {
  350. return {
  351. restrict: 'E',
  352. scope: {
  353. item: '=',
  354. colobject: '='
  355. },
  356. controller: 'ProblemOperCtrl',
  357. template: '<div class="links cl-effect-1">' +
  358. // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
  359. '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip-placement="left" class="jry_bj">处理</a>' +
  360. '</div>'
  361. };
  362. });