meansoutCtrl.js 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. 'use strict';
  2. app.controller('meansapplyListCtrl', ["$scope", "$http", "i18nService", "$rootScope", "$state", "$timeout", "moment", "$interval", "$modal", "$stateParams", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_domain", "api_text", "api_bpm_data", "api_user_data", function($scope, $http, i18nService, $rootScope, $state, $timeout, moment, $interval, $modal, $stateParams, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_domain, api_text, api_bpm_data, api_user_data) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. $scope.myData = [];
  7. var loginUser = $rootScope.user;
  8. // var voiceurl=$rootScope.audioiIp;
  9. // delete $rootScope.user.authority;
  10. var pdKey = $state.current.pdKey;
  11. $scope.gridOptions = {};
  12. $scope.gridOptions.data = 'myData';
  13. $scope.gridOptions.enableColumnResizing = true;
  14. $scope.gridOptions.enableFiltering = false;
  15. $scope.gridOptions.enableGridMenu = false;
  16. $scope.gridOptions.enableSelectAll = true;
  17. $scope.gridOptions.enableRowSelection = true;
  18. $scope.gridOptions.showGridFooter = true;
  19. $scope.gridOptions.showColumnFooter = false;
  20. $scope.gridOptions.fastWatch = true;
  21. $scope.gridOptions.enableSorting = true;
  22. $scope.gridOptions.useExternalSorting = true;
  23. $scope.gridOptions.useExternalFiltering = false;
  24. $scope.gridOptions.useExternalPagination = true;
  25. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  26. $scope.gridOptions.paginationPageSize = 10;
  27. $scope.gridOptions.multiSelect = true;
  28. var mun = $scope.gridOptions.paginationPageSize;
  29. $scope.gridOptions.rowTemplate = "<div ng-click=\"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>";
  30. $scope.gridOptions.rowIdentity = function(row) {
  31. return row.id;
  32. };
  33. $scope.gridOptions.getRowIdentity = function(row) {
  34. return row.id;
  35. };
  36. $scope.states = [
  37. { id: 0, name: '待批准' },
  38. { id: 1, name: '已驳回' },
  39. { id: 2, name: '待出库' },
  40. { id: 3, name: '信息更新' },
  41. { id: 4, name: '信息确认' },
  42. { id: 5, name: '已关闭' }
  43. ];
  44. $scope.type = [
  45. { id: 1, name: '资产入库' },
  46. { id: 2, name: '资产归还' },
  47. { id: 3, name: '资产零用' },
  48. { id: 4, name: '资产更换' }
  49. ];
  50. $scope.application = [
  51. { id: 1, name: '申请单编号' },
  52. { id: 2, name: '申请人' },
  53. { id: 3, name: '领用用途' },
  54. { id: 4, name: '设备编号' }
  55. ];
  56. $scope.gridOptions.columnDefs = [{
  57. name: 'item',
  58. displayName: '序号',
  59. width: 50,
  60. cellTemplate: '<div>' +
  61. '<div class="ui-grid-cell-contents">{{row.entity.item}}</div>' +
  62. '</div>'
  63. },
  64. {
  65. name: 'serialNumbe',
  66. displayName: '申请人编号',
  67. width: '15%',
  68. enableSorting: false
  69. },
  70. {
  71. name: 'proposer.name',
  72. displayName: '申请人',
  73. width: '10%',
  74. enableSorting: false
  75. },
  76. {
  77. name: 'area.area',
  78. displayName: '类型',
  79. width: '18%',
  80. enableFiltering: false
  81. },
  82. {
  83. name: 'state.name',
  84. displayName: '状态',
  85. width: '8%',
  86. enableFiltering: false,
  87. },
  88. {
  89. name: 'contactsInformation',
  90. displayName: '环节处理人',
  91. width: '15%'
  92. },
  93. {
  94. name: 'acceptDate',
  95. displayName: '领用用途',
  96. width: '12%',
  97. enableFiltering: false
  98. },
  99. { name: '操作', enableSorting: false, cellTemplate: '<meansoperator style="background-color:{{row.entity.colourInfo.rgb}}" item="row.entity" colobject="col">', enableFiltering: false },
  100. ];
  101. $scope.value = 10;
  102. $scope.decrement = function() {
  103. $scope.value = $scope.value - 1;
  104. };
  105. $scope.record = function() {
  106. api_text.record($rootScope.takes).then(function(data) {
  107. if (data.errno == 0) {
  108. $scope.busy = false;
  109. }
  110. })
  111. };
  112. $scope.parameters = null;
  113. $scope.open = function($event) {
  114. $event.preventDefault();
  115. $event.stopPropagation();
  116. $scope.opened = !$scope.opened;
  117. };
  118. $scope.endOpen = function($event) {
  119. $event.preventDefault();
  120. $event.stopPropagation();
  121. $scope.startOpened = false;
  122. $scope.endOpened = !$scope.endOpened;
  123. };
  124. $scope.startOpen = function($event) {
  125. $event.preventDefault();
  126. $event.stopPropagation();
  127. $scope.endOpened = false;
  128. $scope.startOpened = !$scope.startOpened;
  129. };
  130. $scope.othcode = {};
  131. $scope.chiceIncident = function(parameters, item, stateid) {
  132. if (stateid && stateid.code) {
  133. item.statusId = stateid.code;
  134. }
  135. var fildata = defaultFilterData;
  136. $scope.memoryfilterData = fildata;
  137. if (!fildata.incident) {
  138. fildata['incident'] = {};
  139. }
  140. $scope.gridOptions.paginationCurrentPage = 1;
  141. if (parameters) {
  142. angular.extend(fildata, { 'idx': 0, 'sum': $scope.gridOptions.paginationPageSize })
  143. angular.extend(fildata.incident, { 'acceptDate': moment(parameters.paramDateFrom).format('YYYY-MM-DD HH:mm:ss'), 'acceptDateEnd': moment(parameters.paramDateTo).format('YYYY-MM-DD 23:59:59') })
  144. }
  145. // item.state
  146. // if(item.state){
  147. // }
  148. var transitiondata = angular.copy(item);
  149. // if (transitiondata.searchdatas) {
  150. // fildata.searchType = item.searchdatas.id;
  151. // delete transitiondata.searchdatas;
  152. // }
  153. // if (key.place) {
  154. // angular.extend(fildata.incident, { "place": { "id": key.place.id } })
  155. // }
  156. angular.extend(fildata.incident, transitiondata)
  157. $scope.refreshData('expand-right', fildata);
  158. }
  159. //区域地点过滤
  160. $scope.key = {};
  161. api_user_data.fetchDataList('area', { "idx": 0, "sum": 1000 }).then(function(response) {
  162. if (response) {
  163. if (response.status = 200) {
  164. $scope.outarea = response.list;
  165. }
  166. }
  167. })
  168. //受理人,处理人
  169. $scope.searchkeys = {};
  170. var fieldata = { "idx": 0, "sum": 10, "flag": -1 };
  171. getUser(fieldata, 3);
  172. function getUser(fieldatas, it) {
  173. api_user_data.fetchDataList('user', fieldatas).then(function(data) {
  174. if (it == 1) {
  175. $scope.acceptUser = data.list;
  176. } else if (it == 2) {
  177. $scope.handlingPersonnelUser = data.list;
  178. } else if (it == 3) {
  179. $scope.acceptUser = data.list;
  180. $scope.handlingPersonnelUser = data.list;
  181. }
  182. });
  183. }
  184. //受理人过滤
  185. $scope.onChangeacceptUser = function(key) {
  186. getUser({
  187. "idx": 0,
  188. "sum": 10,
  189. "flag": -1,
  190. "user": { "flag": -1, "name": key }
  191. }, 1);
  192. }
  193. //处理人过滤
  194. $scope.onChangehandling = function(key) {
  195. getuser({
  196. "idx": 0,
  197. "sum": 10,
  198. "flag": -1,
  199. "user": { "flag": -1, "name": key }
  200. }, 2);
  201. }
  202. //状态
  203. api_bpm_data.fetchDataList('incidentstatus', { "idx": 0, "sum": 100 }).then(function(response) {
  204. if (response) {
  205. if (response.status = 200) {
  206. $scope.state = response.list;
  207. }
  208. }
  209. })
  210. //地点区域过滤
  211. $scope.onChangearea = function(data) {
  212. delete $scope.searchkeys.place;
  213. if ($scope.memoryfilterData.incident) {
  214. delete $scope.memoryfilterData.incident.place;
  215. }
  216. var fildata = { "idx": 0, "sum": 1000, "place": { areaId: data.area.id } };
  217. api_user_data.fetchDataList('place', fildata).then(function(response) {
  218. if (response) {
  219. if (response.status = 200) {
  220. $scope.outplace = response.list;
  221. }
  222. }
  223. })
  224. };
  225. $scope.starttime = function(data) {
  226. return moment(new Date(data)).format('YYYY-MM-DD')
  227. }
  228. $scope.overtime = function(data) {
  229. return moment(new Date(data)).format('YYYY-MM-DD HH:mm')
  230. }
  231. $scope.areaplace = function(data) {
  232. if (data.area && data.place) {
  233. if (data.houseNumber) {
  234. return data.area.area + ' ' + data.place.place + ' ' + data.houseNumber;
  235. } else {
  236. return data.area.area + ' ' + data.place.place;
  237. }
  238. } else if (data.area && !data.place) {
  239. if (data.houseNumber) {
  240. return data.area.area + ' ' + data.houseNumber;
  241. } else {
  242. return data.area.area;
  243. }
  244. } else if (!data.area && data.place) {
  245. if (data.houseNumber) {
  246. return data.place.place + ' ' + data.houseNumber;
  247. } else {
  248. return data.place.place;
  249. }
  250. }
  251. }
  252. //录音
  253. $scope.play = function(data) {
  254. // console.log($scope.item.callID)
  255. var modalInstance = $modal.open({
  256. templateUrl: 'assets/views/incident/tpl/audio.html',
  257. controller: function($rootScope, $scope, $modalInstance, $sce) {
  258. $scope.data = {
  259. "name": "视频",
  260. "url": callIp + "/recording/recording?callID=" + data.callID
  261. };
  262. $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  263. // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
  264. $scope.cancel = function() {
  265. $modalInstance.dismiss('cancel');
  266. };
  267. $modalInstance.close();
  268. }
  269. });
  270. };
  271. //列表排序
  272. $scope.gridOptions.onRegisterApi = function(gridApi) {
  273. $scope.gridApi = gridApi;
  274. var index = 0;
  275. var oldheader = {};
  276. gridApi.grid.sortColumn = function(gridApi) {
  277. if (oldheader.field) {
  278. if (oldheader.field == gridApi.field) {
  279. // index = 0;
  280. } else {
  281. index = 0;
  282. }
  283. }
  284. index++;
  285. oldheader = gridApi;
  286. var fildata = $scope.memoryfilterData;
  287. if (index % 3 == 0) {
  288. delete $scope.memoryfilterData.incident;
  289. fildata = $scope.memoryfilterData;
  290. } else if (index % 3 == 1) {
  291. if (fildata.incident) {
  292. if (gridApi.field == "acceptDate") {
  293. angular.extend(fildata.incident, { "sort": gridApi.field });
  294. } else {
  295. angular.extend(fildata.incident, { "sort": gridApi.field + " desc , _incident.acceptDate" });
  296. }
  297. } else {
  298. if (gridApi.field == "acceptDate") {
  299. angular.extend(fildata, { 'incident': { "sort": gridApi.field } });
  300. } else {
  301. angular.extend(fildata, { 'incident': { "sort": gridApi.field + " desc , _incident.acceptDate" } });
  302. }
  303. }
  304. } else if (index % 3 == 2) {
  305. if (fildata.incident) {
  306. if (gridApi.field == "acceptDate") {
  307. angular.extend(fildata.incident, { "sort": gridApi.field, "order": "asc" });
  308. } else {
  309. angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
  310. }
  311. } else {
  312. if (gridApi.field == "acceptDate") {
  313. angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
  314. } else {
  315. angular.extend(fildata.incident, { "sort": gridApi.field + " asc , _incident.acceptDate" });
  316. }
  317. }
  318. // angular.extend(fildata, { 'incident': { "sort": gridApi.field, "order": "asc" } });
  319. }
  320. $scope.refreshData('expand-right', fildata);
  321. }
  322. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  323. var filtersData = $scope.memoryfilterData;
  324. filtersData.idx = newPage - 1;
  325. filtersData.sum = pageSize;
  326. // sessionStorage.idx = JSON.stringify(newPage-1)
  327. $scope.refreshData('expand-right', filtersData);
  328. // $scope.refreshData('expand-right', {"assignee":$rootScope.user.id, "candidateGroups":$rootScope.user.group[0].id, "idx":newPage-1,"sum":pageSize});
  329. });
  330. // gridApi.selection.on.rowSelectionChanged($scope, function(data) {
  331. // data.grid.appScope.selected.items = data.entity
  332. // });
  333. $scope.Change = function(upTypes) {
  334. if (angular.isDefined($scope.selected.items)) {
  335. if (angular.isDefined(upTypes) && upTypes == 'upincident') {
  336. var data = {
  337. cancelUrl: 'app.incident.list',
  338. model: {
  339. problem: {
  340. title: $scope.selected.items.title,
  341. des: $scope.selected.items.description,
  342. proposePerson: $scope.selected.items.handlerUser,
  343. source: {
  344. id: 1,
  345. code: 1,
  346. name: ' 事件 '
  347. },
  348. incident: $scope.selected.items
  349. }
  350. }
  351. }
  352. $state.go('app.problem.incident', { pdKey: 'incident', dataId: $scope.selected.items.id, processInstanceId: $scope.selected.items.processInstanceId, 'model': JSON.stringify(data) });
  353. } else if (angular.isDefined(upTypes) && upTypes == 'upchange') {
  354. var data = {
  355. cancelUrl: 'app.incident.list',
  356. model: {
  357. change: {
  358. title: $scope.selected.items.title,
  359. description: $scope.selected.items.description,
  360. requestingPerson: $scope.selected.items.handlerUser,
  361. source: {
  362. id: 1,
  363. code: 1,
  364. name: ' 事件 '
  365. },
  366. incident: $scope.selected.items
  367. }
  368. }
  369. }
  370. // var data={cancelUrl:'app.incident.list'}
  371. $state.go('app.change.incident', { pdKey: 'incident', dataId: $scope.selected.items.id, processInstanceId: $scope.selected.items.processInstanceId, 'model': JSON.stringify(data) });
  372. }
  373. }
  374. }
  375. $scope.selected = {
  376. items: []
  377. }
  378. gridApi.core.on.filterChanged($scope, function() {
  379. var grid = this.grid;
  380. if ($rootScope.user.group) {
  381. var filtersData = {
  382. "assignee": $rootScope.user.id,
  383. "candidateGroups": $rootScope.user.group[0].id,
  384. idx: 0,
  385. sum: mun
  386. };
  387. } else {
  388. var filtersData = {
  389. "assignee": $rootScope.user.id,
  390. idx: 0,
  391. sum: mun
  392. };
  393. }
  394. angular.forEach(grid.columns, function(item) {
  395. if (item.enableFiltering) {
  396. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  397. filtersData = $scope.memoryfilterData
  398. if (angular.isUndefined(filtersData['incident'])) {
  399. filtersData['incident'] = {};
  400. }
  401. if (item.field == 'requester.name') {
  402. filtersData['incident']['requester'] = {};
  403. filtersData.incident.requester['accountName'] = item.filters[0].term;
  404. } else if (item.field == 'handlingPersonnelUser.name') {
  405. filtersData['incident']['handlingPersonnelUser'] = {};
  406. filtersData.incident.handlingPersonnelUser['name'] = item.filters[0].term;
  407. } else if (item.field == 'requester.account') {
  408. filtersData['incident']['requester'] = {};
  409. filtersData.incident.requester['account'] = item.filters[0].term;
  410. } else if (item.field == 'acceptUser.name') {
  411. filtersData['incident']['acceptUser'] = {};
  412. filtersData.incident.acceptUser['name'] = item.filters[0].term;
  413. } else {
  414. filtersData['incident'][item.field] = item.filters[0].term;
  415. }
  416. }
  417. }
  418. });
  419. filtersData.idx = 0;
  420. $scope.memoryfilterData = filtersData;
  421. $scope.refreshData('expand-right', filtersData);
  422. });
  423. };
  424. //当前人是否分组
  425. if ($rootScope.user.group) {
  426. if ($rootScope.user.group.length == 0) {
  427. SweetAlert.swal("访问失败!", "当前登录人未分配工作组,无权限访问,请添加工作组后重试。", "error");
  428. } else {
  429. $scope.memoryfilterData = defaultFilterData = {
  430. "assignee": $rootScope.user.id,
  431. "candidateGroups": $rootScope.user.group[0].id,
  432. "searchType": "todo",
  433. "idx": 0,
  434. "sum": mun
  435. };
  436. }
  437. } else {
  438. $scope.memoryfilterData = defaultFilterData = {
  439. "assignee": $rootScope.user.id,
  440. "searchType": "todo",
  441. "idx": 0,
  442. "sum": mun
  443. };
  444. }
  445. //打印
  446. $scope.open = function(data) {
  447. var modalInstance = $modal.open({
  448. templateUrl: 'assets/views/incident/tpl/print.html',
  449. controller: function($scope, $modalInstance) {
  450. $scope.printdata = data;
  451. if (!data.emergency) { data['emergency'] = {}; }
  452. if (!data.influence) { data['influence'] = {}; }
  453. if (!data.place) { data['place'] = {}; }
  454. if (!data.influence) { data['influence'] = {}; }
  455. if (!data.emergency) { data['emergency'] = {}; }
  456. if (!data.influence) { data['influence'] = {}; }
  457. var height = $(".groundborder").height()
  458. console.log(height)
  459. $scope.printrequest = [
  460. { name: "事件单号", value: data.incidentsign },
  461. { name: "事件主题", value: data.title },
  462. { name: "事件分类", value: data.category.category },
  463. { name: "紧急度", value: data.emergency.name },
  464. { name: "影响度", value: data.influence.name },
  465. { name: "优先级", value: data.priority.name }
  466. ];
  467. $scope.printrequest['requester'] = [{ nameone: "用户姓名", valueone: data.requester.name, nametwo: "联系电话", valuetwo: data.requester.mphone },
  468. { nameone: "故障地点", valueone: data.place.place, nametwo: "申报时间", valuetwo: data.responseTime }
  469. ];
  470. // $scope.printrequest['requester']=[{name:"用户姓名",value:data.requester.name},
  471. // {name:"联系电话",value:data.requester.mphone},
  472. // {name:"故障地点",value:data.place.place},
  473. // {name:"申报时间",value:data.responseTime}];
  474. $scope.printrequest['incident'] = [{ nameone: "故障工单", valueone: data.incidentsign, nametwo: "故障分类", valuetwo: data.category.category }];
  475. $scope.printrequest['handler'] = [{ name: "故障描述", value: data.description },
  476. { name: "处理人", value: data.handlingPersonnelUser ? data.handlingPersonnelUser.name : '' }
  477. ];
  478. // {name:"处理结果",value:data.handleResult}];
  479. // {name:"用户评价",value:''},
  480. // {name:"满意度",value:''},
  481. // {name:"用户签字",value:''}];
  482. $scope.cancel = function() {
  483. $modalInstance.dismiss('cancel');
  484. };
  485. },
  486. size: 'lg'
  487. });
  488. }
  489. //新建事件
  490. // $scope.newincident = function(data) {
  491. // $state.go('app.incident.editor', {});
  492. // };
  493. //编辑
  494. $scope.selectRowFunction = function(data) {
  495. $state.go('app.means.applyediter', { taskId: data.taskId, processInstanceId: data.processInstanceId });
  496. };
  497. //查看
  498. $scope.onDblClick = function(data) {
  499. // console.log('data='+JSON.stringify(data));
  500. //$state.go('app.detail',{taskId:data.taskId,processInstanceId: data.processInstanceId});
  501. $state.go('app.incident.detail', { formKey: 'incident_back', pdKey: 'incident', dataId: data.entity.id, taskId: data.taskId, processInstanceId: data.entity.processInstanceId });
  502. };
  503. // //查看
  504. // $scope.followFunction = function(data) {
  505. // //console.log('data='+JSON.stringify(data));
  506. // $state.go('app.detail', { formKey: 'statusform', pdKey: 'incident', dataId: data.id, processInstanceId: data.processInstanceId });
  507. // };
  508. //协同人
  509. $scope.coordination = function(data) {
  510. var modalInstance = $modal.open({
  511. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  512. controller: function($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data) {
  513. $scope.langs = i18nService.getAllLangs();
  514. $scope.lang = 'zh-cn';
  515. i18nService.setCurrentLang($scope.lang);
  516. $scope.gridOptions = {};
  517. $scope.gridOptions.data = 'myData';
  518. $scope.gridOptions.enableColumnResizing = true;
  519. $scope.gridOptions.enableFiltering = true;
  520. $scope.gridOptions.enableGridMenu = true;
  521. $scope.gridOptions.showGridFooter = true;
  522. $scope.gridOptions.showColumnFooter = true;
  523. $scope.gridOptions.fastWatch = true;
  524. $scope.gridOptions.useExternalFiltering = true;
  525. $scope.gridOptions.useExternalPagination = true;
  526. $scope.gridOptions.paginationPageSizes = [10];
  527. $scope.gridOptions.paginationPageSize = 10;
  528. $scope.gridOptions.multiSelect = false;
  529. $scope.gridOptions.rowIdentity = function(row) {
  530. return row.id;
  531. };
  532. $scope.gridOptions.getRowIdentity = function(row) {
  533. return row.id;
  534. };
  535. $scope.gridOptions.columnDefs = [
  536. // { name:'id', width:80, enableFiltering:false},
  537. { name: 'account', displayName: '账号', width: 140 },
  538. { name: 'name', displayName: '名称', width: 100 },
  539. { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
  540. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  541. { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
  542. { name: 'dept.dept', displayName: '科室', width: 100, enableFiltering: false },
  543. { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
  544. ];
  545. $scope.gridOptions.onRegisterApi = function(gridApi) {
  546. $scope.gridApi = gridApi;
  547. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  548. var filtersData = $scope.memoryfilterData;
  549. filtersData.idx = newPage - 1;
  550. filtersData.sum = pageSize;
  551. $scope.loadData(filtersData);
  552. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  553. });
  554. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  555. scope.grid.appScope.selected.items[0] = scope.entity;
  556. // $scope.selected.items[0] = scope.entity;
  557. });
  558. gridApi.core.on.filterChanged($scope, function() {
  559. var grid = this.grid;
  560. var filtersData = {
  561. idx: 0,
  562. sum: 10,
  563. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  564. };
  565. angular.forEach(grid.columns, function(item) {
  566. if (item.enableFiltering) {
  567. //console.log("filtersData="+JSON.stringify(filtersData))
  568. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  569. if (angular.isUndefined(filtersData['user'])) {
  570. filtersData['user'] = {};
  571. }
  572. filtersData['user'][item.field] = item.filters[0].term;
  573. }
  574. }
  575. });
  576. $scope.memoryfilterData = filtersData;
  577. $scope.loadData(filtersData);
  578. });
  579. };
  580. $scope.selected = {
  581. items: []
  582. }
  583. var filterData = {
  584. "idx": 0,
  585. "sum": 10,
  586. "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1" }
  587. }
  588. $scope.loadData = function(filterData) {
  589. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  590. api_user_data.fetchDataList('user', filterData).then(function(data) {
  591. var myData = Restangular.stripRestangular(data);
  592. $scope.gridOptions.totalItems = myData.totalNum;
  593. $scope.myData = myData.list;
  594. });
  595. };
  596. $scope.loadData({
  597. idx: 0,
  598. sum: 10,
  599. "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1" }
  600. });
  601. $scope.ok = function() {
  602. $modalInstance.close($scope.selected.items);
  603. };
  604. $scope.cancel = function() {
  605. $modalInstance.dismiss('cancel');
  606. };
  607. },
  608. size: 'lg'
  609. });
  610. modalInstance.result.then(function(selectedItem) {
  611. if (selectedItem) {
  612. var filterData = {
  613. "assginee": selectedItem[0].id
  614. }
  615. api_bpm_domain.delegateTask(data.taskId, filterData).then(function(data) {
  616. if (data && data.status == 200) {
  617. SweetAlert.swal("添加成功!", "添加协同人成功", "success")
  618. $scope.refreshData('expand-right', $scope.memoryfilterData);
  619. } else {
  620. SweetAlert.swal("添加失败!", "请稍候重试", "error");
  621. }
  622. // var myData = Restangular.stripRestangular(data);
  623. // $scope.gridOptions.totalItems = myData.totalNum;
  624. // $scope.myData = myData.list;
  625. });
  626. }
  627. });
  628. }
  629. // $scope.onDblClick = function(row){
  630. // console.log(row.entity);
  631. // if($rootScope.user.id==row.entity.handlerUser.id){$state.go('app.incident.editor',{taskId:row.entity.taskId,processInstanceId: row.entity.processInstanceId});}
  632. // else{$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: row.entity.id});}
  633. // };
  634. /*
  635. appScopeProvider: {
  636. onDblClick : function(row) {
  637. var url = '//google.com';
  638. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  639. }
  640. },
  641. 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>"
  642. */
  643. //删除
  644. $scope.eventDeleted = function(event) {
  645. SweetAlert.swal({
  646. title: "确认删除?",
  647. text: "删除的数据不可恢复,请确认继续操作!",
  648. type: "warning",
  649. showCancelButton: true,
  650. confirmButtonColor: "#DD6B55",
  651. confirmButtonText: "继续删除",
  652. cancelButtonText: "取消操作",
  653. closeOnConfirm: false,
  654. closeOnCancel: false
  655. }, function(isConfirm) {
  656. if (isConfirm) {
  657. api_bpm_schedule.remove([event.id]).then(function(response) {
  658. if (response.status == 200) {
  659. $scope.events.splice(event.id, 1); //有修改的一行
  660. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  661. } else {
  662. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  663. }
  664. });
  665. } else {
  666. SweetAlert.swal("操作取消", "数据安全", "error");
  667. }
  668. });
  669. };
  670. //导出
  671. $scope.export = function() {
  672. // api_bpm_data.downDataModel("incident", 3, $scope.memoryfilterData).then(function(data) {
  673. // console.log(data)
  674. // var file = new Blob([data], {
  675. // // type: 'application/octet-stream'
  676. // type: 'application/vnd.ms-excel'
  677. // });
  678. // //trick to download store a file having its URL
  679. // var fileURL = URL.createObjectURL(file);
  680. // var a = document.createElement('a');
  681. // a.href = fileURL;
  682. // a.target = '_blank';
  683. // a.download = '事件列表.xls';
  684. // document.body.appendChild(a);
  685. // a.click();
  686. // })
  687. // $scope.ldloading[style.replace('-', '_')] = true;
  688. var filadata = angular.copy($scope.memoryfilterData);
  689. filadata.sum = 10000;
  690. $http({
  691. url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
  692. method: 'POST',
  693. data: JSON.stringify(filadata),
  694. headers: {
  695. // 'Content-type': 'application/xls',
  696. 'Accept': '*/*'
  697. },
  698. responseType: 'arraybuffer'
  699. }).success(function(data, status, headers, config) {
  700. // $scope.ldloading.zoom_in = false;
  701. var file = new Blob([data], {
  702. type: 'application/vnd.ms-excel'
  703. });
  704. //trick to download store a file having its URL
  705. var fileURL = URL.createObjectURL(file);
  706. var a = document.createElement('a');
  707. a.href = fileURL;
  708. a.target = '_blank';
  709. a.download = '事件列表.xls';
  710. document.body.appendChild(a);
  711. a.click();
  712. }).error(function(data, status, headers, config) {
  713. // $scope.ldloading.zoom_in = false;
  714. console.log(data);
  715. });
  716. }
  717. //事件提取
  718. $scope.acceptTaskAction = function(model) {
  719. var modalInstance = $modal.open({
  720. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  721. controller: function($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
  722. var receiveTask = function(receive_code, modelData) {
  723. var data = {
  724. 'receive_code': receive_code
  725. };
  726. if (modelData) {
  727. return {
  728. taskId: modelData.taskId,
  729. data: data
  730. };
  731. } else {
  732. return 'error';
  733. }
  734. };
  735. $scope.title = "提示";
  736. $scope.connect = "确认抢单?";
  737. $scope.ok = function() {
  738. //接收任务//请求重新指派
  739. var data = receiveTask($scope.receive_code, modelData);
  740. APIService.claimAndCompletedTask(data.taskId, { userId: currentUserId, receive_code: "handler" }).then(function(response) {
  741. if (response.status == 200) {
  742. Alert.swal({
  743. title: "操作成功!",
  744. confirmButtonColor: "#007AFF",
  745. type: "success"
  746. });
  747. $modalInstance.close('success');
  748. } else if (response.status == 500) {
  749. Alert.swal({
  750. title: "操作失败",
  751. text: "该事件已被提取,请刷新页面!",
  752. type: "error"
  753. });
  754. $modalInstance.close('success');
  755. } else {
  756. Alert.swal({
  757. title: "操作失败",
  758. text: "操作失败, 请稍后再试!",
  759. type: "error"
  760. });
  761. }
  762. });
  763. }
  764. $scope.cancel = function() {
  765. $modalInstance.dismiss('cancel');
  766. }
  767. },
  768. size: 'sm',
  769. resolve: {
  770. APIService: function() {
  771. return api_bpm_domain;
  772. },
  773. modelData: function() {
  774. return model;
  775. },
  776. currentUserId: function() {
  777. return loginUser.id;
  778. },
  779. Alert: function() {
  780. return SweetAlert;
  781. }
  782. }
  783. });
  784. modalInstance.result.then(function(selectedItem) {
  785. if (selectedItem == 'success') {
  786. $scope.refreshData('expand-right', defaultFilterData);
  787. }
  788. });
  789. }
  790. if ($stateParams.model) {
  791. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  792. $scope.searchTypes = JSON.parse($stateParams.model).searchType;
  793. } else {
  794. $scope.searchTypes = "todo";
  795. }
  796. } else {
  797. $scope.searchTypes = "todo";
  798. }
  799. if ($rootScope.user.group) {
  800. var defaultFilterData = {
  801. "assignee": $rootScope.user.id,
  802. "candidateGroups": $rootScope.user.group[0].id,
  803. "searchType": "todo",
  804. "idx": 0,
  805. "sum": mun
  806. };
  807. } else {
  808. var defaultFilterData = {
  809. "assignee": $rootScope.user.id,
  810. "searchType": "todo",
  811. "idx": 0,
  812. "sum": mun
  813. };
  814. }
  815. // var defaultFilterData = {
  816. // "assignee":$rootScope.user.id,
  817. // "candidateGroups":$rootScope.user.group[0].id,
  818. // "idx":0,
  819. // "sum":mun
  820. // };
  821. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  822. defaultFilterData['searchType'] = $rootScope.search.incident;
  823. $scope.searchTypes = $rootScope.search.incident;
  824. }
  825. if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
  826. if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
  827. $rootScope['cmdbs'] = 'incident';
  828. defaultFilterData.idx = $rootScope.idx - 1;
  829. } else { $rootScope.cmdbs = ""; }
  830. $scope.ldloading = {};
  831. // $scope.Change= function(upTypes){
  832. // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
  833. // $state.go('app.problem.incident',{});
  834. // }
  835. // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
  836. // $state.go('app.change.incident',{});
  837. // }
  838. // }
  839. //事件类型筛选
  840. $scope.searchstate = 'todo';
  841. $scope.onChange = function(searchType) {
  842. $scope.searchstate = searchType;
  843. defaultFilterData = $scope.memoryfilterData;
  844. defaultFilterData['searchType'] = searchType;
  845. $scope.refreshData('expand-right', defaultFilterData);
  846. }
  847. //获取列表数据
  848. $scope.refreshData = function(style, filterData) {
  849. $scope.ldloading[style.replace('-', '_')] = true;
  850. if (angular.isUndefined(filterData)) {
  851. filterData = defaultFilterData;
  852. }
  853. // if (angular.isDefined($scope.searchTypes)) {
  854. // $rootScope['search'] = {};
  855. // filterData['searchType'] = $scope.searchTypes;
  856. // $rootScope['search']['incident'] = $scope.searchTypes;
  857. // }
  858. // if(sessionStorage.idx){
  859. // filterData.idx = Number(sessionStorage.idx);
  860. // $scope.gridOptions.idx = Number(sessionStorage.idx)+1;
  861. // }
  862. $scope.myData = [];
  863. //var start = new Date();
  864. //var sec = $interval(function () {
  865. //$scope.callsPending++;
  866. $scope.gridOptions['sum'] = filterData.sum;
  867. api_bpm_data.fetchDataList(pdKey, filterData).then(function(data) {
  868. if (data.status) {
  869. var myData = Restangular.stripRestangular(data);
  870. var list = [];
  871. $scope.gridOptions['totalItems'] = myData.resultCount;
  872. $scope.myData = myData.list;
  873. for (var i = 0; i < $scope.myData.length; i++) {
  874. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  875. }
  876. } else {
  877. SweetAlert.swal({
  878. title: "系统错误",
  879. text: "请稍后再试!",
  880. type: "error"
  881. });
  882. }
  883. $scope.ldloading[style.replace('-', '_')] = false;
  884. }, function() {
  885. $scope.ldloading[style.replace('-', '_')] = false;
  886. });
  887. };
  888. $scope.refreshData('expand-right', defaultFilterData);
  889. }]);
  890. //操作按钮权限控制
  891. app.controller('MeansOperCtrl', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
  892. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  893. // if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  894. // if ($rootScope.user.id == $scope.item.handlerUser.id) {
  895. // $scope.item.chaozuoPower = true;
  896. // if ($scope.item.state.id == 4) {
  897. // $scope.item.coordination = true;
  898. // }
  899. // }
  900. // }
  901. // $rootScope.callid = $scope.item.callID;
  902. // if ($scope.item.callID) {
  903. // $scope.item.listen = true;
  904. // } else { $scope.item.listen = false; }
  905. // if ($scope.item.state.id != 6 && $scope.item.handlerUser == null) {
  906. // angular.forEach($rootScope.user.group, function(item) {
  907. // if (item.id == $scope.item.candidateGroups) {
  908. // $scope.item.tiquPower = true;
  909. // }
  910. // })
  911. // }
  912. $scope.coordination = function() {
  913. $scope.colobject.grid.appScope.coordination($scope.item);
  914. }
  915. $scope.look = function() {
  916. //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
  917. $scope.colobject.grid.appScope.lookFunction($scope.item);
  918. // console.log('$scope.item='+JSON.stringify($scope.item));
  919. //$scope.doEdit($scope.item.id);
  920. }
  921. $scope.edit = function() {
  922. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  923. // console.log('$scope.item='+JSON.stringify($scope.item));
  924. // $scope.doEdit($scope.item.id);
  925. }
  926. $scope.print = function() { //print
  927. $scope.colobject.grid.appScope.open($scope.item);
  928. // $scope.doEdit($scope.item.id);
  929. }
  930. $scope.record = function() { //record
  931. $scope.colobject.grid.appScope.play($scope.item);
  932. // $scope.doEdit($scope.item.id);
  933. }
  934. $scope.handler = function() {
  935. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  936. $scope.doComment($scope.item.id);
  937. }
  938. $scope.follow = function() {
  939. $scope.colobject.grid.appScope.followFunction($scope.item);
  940. }
  941. // $scope.play = function() {
  942. // // console.log($scope.item.callID)
  943. // var modalInstance = $modal.open({
  944. // templateUrl: 'assets/views/incident/tpl/audio.html',
  945. // controller: function($scope, $modalInstance,$sce){
  946. // $scope.data={
  947. // "name":"视频",
  948. // "url":"http://192.168.3.69:8088/recording/recording?callID="+$rootScope.callid
  949. // };
  950. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  951. // // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
  952. // $scope.cancel = function() {
  953. // $modalInstance.dismiss('cancel');
  954. // };
  955. // $modalInstance.close();
  956. // }
  957. // });
  958. // };
  959. }]);
  960. //操作按钮
  961. app.directive('meansoperator', function() {
  962. return {
  963. restrict: 'E',
  964. scope: {
  965. item: '=',
  966. colobject: '='
  967. },
  968. controller: 'MeansOperCtrl',
  969. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  970. '<a ng-click="look()" tooltip-placement="left">查看</a>' +
  971. // '<a ng-click="handler()" ng-show="{{item.tiquPower}}" class="handlefont" >抢单</a>' +
  972. '<a ng-click="edit()" class="bianjifont">编辑</a>' +
  973. // '<a ng-click="print()" class="printfont" >打印</a>' +
  974. // '<a ng-click="record()" ng-show="{{item.listen}}" class="luyinfont" >录音</a>' +
  975. '</div></div>'
  976. };
  977. });