meansoutCtrl.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009
  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,user:{engineer: 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,engineer: 1, }
  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,engineer: 1, }
  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.phone },
  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.phone},
  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.incidentDetail', {
  502. id: data.entity.id,
  503. });
  504. };
  505. // //查看
  506. // $scope.followFunction = function(data) {
  507. // //console.log('data='+JSON.stringify(data));
  508. // $state.go('app.detail', { formKey: 'statusform', pdKey: 'incident', dataId: data.id, processInstanceId: data.processInstanceId });
  509. // };
  510. //协同人
  511. $scope.coordination = function(data) {
  512. var modalInstance = $modal.open({
  513. templateUrl: 'assets/views/customform/tpl/checktable-modal-content.html',
  514. controller: function($scope, $modalInstance, i18nService, $timeout, api_bpm_domain, api_user_data) {
  515. $scope.langs = i18nService.getAllLangs();
  516. $scope.lang = 'zh-cn';
  517. i18nService.setCurrentLang($scope.lang);
  518. $scope.gridOptions = {};
  519. $scope.gridOptions.data = 'myData';
  520. $scope.gridOptions.enableColumnResizing = true;
  521. $scope.gridOptions.enableFiltering = true;
  522. $scope.gridOptions.enableGridMenu = true;
  523. $scope.gridOptions.showGridFooter = true;
  524. $scope.gridOptions.showColumnFooter = true;
  525. $scope.gridOptions.fastWatch = true;
  526. $scope.gridOptions.useExternalFiltering = true;
  527. $scope.gridOptions.useExternalPagination = true;
  528. $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
  529. $scope.gridOptions.paginationPageSize = 10;
  530. $scope.gridOptions.multiSelect = false;
  531. $scope.gridOptions.rowIdentity = function(row) {
  532. return row.id;
  533. };
  534. $scope.gridOptions.getRowIdentity = function(row) {
  535. return row.id;
  536. };
  537. $scope.gridOptions.columnDefs = [
  538. // { name:'id', width:80, enableFiltering:false},
  539. { name: 'account', displayName: '账号', width: 140 },
  540. { name: 'name', displayName: '名称', width: 100 },
  541. { name: 'gender', displayName: '性别', width: 140, enableFiltering: false },
  542. { name: 'phone', displayName: '电话', width: 100, enableFiltering: false },
  543. { name: 'email', displayName: '邮件', width: 100, enableFiltering: false },
  544. { name: 'dept.dept', displayName: '科室', width: 100, enableFiltering: false },
  545. { name: 'group[0].groupName', displayName: '职位', width: 100, enableFiltering: false }
  546. ];
  547. $scope.gridOptions.onRegisterApi = function(gridApi) {
  548. $scope.gridApi = gridApi;
  549. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  550. var filtersData = $scope.memoryfilterData;
  551. filtersData.idx = newPage - 1;
  552. filtersData.sum = pageSize;
  553. $scope.loadData(filtersData);
  554. // $scope.loadData({"idx":newPage-1,"sum":pageSize});
  555. });
  556. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  557. scope.grid.appScope.selected.items[0] = scope.entity;
  558. // $scope.selected.items[0] = scope.entity;
  559. });
  560. gridApi.core.on.filterChanged($scope, function() {
  561. var grid = this.grid;
  562. var filtersData = {
  563. idx: 0,
  564. sum: 10,
  565. "user": { "roledata": { "rolecode": options.model.currentRole }, "selectType": "1" }
  566. };
  567. angular.forEach(grid.columns, function(item) {
  568. if (item.enableFiltering) {
  569. //console.log("filtersData="+JSON.stringify(filtersData))
  570. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  571. if (angular.isUndefined(filtersData['user'])) {
  572. filtersData['user'] = {};
  573. }
  574. filtersData['user'][item.field] = item.filters[0].term;
  575. }
  576. }
  577. });
  578. $scope.memoryfilterData = filtersData;
  579. $scope.loadData(filtersData);
  580. });
  581. };
  582. $scope.selected = {
  583. items: []
  584. }
  585. var filterData = {
  586. "idx": 0,
  587. "sum": 10,
  588. "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1",engineer: 1, }
  589. }
  590. $scope.loadData = function(filterData) {
  591. // console.log(" filtersData['user'][item.field]=111"+JSON.stringify(filterData));
  592. api_user_data.fetchDataList('user', filterData).then(function(data) {
  593. var myData = Restangular.stripRestangular(data);
  594. $scope.gridOptions.totalItems = myData.totalNum;
  595. $scope.myData = myData.list;
  596. });
  597. };
  598. $scope.loadData({
  599. idx: 0,
  600. sum: 10,
  601. "user": { "roledata": { "rolecode": 'first-line support' }, "selectType": "1" }
  602. });
  603. $scope.ok = function() {
  604. $modalInstance.close($scope.selected.items);
  605. };
  606. $scope.cancel = function() {
  607. $modalInstance.dismiss('cancel');
  608. };
  609. },
  610. size: 'lg'
  611. });
  612. modalInstance.result.then(function(selectedItem) {
  613. if (selectedItem) {
  614. var filterData = {
  615. "assginee": selectedItem[0].id
  616. }
  617. api_bpm_domain.delegateTask(data.taskId, filterData).then(function(data) {
  618. if (data && data.status == 200) {
  619. SweetAlert.swal("添加成功!", "添加协同人成功", "success")
  620. $scope.refreshData('expand-right', $scope.memoryfilterData);
  621. } else {
  622. SweetAlert.swal("添加失败!", "请稍候重试", "error");
  623. }
  624. // var myData = Restangular.stripRestangular(data);
  625. // $scope.gridOptions.totalItems = myData.totalNum;
  626. // $scope.myData = myData.list;
  627. });
  628. }
  629. });
  630. }
  631. // $scope.onDblClick = function(row){
  632. // console.log(row.entity);
  633. // if($rootScope.user.id==row.entity.handlerUser.id){$state.go('app.incident.editor',{taskId:row.entity.taskId,processInstanceId: row.entity.processInstanceId});}
  634. // else{$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: row.entity.id});}
  635. // };
  636. /*
  637. appScopeProvider: {
  638. onDblClick : function(row) {
  639. var url = '//google.com';
  640. $window.open(url, "_blank", "height=600,width=800,toolbar=no,location=no,menubar=no,titlebar=no");
  641. }
  642. },
  643. 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>"
  644. */
  645. //删除
  646. $scope.eventDeleted = function(event) {
  647. SweetAlert.swal({
  648. title: "确认删除?",
  649. text: "删除的数据不可恢复,请确认继续操作!",
  650. type: "warning",
  651. showCancelButton: true,
  652. confirmButtonColor: "#DD6B55",
  653. confirmButtonText: "继续删除",
  654. cancelButtonText: "取消操作",
  655. closeOnConfirm: false,
  656. closeOnCancel: false
  657. }, function(isConfirm) {
  658. if (isConfirm) {
  659. api_bpm_schedule.remove([event.id]).then(function(response) {
  660. if (response.status == 200) {
  661. $scope.events.splice(event.id, 1); //有修改的一行
  662. SweetAlert.swal("操作成功!", "数据已经被删除.", "success");
  663. } else {
  664. SweetAlert.swal("操作失败!", "数据暂时无法被删除,请稍候重试", "error");
  665. }
  666. });
  667. } else {
  668. SweetAlert.swal("操作取消", "数据安全", "error");
  669. }
  670. });
  671. };
  672. //导出
  673. $scope.export = function() {
  674. // api_bpm_data.downDataModel("incident", 3, $scope.memoryfilterData).then(function(data) {
  675. // console.log(data)
  676. // var file = new Blob([data], {
  677. // // type: 'application/octet-stream'
  678. // type: 'application/vnd.ms-excel'
  679. // });
  680. // //trick to download store a file having its URL
  681. // var fileURL = URL.createObjectURL(file);
  682. // var a = document.createElement('a');
  683. // a.href = fileURL;
  684. // a.target = '_blank';
  685. // a.download = '工单列表.xls';
  686. // document.body.appendChild(a);
  687. // a.click();
  688. // })
  689. // $scope.ldloading[style.replace('-', '_')] = true;
  690. var filadata = angular.copy($scope.memoryfilterData);
  691. filadata.sum = 10000;
  692. $http({
  693. url: api_bpm_data.downDataModel("incident", 3).getRequestedUrl(),
  694. method: 'POST',
  695. data: JSON.stringify(filadata),
  696. headers: {
  697. // 'Content-type': 'application/xls',
  698. 'Accept': '*/*'
  699. },
  700. responseType: 'arraybuffer'
  701. }).success(function(data, status, headers, config) {
  702. // $scope.ldloading.zoom_in = false;
  703. var file = new Blob([data], {
  704. type: 'application/vnd.ms-excel'
  705. });
  706. //trick to download store a file having its URL
  707. var fileURL = URL.createObjectURL(file);
  708. var a = document.createElement('a');
  709. a.href = fileURL;
  710. a.target = '_blank';
  711. a.download = '工单列表.xls';
  712. document.body.appendChild(a);
  713. a.click();
  714. }).error(function(data, status, headers, config) {
  715. // $scope.ldloading.zoom_in = false;
  716. console.log(data);
  717. });
  718. }
  719. //事件提取
  720. $scope.acceptTaskAction = function(model) {
  721. var modalInstance = $modal.open({
  722. templateUrl: 'assets/views/incident/tpl/acceptTask.tpl.html',
  723. controller: function($scope, $modalInstance, APIService, modelData, currentUserId, Alert) {
  724. var receiveTask = function(receive_code, modelData) {
  725. var data = {
  726. 'receive_code': receive_code
  727. };
  728. if (modelData) {
  729. return {
  730. taskId: modelData.taskId,
  731. data: data
  732. };
  733. } else {
  734. return 'error';
  735. }
  736. };
  737. $scope.title = "提示";
  738. $scope.connect = "确认接单?";
  739. $scope.ok = function() {
  740. //接收任务//请求重新指派
  741. var data = receiveTask($scope.receive_code, modelData);
  742. APIService.claimAndCompletedTask(data.taskId, { userId: currentUserId, receive_code: "handler" }).then(function(response) {
  743. if (response.status == 200) {
  744. Alert.swal({
  745. title: "操作成功!",
  746. confirmButtonColor: "#007AFF",
  747. type: "success"
  748. });
  749. $modalInstance.close('success');
  750. } else if (response.status == 500) {
  751. Alert.swal({
  752. title: "操作失败",
  753. text: "该事件已被提取,请刷新页面!",
  754. type: "error"
  755. });
  756. $modalInstance.close('success');
  757. } else {
  758. Alert.swal({
  759. title: "操作失败",
  760. text: "操作失败, 请稍后再试!",
  761. type: "error"
  762. });
  763. }
  764. });
  765. }
  766. $scope.cancel = function() {
  767. $modalInstance.dismiss('cancel');
  768. }
  769. },
  770. size: 'sm',
  771. resolve: {
  772. APIService: function() {
  773. return api_bpm_domain;
  774. },
  775. modelData: function() {
  776. return model;
  777. },
  778. currentUserId: function() {
  779. return loginUser.id;
  780. },
  781. Alert: function() {
  782. return SweetAlert;
  783. }
  784. }
  785. });
  786. modalInstance.result.then(function(selectedItem) {
  787. if (selectedItem == 'success') {
  788. $scope.refreshData('expand-right', defaultFilterData);
  789. }
  790. });
  791. }
  792. if ($stateParams.model) {
  793. if (JSON.parse($stateParams.model).searchType && JSON.parse($stateParams.model).searchType != null) {
  794. $scope.searchTypes = JSON.parse($stateParams.model).searchType;
  795. } else {
  796. $scope.searchTypes = "todo";
  797. }
  798. } else {
  799. $scope.searchTypes = "todo";
  800. }
  801. if ($rootScope.user.group) {
  802. var defaultFilterData = {
  803. "assignee": $rootScope.user.id,
  804. "candidateGroups": $rootScope.user.group[0].id,
  805. "searchType": "todo",
  806. "idx": 0,
  807. "sum": mun
  808. };
  809. } else {
  810. var defaultFilterData = {
  811. "assignee": $rootScope.user.id,
  812. "searchType": "todo",
  813. "idx": 0,
  814. "sum": mun
  815. };
  816. }
  817. // var defaultFilterData = {
  818. // "assignee":$rootScope.user.id,
  819. // "candidateGroups":$rootScope.user.group[0].id,
  820. // "idx":0,
  821. // "sum":mun
  822. // };
  823. if (angular.isDefined($rootScope.search) && angular.isDefined($rootScope.search.incident)) {
  824. defaultFilterData['searchType'] = $rootScope.search.incident;
  825. $scope.searchTypes = $rootScope.search.incident;
  826. }
  827. if ($rootScope['cmdbs'] != 'incident') { $rootScope.idx = 1 }
  828. if (angular.isDefined($rootScope.idx) && $rootScope.cmdbs != "false") {
  829. $rootScope['cmdbs'] = 'incident';
  830. defaultFilterData.idx = $rootScope.idx - 1;
  831. } else { $rootScope.cmdbs = ""; }
  832. $scope.ldloading = {};
  833. // $scope.Change= function(upTypes){
  834. // if(angular.isDefined(upTypes)&&upTypes=='upincident'){
  835. // $state.go('app.problem.incident',{});
  836. // }
  837. // else if(angular.isDefined(upTypes)&&upTypes=='upchange'){
  838. // $state.go('app.change.incident',{});
  839. // }
  840. // }
  841. //事件类型筛选
  842. $scope.searchstate = 'todo';
  843. $scope.onChange = function(searchType) {
  844. $scope.searchstate = searchType;
  845. defaultFilterData = $scope.memoryfilterData;
  846. defaultFilterData['searchType'] = searchType;
  847. $scope.refreshData('expand-right', defaultFilterData);
  848. }
  849. //获取列表数据
  850. $scope.refreshData = function(style, filterData) {
  851. $scope.ldloading[style.replace('-', '_')] = true;
  852. if (angular.isUndefined(filterData)) {
  853. filterData = defaultFilterData;
  854. }
  855. // if (angular.isDefined($scope.searchTypes)) {
  856. // $rootScope['search'] = {};
  857. // filterData['searchType'] = $scope.searchTypes;
  858. // $rootScope['search']['incident'] = $scope.searchTypes;
  859. // }
  860. // if(sessionStorage.idx){
  861. // filterData.idx = Number(sessionStorage.idx);
  862. // $scope.gridOptions.idx = Number(sessionStorage.idx)+1;
  863. // }
  864. $scope.myData = [];
  865. //var start = new Date();
  866. //var sec = $interval(function () {
  867. //$scope.callsPending++;
  868. $scope.gridOptions['sum'] = filterData.sum;
  869. api_bpm_data.fetchDataList(pdKey, filterData).then(function(data) {
  870. if (data.status) {
  871. var myData = Restangular.stripRestangular(data);
  872. var list = [];
  873. $scope.gridOptions['totalItems'] = myData.resultCount;
  874. $scope.myData = myData.list;
  875. for (var i = 0; i < $scope.myData.length; i++) {
  876. $scope.myData[i]['item'] = i + 1 + filterData.idx * filterData.sum
  877. }
  878. } else {
  879. SweetAlert.swal({
  880. title: "系统错误",
  881. text: "请稍后再试!",
  882. type: "error"
  883. });
  884. }
  885. $scope.ldloading[style.replace('-', '_')] = false;
  886. }, function() {
  887. $scope.ldloading[style.replace('-', '_')] = false;
  888. });
  889. };
  890. $scope.refreshData('expand-right', defaultFilterData);
  891. }]);
  892. //操作按钮权限控制
  893. app.controller('MeansOperCtrl', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
  894. // console.log('$rootScope.user3='+JSON.stringify($scope.item));
  895. // if ($scope.item.state.id != null && $scope.item.handlerUser != null) {
  896. // if ($rootScope.user.id == $scope.item.handlerUser.id) {
  897. // $scope.item.chaozuoPower = true;
  898. // if ($scope.item.state.id == 4) {
  899. // $scope.item.coordination = true;
  900. // }
  901. // }
  902. // }
  903. // $rootScope.callid = $scope.item.callID;
  904. // if ($scope.item.callID) {
  905. // $scope.item.listen = true;
  906. // } else { $scope.item.listen = false; }
  907. // if ($scope.item.state.id != 6 && $scope.item.handlerUser == null) {
  908. // angular.forEach($rootScope.user.group, function(item) {
  909. // if (item.id == $scope.item.candidateGroups) {
  910. // $scope.item.tiquPower = true;
  911. // }
  912. // })
  913. // }
  914. $scope.coordination = function() {
  915. $scope.colobject.grid.appScope.coordination($scope.item);
  916. }
  917. $scope.look = function() {
  918. //$state.go('app.detail', { formKey:'incident_back', pdKey:'incident', dataId: $scope.item.id});
  919. $scope.colobject.grid.appScope.lookFunction($scope.item);
  920. // console.log('$scope.item='+JSON.stringify($scope.item));
  921. //$scope.doEdit($scope.item.id);
  922. }
  923. $scope.edit = function() {
  924. $scope.colobject.grid.appScope.selectRowFunction($scope.item);
  925. // console.log('$scope.item='+JSON.stringify($scope.item));
  926. // $scope.doEdit($scope.item.id);
  927. }
  928. $scope.print = function() { //print
  929. $scope.colobject.grid.appScope.open($scope.item);
  930. // $scope.doEdit($scope.item.id);
  931. }
  932. $scope.record = function() { //record
  933. $scope.colobject.grid.appScope.play($scope.item);
  934. // $scope.doEdit($scope.item.id);
  935. }
  936. $scope.handler = function() {
  937. $scope.colobject.grid.appScope.acceptTaskAction($scope.item);
  938. $scope.doComment($scope.item.id);
  939. }
  940. $scope.follow = function() {
  941. $scope.colobject.grid.appScope.followFunction($scope.item);
  942. }
  943. // $scope.play = function() {
  944. // // console.log($scope.item.callID)
  945. // var modalInstance = $modal.open({
  946. // templateUrl: 'assets/views/incident/tpl/audio.html',
  947. // controller: function($scope, $modalInstance,$sce){
  948. // $scope.data={
  949. // "name":"视频",
  950. // "url":"http://192.168.3.69:8088/recording/recording?callID="+$rootScope.callid
  951. // };
  952. // $scope.data.url = $sce.trustAsResourceUrl($scope.data.url);
  953. // // $scope.audiourl={url:$sce.trustAsResourceUrl("http://192.168.3.69:8088/recording/recording?callID=218147232")};
  954. // $scope.cancel = function() {
  955. // $modalInstance.dismiss('cancel');
  956. // };
  957. // $modalInstance.close();
  958. // }
  959. // });
  960. // };
  961. }]);
  962. //操作按钮
  963. app.directive('meansoperator', function() {
  964. return {
  965. restrict: 'E',
  966. scope: {
  967. item: '=',
  968. colobject: '='
  969. },
  970. controller: 'MeansOperCtrl',
  971. template: '<div><div class="cl-effect-1 ui-grid-cell-contents pull-left" >' +
  972. '<a ng-click="look()" tooltip-placement="left">查看</a>' +
  973. // '<a ng-click="handler()" ng-show="{{item.tiquPower}}" class="handlefont" >接单</a>' +
  974. '<a ng-click="edit()" class="bianjifont">编辑</a>' +
  975. // '<a ng-click="print()" class="printfont" >打印</a>' +
  976. // '<a ng-click="record()" ng-show="{{item.listen}}" class="luyinfont" >录音</a>' +
  977. '</div></div>'
  978. };
  979. });