calllogCtrl.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. 'use strict';
  2. app.controller('calllogCtrl', ["$scope", "i18nService", "$rootScope", "$state", "$timeout", "$interval", "$modal", "SweetAlert", "uiGridConstants", "uiGridGroupingConstants", "Restangular", "api_bpm_data", "api_text", "api_user_data", function($scope, i18nService, $rootScope, $state, $timeout, $interval, $modal, SweetAlert, uiGridConstants, uiGridGroupingConstants, Restangular, api_bpm_data, api_text, api_user_data) {
  3. $scope.langs = i18nService.getAllLangs();
  4. $scope.lang = 'zh-cn';
  5. i18nService.setCurrentLang($scope.lang);
  6. // $(window).resize(function() {
  7. // // console.log("1111")
  8. // });
  9. var loginUser = $rootScope.user;
  10. // var voiceurl=$rootScope.audioiIp;
  11. // delete $rootScope.user.authority;
  12. var pdKey = $state.current.pdKey;
  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.useExternalFiltering=true;
  23. $scope.gridOptions.useExternalPagination = true;
  24. $scope.gridOptions.paginationPageSizes = [10];
  25. $scope.gridOptions.paginationPageSize = 10;
  26. $scope.gridOptions.multiSelect = true;
  27. var mun = $scope.gridOptions.paginationPageSize;
  28. $scope.gridOptions.rowIdentity = function(row) {
  29. return row.id;
  30. };
  31. $scope.gridOptions.getRowIdentity = function(row) {
  32. return row.id;
  33. };
  34. $scope.translateone = function(item) {
  35. if (item) {
  36. return '是';
  37. } else {
  38. return '否';
  39. }
  40. }
  41. $scope.translatetwo = function(item) {
  42. if (item) {
  43. return '呼入';
  44. } else {
  45. return '呼出';
  46. }
  47. }
  48. $scope.transferTime = function(time) {
  49. return moment(time).format('YYYY-MM-DD HH:mm:ss');
  50. }
  51. $scope.gridOptions.columnDefs = [{
  52. name: 'item',
  53. displayName: '序号',
  54. width: 50
  55. }, {
  56. name: 'ano',
  57. displayName: '主叫号码',
  58. width: '10%'
  59. },
  60. {
  61. name: 'bno',
  62. displayName: '拨打号码',
  63. width: '10%'
  64. },
  65. {
  66. name: 'begTime',
  67. displayName: '开始时间',
  68. width: '15%',
  69. cellTemplate: '<div>' +
  70. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.begTime)}} </div>' +
  71. '</div>'
  72. }, {
  73. name: 'endTime',
  74. displayName: '结束时间',
  75. width: '15%',
  76. cellTemplate: '<div>' +
  77. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.endTime)}}</div>' +
  78. '</div>'
  79. }, , {
  80. name: 'duration',
  81. displayName: '通话时长(秒)',
  82. width: '10%'
  83. }, {
  84. name: 'isRouteAgent',
  85. displayName: '是否被座席接听',
  86. width: '10%',
  87. cellTemplate: '<div>' +
  88. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translateone(row.entity.isRouteAgent)}}</div>' +
  89. '</div>'
  90. }, {
  91. name: 'routedDN',
  92. displayName: '座席工号',
  93. width: '15%'
  94. }, {
  95. name: 'type',
  96. displayName: '呼入/呼出',
  97. width: '10%',
  98. cellTemplate: '<div>' +
  99. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translatetwo(row.entity.type)}}</div>' +
  100. '</div>'
  101. // },
  102. // {
  103. // name: '生成事件',
  104. // width: 80,
  105. // cellTemplate: '<div class="links cl-effect-1">' +
  106. // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  107. // '</div>'
  108. }
  109. // { name: '操作', cellTemplate: '<wechatoperator item="row.entity" colobject="col">', enableFiltering: false }
  110. ];
  111. $scope.value = 10;
  112. $scope.decrement = function() {
  113. $scope.value = $scope.value - 1;
  114. };
  115. $scope.selected = {
  116. items: []
  117. }
  118. $scope.memoryfilterData = defaultFilterData = {
  119. // "assignee":$rootScope.user.id,
  120. // "candidateGroups":$rootScope.user.group[0].id,
  121. "idx": 0,
  122. "sum": 10
  123. };
  124. $scope.type = [{ id: 1, name: '呼入' }, { id: 0, name: '呼出' }]
  125. var defaultFilterData = {
  126. // "assignee":$rootScope.user.id,
  127. // "candidateGroups":$rootScope.user.group[0].id,
  128. "idx": 0,
  129. "sum": 10
  130. };
  131. $scope.searchkeys = {};
  132. $scope.chicecalllog = function(item) {
  133. var fildata = { hjzxCall: {} };
  134. if (item.ano && item.ano != "") {
  135. fildata.hjzxCall.ano = item.ano;
  136. }
  137. if (item.bno && item.bno != "") {
  138. fildata.hjzxCall.bno = item.bno;
  139. }
  140. if (item.routedDN && item.routedDN != "") {
  141. fildata.hjzxCall.routedDN = item.routedDN;
  142. }
  143. if (item.type && item.type != "") {
  144. fildata.hjzxCall.type = item.type.id;
  145. }
  146. $scope.gridOptions.paginationCurrentPage = 1;
  147. $scope.refreshData('expand-right', fildata);
  148. }
  149. $scope.clear = function() {
  150. $scope.searchkeys = {};
  151. $scope.gridOptions.paginationCurrentPage = 1;
  152. $scope.memoryfilterData = defaultFilterData;
  153. $scope.refreshData('expand-right');
  154. }
  155. $scope.gridOptions.onRegisterApi = function(gridApi) {
  156. $scope.gridApi = gridApi;
  157. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  158. var filtersData = $scope.memoryfilterData;
  159. filtersData.idx = newPage - 1;
  160. filtersData.sum = pageSize;
  161. defaultFilterData = filtersData;
  162. $scope.refreshData('expand-right', filtersData);
  163. });
  164. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  165. var j = 0;
  166. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  167. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  168. j++;
  169. break;
  170. }
  171. }
  172. // console.log("j="+j)
  173. if (j == 1) {
  174. scope.grid.appScope.selected.items.splice(i, 1);
  175. } else {
  176. scope.grid.appScope.selected.items.push(scope.entity)
  177. }
  178. });
  179. gridApi.core.on.filterChanged($scope, function() {
  180. var grid = this.grid;
  181. var filtersData = $scope.memoryfilterData;
  182. angular.forEach(grid.columns, function(item) {
  183. if (item.enableFiltering) {
  184. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  185. if (angular.isUndefined(filtersData['user'])) {
  186. filtersData['notice'] = {};
  187. filtersData['notice'][item.field] = item.filters[0].term;
  188. } else {
  189. filtersData.notice[item.field] = item.filters[0].term;
  190. }
  191. }
  192. }
  193. });
  194. $scope.memoryfilterData = filtersData;
  195. $scope.refreshData('expand-right', filtersData);
  196. });
  197. };
  198. $scope.ldloading = {};
  199. $scope.refreshData = function(style, filterData) {
  200. $scope.ldloading[style.replace('-', '_')] = true;
  201. var faldata = { idx: 0, sum: 10 };
  202. if (filterData) {
  203. faldata = angular.extend(faldata, filterData)
  204. }
  205. $scope.memoryfilterData = faldata;
  206. api_bpm_data.fetchDataList("hjzxCall", faldata).then(function(data) {
  207. var myData = Restangular.stripRestangular(data);
  208. $scope.gridOptions['totalItems'] = myData.totalNum;
  209. $scope.myData = myData.list;
  210. for (var i = 0; i < $scope.myData.length; i++) {
  211. $scope.myData[i]['item'] = i + 1 + $scope.memoryfilterData.idx * $scope.memoryfilterData.sum
  212. }
  213. // console.log($scope.myData)
  214. $scope.ldloading[style.replace('-', '_')] = false;
  215. }, function() {
  216. $scope.ldloading[style.replace('-', '_')] = false;
  217. });
  218. };
  219. $scope.refreshData('expand-right');
  220. }]);