releaseCtrl.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. 'use strict';
  2. app.controller('releaseListCtrl', ["$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. var pdKey = $state.current.pdKey;
  4. $scope.langs = i18nService.getAllLangs();
  5. $scope.lang = 'zh-cn';
  6. i18nService.setCurrentLang($scope.lang);
  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. $scope.gridOptions.rowIdentity = function(row) {
  23. return row.id;
  24. };
  25. $scope.gridOptions.getRowIdentity = function(row) {
  26. return row.id;
  27. };
  28. // $scope.gridOptions.columnDefs = [
  29. // { name:'id', width:100, enableFiltering:false},
  30. // { name:'deploymentId', displayName:'部署Id', width:100, enableFiltering:false},
  31. // { name:'name', displayName:'名称', width:100 },
  32. // { name:'key', displayName:'KEY', width:200 },
  33. // { name:'version', displayName:'版本号', width:100},
  34. // { name:'最后更新时间',field:'lastUpdateTime', cellFilter:'date', width:150, type:'date', enableFiltering:false },
  35. // { name:'创建时间',field:'createTime', cellFilter: 'date', width:150, type:'date', enableFiltering:false},
  36. // { name:'操作', cellTemplate:'<a class="btn btn-sm btn-info" ng-click="grid.appScope.pdList.selectRowFunction(row.entity)"><i class="fa fa-pencil-square-o"/></a><a class="btn btn-sm btn-warning" ng-click="grid.appScope.pdList.removeRowFunction(row.entity)"><i class="fa fa-trash"/></a>', enableFiltering:false}
  37. // ];
  38. // '<a class="btn btn-sm btn-warning" ng-click="grid.appScope.pdList.removeRowFunction(row.entity)">' + '<i class="fa fa-trash"/></a>'
  39. $scope.gridOptions.columnDefs = [{
  40. name: 'item',
  41. displayName: '序号',
  42. width: '3%',
  43. cellTemplate: '<div>' +
  44. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  45. '</div>',
  46. enableFiltering: false
  47. },
  48. { name: 'releasemsign', displayName: '发布单号', width: '9%', enableFiltering: false },
  49. { name: 'title', displayName: '发布标题', width: '15%', enableFiltering: false },
  50. { name: 'applyUser.name', displayName: '请求人', width: '10%', enableFiltering: false },
  51. { name: 'change.changesign', displayName: '关联变更单号', width: '9%', enableFiltering: false },
  52. { name: 'source.name', displayName: '发布来源', width: '10%', enableFiltering: false },
  53. { name: 'type.name', displayName: '发布类型', width: '10%', enableFiltering: false },
  54. { name: 'registrationTime', displayName: '创建时间', width: '14%', enableFiltering: false },
  55. { name: 'stage.name', displayName: '状态', width: '10%', enableFiltering: false },
  56. { name: '操作', cellTemplate: '<releaseoperator item="row.entity" colobject="col">', width: '10%', enableFiltering: false }
  57. ];
  58. $scope.searchstate = 'todo';
  59. $scope.states = [
  60. { id: "all", name: '全部的问题' },
  61. { id: "todo", name: '待我处理的问题' },
  62. { id: "create", name: '我创建的问题' },
  63. { id: "done", name: '我处理过的问题' }
  64. ];
  65. $scope.onChange = function(searchType) {
  66. $scope.searchstate = searchType;
  67. defaultFilterData = $scope.memoryfilterData;
  68. defaultFilterData['searchType'] = searchType;
  69. $scope.refreshData('expand-right', defaultFilterData);
  70. }
  71. $scope.clear = function() {
  72. $scope.searchkeys = {};
  73. // $scope.try_async_load();
  74. var fildata = JSON.parse(sessionStorage.getItem("searchrelease"));
  75. fildata.assignee = $rootScope.user.id;
  76. fildata.candidateGroups = $rootScope.user.group[0].id;
  77. fildata.idx = 0;
  78. fildata.sum = 10;
  79. delete fildata.release;
  80. // var fildata = {
  81. // "assignee": $rootScope.user.id,
  82. // "candidateGroups": $rootScope.user.group[0].id,
  83. // "idx": 0,
  84. // "sum": 10,
  85. // }
  86. // sessionStorage.removeItem("searchrelease");
  87. sessionStorage['searchrelease'] = angular.copy(JSON.stringify(fildata));
  88. $scope.memoryfilterData = fildata;
  89. $scope.refreshData('expand-right', fildata);
  90. }
  91. $scope.chiceIncident = function(item, stateid) {
  92. var fildata = {};
  93. if (sessionStorage.searchrelease) {
  94. fildata = JSON.parse(sessionStorage.getItem("searchrelease"));
  95. $scope.gridOptions.paginationCurrentPage = 1;
  96. fildata.idx = 0;
  97. } else {
  98. fildata = defaultFilterData;
  99. }
  100. if (!fildata.release) {
  101. fildata['release'] = {};
  102. }
  103. if (item) {
  104. var transitiondata = angular.copy(item);
  105. angular.extend(fildata.release, transitiondata)
  106. sessionStorage['searchrelease'] = angular.copy(JSON.stringify(fildata));
  107. }
  108. $scope.memoryfilterData = fildata;
  109. $scope.refreshData('expand-right', fildata);
  110. }
  111. $scope.gridOptions.onRegisterApi = function(gridApi) {
  112. $scope.gridApi = gridApi;
  113. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  114. var filtersData = $scope.memoryfilterData;
  115. filtersData.idx = newPage - 1;
  116. filtersData.sum = pageSize;
  117. $scope.refreshData('expand-right', filtersData);
  118. // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
  119. });
  120. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  121. // //$scope.selected.item = data.entity;
  122. // // console.log(data);
  123. // });
  124. gridApi.core.on.filterChanged($scope, function() {
  125. var grid = this.grid;
  126. var filtersData = {
  127. "assignee": $rootScope.user.id,
  128. "candidateGroups": $rootScope.user.group[0].id,
  129. idx: 0,
  130. sum: 10
  131. };
  132. angular.forEach(grid.columns, function(item) {
  133. if (item.enableFiltering) {
  134. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  135. // console.log('item.filters[0]='+JSON.stringify(item.filters[0]));
  136. if (angular.isUndefined(filtersData['release'])) {
  137. filtersData['release'] = {};
  138. }
  139. filtersData['release'][item.field] = item.filters[0].term;
  140. }
  141. }
  142. });
  143. $scope.memoryfilterData = filtersData;
  144. $scope.refreshData('expand-right', filtersData);
  145. });
  146. };
  147. $scope.memoryfilterData = defaultFilterData = {
  148. "assignee": $rootScope.user.id,
  149. "candidateGroups": $rootScope.user.group[0].id,
  150. "idx": 0,
  151. "sum": 10
  152. };
  153. $scope.selectRowFunction = function(data) {
  154. console.log(data);
  155. // $state.go('app.process.modeler',{modelId:data.id});
  156. $state.go('app.release.editor', { taskId: data.taskId, processInstanceId: data.processInstanceId });
  157. };
  158. $scope.onDblClick = function(data) {
  159. //console.log(row.entity);
  160. // $state.go('app.detail', { formKey:'releaseDetail', pdKey:'release', dataId: row.entity.id});
  161. $state.go('app.detail', { formKey: 'releaseDetail', pdKey: 'release', dataId: data.entity.id, taskId: data.entity.taskId, processInstanceId: data.entity.processInstanceId });
  162. };
  163. /*
  164. appScopeProvider: {
  165. onDblClick : function(row) {
  166. var url = '//google.com';
  167. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  168. }
  169. },
  170. 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>"
  171. */
  172. this.removeRowFunction = function(data) {
  173. //TODO $translate('key')
  174. SweetAlert.swal({
  175. title: "确认删除?",
  176. text: "删除以后,你将不能恢复该数据!",
  177. type: "warning",
  178. cancelButtonText: "取消",
  179. showCancelButton: true,
  180. confirmButtonColor: "#DD6B55",
  181. confirmButtonText: "确认删除!"
  182. }, function(isConfirm) {
  183. if (isConfirm) {
  184. // api_bpm_domain.removemodel(data.id).then(function(response){
  185. // if(response){
  186. // $scope.refreshData();
  187. // SweetAlert.swal({
  188. // title: "删除成功!",
  189. // confirmButtonColor: "#007AFF"
  190. // });
  191. // }
  192. // });
  193. } else {
  194. }
  195. });
  196. }
  197. //$scope.callsPending = 0;
  198. //var i = 0;
  199. var defaultFilterData = {
  200. "assignee": $rootScope.user.id,
  201. "candidateGroups": $rootScope.user.group[0].id,
  202. "idx": 0,
  203. "sum": 10,
  204. };
  205. if (angular.isDefined($rootScope['searchrelease'])) {
  206. defaultFilterData['searchType'] = $rootScope['searchrelease'];
  207. $scope.searchTypes = $rootScope['searchrelease']
  208. }
  209. $scope.ldloading = {};
  210. $scope.refreshData = function(style, filterData) {
  211. $scope.ldloading[style.replace('-', '_')] = true;
  212. if (angular.isUndefined(filterData)) {
  213. filterData = defaultFilterData;
  214. }
  215. if (angular.isDefined($scope.searchTypes)) {
  216. filterData['searchType'] = $scope.searchTypes;
  217. $rootScope['searchrelease'] = $scope.searchTypes;
  218. }
  219. $scope.myData = [];
  220. //var start = new Date();
  221. //var sec = $interval(function () {
  222. //$scope.callsPending++;
  223. api_bpm_domain.fetchtask(pdKey, filterData).then(function(data) {
  224. $scope.callsPending--;
  225. // console.log('filterData='+JSON.stringify(filterData));
  226. var myData = Restangular.stripRestangular(data);
  227. $scope.gridOptions.totalItems = myData.resultCount;
  228. $scope.myData = myData.data;
  229. $scope.ldloading[style.replace('-', '_')] = false;
  230. for (var i = 0; i < $scope.myData.length; i++) {
  231. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  232. }
  233. }, function() {
  234. $scope.ldloading[style.replace('-', '_')] = false;
  235. });
  236. };
  237. $scope.refreshData('expand-right', defaultFilterData);
  238. }]);
  239. app.controller('ReleaseOperCtrl', ['$rootScope', '$http', '$scope', function($rootScope, $http, $scope, $event) {
  240. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  241. if ($scope.item.handlerUser != null) {
  242. if ($rootScope.user.id == $scope.item.handlerUser.id) {
  243. $scope.item.chaozuoPower = true;
  244. }
  245. }
  246. $scope.look = function() {
  247. $scope.colobject.grid.appScope.onDblClick($scope.item);
  248. // console.log('$scope.item='+JSON.stringify($scope.item));
  249. }
  250. $scope.edit = function() {
  251. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  252. // console.log('$scope.item='+JSON.stringify($scope.item));
  253. $scope.doEdit($scope.item.id);
  254. }
  255. }]);
  256. app.directive('releaseoperator', function() {
  257. return {
  258. restrict: 'E',
  259. scope: {
  260. item: '=',
  261. colobject: '='
  262. },
  263. controller: 'ReleaseOperCtrl',
  264. template: '<div class="links cl-effect-1">' +
  265. // '<a ng-click="look()" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
  266. '<a ng-click="edit()" ng-show="{{item.chaozuoPower}}" tooltip="处理" tooltip-placement="left" class="jry_bj">处理</a>' +
  267. '</div>'
  268. };
  269. });