releaseCtrl.js 14 KB

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