reServiceCtrl-1.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. app.controller('reServiceManagerCtrl', ["$rootScope","$scope","i18nService", "$state", "$timeout", "$interval", "SweetAlert", "$modal", "FileUploader", "i18nService", "uiGridConstants", "uiGridGroupingConstants", "Restangular","api_user_data","api_solution","api_bpm_domain","api_bpm_data", function ($rootScope, $scope,i18nService, $state, $timeout, $interval, SweetAlert, $modal, FileUploader, i18nService, uiGridConstants, uiGridGroupingConstants, Restangular, api_user_data, api_solution,api_bpm_domain,api_bpm_data) {
  2. $scope.langs=i18nService.getAllLangs();
  3. $scope.lang = 'zh-cn';
  4. i18nService.setCurrentLang($scope.lang);
  5. var loginUser=$rootScope.user;
  6. // console.log(' loginUser='+JSON.stringify( loginUser));
  7. //for test
  8. // loginUser = {
  9. // id:2,
  10. // name:'李进'
  11. // };
  12. //console.log(loginUser);
  13. $scope.gridOptions = {};
  14. $scope.gridOptions.data = 'myData';
  15. $scope.gridOptions.enableColumnResizing = true;
  16. $scope.gridOptions.enableFiltering = false;
  17. $scope.gridOptions.enableGridMenu = false;
  18. $scope.gridOptions.enableRowSelection = true;
  19. $scope.gridOptions.showGridFooter = true;
  20. $scope.gridOptions.showColumnFooter = false;
  21. $scope.gridOptions.fastWatch = true;
  22. $scope.gridOptions.useExternalPagination = true;
  23. $scope.gridOptions.paginationPageSizes = [10];
  24. $scope.gridOptions.paginationPageSize = 10;
  25. $scope.gridOptions.multiSelect = true;
  26. //var mun = $scope.gridOptions.paginationPageSize;s
  27. $scope.gridOptions.rowIdentity = function(row) {
  28. return row.id;
  29. };
  30. $scope.gridOptions.getRowIdentity = function(row) {
  31. return row.id;
  32. };
  33. $scope.transferTime = function(time){
  34. return moment(time).format('YYYY-MM-DD ');
  35. }
  36. $scope.transferStatus = function(status){}
  37. $scope.gridOptions.columnDefs = [
  38. /*{
  39. name: 'item',
  40. displayName: '编号',
  41. width: '5%',
  42. enableFiltering: false
  43. }, //编号*/
  44. {
  45. name: '查看',
  46. width: '5%',
  47. enableFiltering: false,
  48. cellTemplate: '<div class="links cl-effect-1">' +
  49. '<a class="ui-grid-cell-contents" ng-click="grid.appScope.lookReService(row.entity)" tooltip="查看" tooltip-placement="left"><i class="ti-eye"></i></a>' +
  50. '</div>'
  51. }, //查看
  52. {
  53. name: '编辑',
  54. width: '5%',
  55. enableFiltering: false,
  56. cellTemplate: '<div class="links cl-effect-1">'+'<a class="ui-grid-cell-contents" ng-click="grid.appScope.editorReService(row.entity)" tooltip="编辑" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>'+'</div>'
  57. }, //编辑
  58. {
  59. name: 'category.recate',
  60. displayName: '服务目录',
  61. width: '10%'
  62. }, //标题
  63. {
  64. name: 'stateName',
  65. displayName: '状态',
  66. width: '10%'
  67. }, //状态
  68. {
  69. name: 'handlerUser.name',
  70. displayName: '处理人',
  71. width: '10%'
  72. }, //开始时间
  73. {
  74. name: 'startDate',
  75. displayName: '创建时间',
  76. width: '20%'
  77. }, //开始时间
  78. ];
  79. $scope.allfilterData={
  80. key:'null',
  81. status:0,
  82. pageIndex:0,
  83. pageSum:10,
  84. //treeIds:'[]',
  85. userId:loginUser.id
  86. }
  87. $scope.gridOptions.onRegisterApi = function(gridApi){
  88. $scope.gridApi = gridApi;
  89. gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
  90. var filtersData = $scope.allfilterData;
  91. // console.log(filtersData)
  92. filterData.pageIndex = newPage-1;
  93. var data = {pageIndex:newPage-1};
  94. var dataFilter = angular.extend(data,filterData);
  95. dataFilter.status=filtersData.status;
  96. // console.log(dataFilter)
  97. $scope.refreshListData('expand-right',dataFilter);
  98. });
  99. gridApi.selection.on.rowSelectionChanged($scope, function(data){
  100. $scope.selected.item = data.entity;
  101. });
  102. };
  103. this.selectRowFunction = function(data){};
  104. //分类显示
  105. $scope.onChange = function(searchType) {
  106. defaultFilterData.status = JSON.parse(sessionStorage.branchReService).id;
  107. defaultFilterData['searchType'] = searchType;
  108. if(defaultFilterData.searchType){
  109. $scope.refreshListData('expand-right', defaultFilterData);
  110. }
  111. }
  112. //数据加载
  113. $scope.refreshListData = function(style,filterData){
  114. //$scope.ldloading[style.replace('-', '_')] = true;
  115. if(angular.isUndefined(filterData)){
  116. filterData = defaultFilterData;
  117. }
  118. if(angular.isDefined($scope.searchTypes)){
  119. filterData['searchType'] = $scope.searchTypes;
  120. }
  121. $scope.myData = [];
  122. api_bpm_data.fetchServiceTasks(filterData.status,filterData).then(function(data){
  123. var myData = Restangular.stripRestangular(data);
  124. $scope.gridOptions.totalItems = myData.resultCount;
  125. if(angular.isArray(myData.data)){
  126. $scope.myData = myData.data;
  127. console.log(myData.data);
  128. }else{
  129. SweetAlert.swal({
  130. title: "数据为空",
  131. text: myData.data,
  132. type: "warning"
  133. });
  134. }
  135. });
  136. }
  137. $scope.newincident = function(data) {
  138. };
  139. $scope.editorReService = function(data) {
  140. $state.go('app.reService.editor', {
  141. formKey: 'inspection_confirm',
  142. pdKey: 'reService',
  143. taskId: data.taskId,
  144. processInstanceId: data.processInstanceId
  145. });
  146. }
  147. $scope.lookReService = function(data){
  148. $state.go('app.reService.detail', {
  149. formKey: 'inspection_detail',
  150. pdKey: 'serviceCatalogueProcessActual',
  151. dataId: data.id,
  152. processInstanceId: data.processInstanceId
  153. });
  154. }
  155. $scope.editSolution = function(id){}
  156. var apple_selected, tree, treedata_avm, treedata_geography;
  157. //$scope.selectedTreeNode = {};
  158. $scope.my_tree_handler = function (branch) {
  159. sessionStorage['branchReService']=JSON.stringify(branch);
  160. defaultFilterData.status = branch.id;
  161. //$scope.selectedTreeNode = branch;
  162. $scope.refreshListData('expand-right', defaultFilterData);
  163. };
  164. $scope.my_data = [];
  165. $scope.tree_data = [];
  166. $scope.my_tree = tree = {};
  167. function convertListToTree(data, treeMap){
  168. var idToNodeMap = {}; //Keeps track of nodes using id as key, for fast lookup
  169. var root = null; //Initially set our loop to null
  170. var parentNode = null;
  171. //loop over data
  172. for(var i = 0; i < data.length; i++) {
  173. var datum = data[i];
  174. //each node will have children, so let's give it a "children" poperty
  175. datum.children = [];
  176. //add an entry for this node to the map so that any future children can
  177. //lookup the parent
  178. idToNodeMap[datum.id] = datum;
  179. //Does this node have a parent?
  180. if(typeof datum.parent === "undefined" || datum.parent == null) {
  181. //Doesn't look like it, so this node is the root of the tree
  182. root = datum;
  183. treeMap[datum.id] = root;
  184. } else {
  185. //This node has a parent, so let's look it up using the id
  186. parentNode = idToNodeMap[datum.parent];
  187. //We don't need this property, so let's delete it.
  188. delete datum.parent;
  189. //Let's add the current node as a child of the parent node.
  190. parentNode.children.push(datum);
  191. }
  192. }
  193. return root;
  194. }
  195. function convertParentToChildList(data){
  196. var treeMap = {};
  197. var list=[];
  198. convertListToTree(data, treeMap);
  199. angular.forEach(treeMap,function(item){
  200. list.push(item);
  201. });
  202. return list;
  203. }
  204. //var uploader = $scope.uploader = new FileUploader({});
  205. //$scope.removeKnowledgeType = function(){}
  206. //
  207. //$scope.editKnowledgeType = function(flag,size){}
  208. //
  209. //$scope.createKnowledge = function(size){}
  210. $scope.my_tree = tree = {};
  211. //树型控件加载
  212. $scope.try_async_load = function () {
  213. $scope.my_data = [];
  214. $scope.doing_async = true;
  215. api_bpm_data.fetchDataList('requestcategory',{ "idx": 0,"sum": 1000}).then(function(response){
  216. if(response.status==200){
  217. var data = response.list;
  218. var objects = [];
  219. for (var i = 0; i < data.length; i++) {
  220. var object = {};
  221. object.id = data[i].id;
  222. if(data[i].parent&&data[i].parent.id != 0){
  223. object.parent = data[i].parent.id;
  224. }
  225. object.label = data[i].recate;
  226. object.actions = data[i].actions; //权限部分
  227. object.group = "1";
  228. object.user = "2";
  229. object.state = {
  230. "opened": true
  231. };
  232. object.typeName = "type";
  233. objects.push(object);
  234. }
  235. $scope.my_data = convertParentToChildList(objects);
  236. $scope.tree_data = angular.copy($scope.my_data);
  237. if($scope.my_data.length>0){
  238. $scope.doing_async = false;
  239. }
  240. }else{
  241. SweetAlert.swal({
  242. title: "系统错误!",
  243. text: "请刷新重试!",
  244. type: "error"
  245. });
  246. }
  247. });
  248. $scope.showAddSolutionType = false; //添加知识类型 按钮
  249. $scope.showReviewKnowledgeType = false; //审核知识类型 按钮
  250. };
  251. var defaultFilterData = {
  252. assignee : loginUser.id,
  253. idx : 0 ,
  254. sum : 10 ,
  255. status: ''
  256. }
  257. $scope.refreshListData('expand-right', defaultFilterData);
  258. $scope.try_async_load();
  259. //
  260. //$scope.ldloading={};
  261. //
  262. //$scope.statuses = [];
  263. //
  264. //$scope.$watch('searchSolutionInput',function(oldvalue,newvalue){});
  265. //
  266. //$scope.filterSolutionStatus = function(filterStatus){}
  267. //
  268. //$scope.searchSolution = function(){}
  269. //
  270. $scope.reload = function(){}
  271. $scope.reload();
  272. }]);