calllogCtrl.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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 = true;
  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');
  50. }
  51. $scope.gridOptions.columnDefs = [{
  52. name: 'item',
  53. displayName: '序号',
  54. width: 50
  55. }, {
  56. name: 'callerIdNumber',
  57. displayName: '主叫号码',
  58. width: '12%'
  59. },
  60. {
  61. name: 'destinationNumber',
  62. displayName: '拨打号码',
  63. width: '10%'
  64. },
  65. {
  66. name: 'createdTime',
  67. displayName: '开始时间',
  68. width: '17%',
  69. cellTemplate: '<div>' +
  70. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.createdTime)}} </div>' +
  71. '</div>'
  72. }, {
  73. name: 'overTime',
  74. displayName: '结束时间',
  75. width: '17%',
  76. cellTemplate: '<div>' +
  77. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.overTime)}}</div>' +
  78. '</div>'
  79. } ,
  80. {
  81. name: 'duration',
  82. displayName: '通话时长(秒)',
  83. width: '10%',
  84. cellTemplate: '<div>' +
  85. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{(row.entity.overTime-row.entity.createdTime)/1000}}</div>' +
  86. '</div>'
  87. },
  88. {
  89. name: 'isRouteAgent',
  90. displayName: '已接/未接',
  91. width: '10%',
  92. cellTemplate: '<div>' +
  93. '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translateone(row.entity.answeredTime)}}</div>' +
  94. '</div>'
  95. },
  96. // {
  97. // name: 'routedDN',
  98. // displayName: '座席工号',
  99. // width: '15%'
  100. // },
  101. // {
  102. // name: 'type',
  103. // displayName: '呼入/呼出',
  104. // width: '10%',
  105. // cellTemplate: '<div>' +
  106. // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translatetwo(row.entity.type)}}</div>' +
  107. // '</div>'
  108. // // },
  109. // // {
  110. // // name: '生成事件',
  111. // // width: 80,
  112. // // cellTemplate: '<div class="links cl-effect-1">' +
  113. // // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
  114. // // '</div>'
  115. // },
  116. // { name: '操作', cellTemplate: '<wechatoperator1 item="row.entity" colobject="col">', enableFiltering: false }
  117. {
  118. name: '操作',
  119. enableFiltering: false,
  120. cellTemplate: '<div class="links cl-effect-1 pull-left ui-grid-cell-contents">' +
  121. '<a ng-click="grid.appScope.recordcall(row.entity)" ng-show="grid.appScope.chuli&&grid.appScope.yijieFn(row.entity)" class="bianjifont">通话录音</a>' +
  122. '<a ng-click="grid.appScope.recordcallid(row.entity)" ng-show="grid.appScope.chuli" class="bianjifont">回拨</a>' +
  123. '</div>'
  124. },
  125. ];
  126. $scope.yijieFn=function(data){
  127. if(data.answeredTime){
  128. return true
  129. }else{
  130. return false
  131. }
  132. }
  133. $scope.chuli=false;
  134. for(var i=0;i<loginUser.menu.length;i++){
  135. if(loginUser.menu[i].link=="tonghualiebiao_chuli"){
  136. $scope.chuli=true
  137. }
  138. };
  139. $scope.value = 10;
  140. $scope.decrement = function() {
  141. $scope.value = $scope.value - 1;
  142. };
  143. $scope.selected = {
  144. items: []
  145. }
  146. $scope.memoryfilterData = defaultFilterData = {
  147. // "assignee":$rootScope.user.id,
  148. // "candidateGroups":$rootScope.user.group[0].id,
  149. "idx": 0,
  150. "sum": 10
  151. };
  152. $scope.type = [{ id: 1, name: '呼入' }, { id: 0, name: '呼出' }]
  153. var defaultFilterData = {
  154. // "assignee":$rootScope.user.id,
  155. // "candidateGroups":$rootScope.user.group[0].id,
  156. "idx": 0,
  157. "sum": 10
  158. };
  159. $scope.searchkeys = {};
  160. // $scope.chicecalllog = function(item) {
  161. // var fildata = { hjzxCall: {} };
  162. // if (item.ano && item.ano != "") {
  163. // fildata.hjzxCall.ano = item.ano;
  164. // }
  165. // if (item.bno && item.bno != "") {
  166. // fildata.hjzxCall.bno = item.bno;
  167. // }
  168. // if (item.routedDN && item.routedDN != "") {
  169. // fildata.hjzxCall.routedDN = item.routedDN;
  170. // }
  171. // if (item.type && item.type != "") {
  172. // fildata.hjzxCall.type = item.type.id;
  173. // }
  174. // $scope.gridOptions.paginationCurrentPage = 1;
  175. // $scope.refreshData('expand-right', $scope.fileData);
  176. // }
  177. // $scope.clear = function() {
  178. // $scope.searchkeys = {};
  179. // $scope.gridOptions.paginationCurrentPage = 1;
  180. // $scope.memoryfilterData = defaultFilterData;
  181. // $scope.refreshData('expand-right',$scope.fileData);
  182. // }
  183. $scope.gridOptions.onRegisterApi = function(gridApi) {
  184. $scope.gridApi = gridApi;
  185. gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
  186. var filtersData = $scope.memoryfilterData;
  187. filtersData.idx = newPage - 1;
  188. filtersData.sum = pageSize;
  189. defaultFilterData = filtersData;
  190. $scope.fileData.idx=newPage - 1;
  191. $scope.fileData.sum=pageSize;
  192. $scope.refreshData('expand-right', $scope.fileData);
  193. });
  194. gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
  195. var j = 0;
  196. for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
  197. if (scope.grid.appScope.selected.items[i] == scope.entity) {
  198. j++;
  199. break;
  200. }
  201. }
  202. // console.log("j="+j)
  203. if (j == 1) {
  204. scope.grid.appScope.selected.items.splice(i, 1);
  205. } else {
  206. scope.grid.appScope.selected.items.push(scope.entity)
  207. }
  208. });
  209. gridApi.core.on.filterChanged($scope, function() {
  210. var grid = this.grid;
  211. var filtersData = $scope.memoryfilterData;
  212. angular.forEach(grid.columns, function(item) {
  213. if (item.enableFiltering) {
  214. if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
  215. if (angular.isUndefined(filtersData['user'])) {
  216. filtersData['notice'] = {};
  217. filtersData['notice'][item.field] = item.filters[0].term;
  218. } else {
  219. filtersData.notice[item.field] = item.filters[0].term;
  220. }
  221. }
  222. }
  223. });
  224. $scope.memoryfilterData = filtersData;
  225. $scope.refreshData('expand-right', $scope.fileData);
  226. });
  227. };
  228. //录音
  229. $scope.recordcall = function(data) {
  230. var modalInstance = $modal.open({
  231. backdrop: "static",
  232. templateUrl: 'assets/views/incident/tpl/audio.html',
  233. controller: function($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
  234. $scope.audioUrl=$sce.trustAsResourceUrl(callIp+data.recordingFileName);
  235. // $rootScope.setbusy();
  236. // $scope.datasurl = "";
  237. // $http({
  238. // url: callIp + "/recording/recording?recordId=" + data.id,
  239. // method: 'GET',
  240. // headers: {},
  241. // }).success(function(data, status, headers, config) {
  242. // $scope.data = {
  243. // "name": "视频",
  244. // "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
  245. // };
  246. // $scope.datasurl = data.rrpath;
  247. // }).error(function(data, status, headers, config) {});
  248. // $scope.download = function(contentId, filename) {
  249. // $http({
  250. // url: "http://" + $scope.datasurl,
  251. // method: 'GET',
  252. // headers: {
  253. // 'Content-type': 'application/octet-stream',
  254. // },
  255. // responseType: 'arraybuffer'
  256. // }).success(function(data, status, headers, config) {
  257. // var file = new Blob([data], {
  258. // type: 'application/octet-stream'
  259. // });
  260. // //trick to download store a file having its URL
  261. // var fileURL = URL.createObjectURL(file);
  262. // var a = document.createElement('a');
  263. // a.href = fileURL;
  264. // a.target = '_blank';
  265. // a.download = filename;
  266. // document.body.appendChild(a);
  267. // a.click();
  268. // }).error(function(data, status, headers, config) {
  269. // // console.log(data);
  270. // });
  271. // }
  272. $scope.cancel = function() {
  273. $modalInstance.dismiss('cancel');
  274. };
  275. $modalInstance.close();
  276. }
  277. });
  278. modalInstance.result.then(function(result) {
  279. // $rootScope.setidle();
  280. }, function(reason) {
  281. $rootScope.setidle();
  282. });
  283. };
  284. $scope.fileData={
  285. "idx":0,
  286. "sum":10,
  287. "callrecord":{}
  288. }
  289. $scope.jsearchkeys={};
  290. $scope.search=function(){
  291. if($scope.jsearchkeys.type){
  292. $scope.fileData.callrecord.type=$scope.jsearchkeys.type.id
  293. }
  294. $scope.refreshData('expand-right',$scope.fileData);
  295. }
  296. $scope.clear=function(){
  297. delete $scope.fileData.callrecord.callerIdNumber;
  298. delete $scope.fileData.callrecord.destinationNumber;
  299. delete $scope.fileData.callrecord.type;
  300. $scope.jsearchkeys={};
  301. $scope.refreshData('expand-right',$scope.fileData);
  302. }
  303. $scope.recordcallid = function(data) {
  304. // var telephone = '9' + data.ano;
  305. // $rootScope.callout = 2;
  306. // if ($rootScope.takes) {
  307. // api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
  308. // if (data.errno == 0) {
  309. // $rootScope.status = 6;
  310. // $scope.oldRecord(data);
  311. // }
  312. // })
  313. // } else {
  314. // SweetAlert.swal({
  315. // title: "呼叫失败",
  316. // text: "请先签入呼叫中心!",
  317. // type: "error",
  318. // confirmButtonColor: "#DD6B55"
  319. // });
  320. // }
  321. $rootScope.dial(data.callerIdNumber)
  322. };
  323. $scope.ldloading = {};
  324. $scope.refreshData = function(style, filterData) {
  325. $scope.ldloading[style.replace('-', '_')] = true;
  326. var faldata = { idx: 0, sum: 10 };
  327. if (filterData) {
  328. faldata = angular.extend(faldata, filterData)
  329. }
  330. $scope.memoryfilterData = faldata;
  331. api_bpm_data.fetchDataList("callrecord", faldata).then(function(data) {
  332. var myData = Restangular.stripRestangular(data);
  333. $scope.gridOptions['totalItems'] = myData.totalNum;
  334. $scope.myData = myData.list;
  335. for (var i = 0; i < $scope.myData.length; i++) {
  336. if(!$scope.myData[i]["id"]){
  337. $scope.myData[i]["id"]=i + 1 + $scope.fileData.idx * $scope.fileData.sum;
  338. }
  339. $scope.myData[i]['item'] = i + 1 + $scope.fileData.idx * $scope.fileData.sum;
  340. };
  341. // console.log($scope.myData)
  342. $scope.ldloading[style.replace('-', '_')] = false;
  343. }, function() {
  344. $scope.ldloading[style.replace('-', '_')] = false;
  345. });
  346. };
  347. $scope.refreshData('expand-right',$scope.fileData);
  348. $scope.timer=$interval(function(){
  349. $scope.refreshData('expand-right', $scope.fileData);
  350. },$rootScope.refreshTime);
  351. $scope.$on('$destroy',function(){
  352. $interval.cancel($scope.timer)
  353. });
  354. }]);
  355. app.controller('wechatoperator1', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
  356. var loginUser = $rootScope.user;
  357. $scope.chuli=false;
  358. for(var i=0;i<loginUser.menu.length;i++){
  359. if(loginUser.menu[i].link=="tonghualiebiao_chuli"){
  360. $scope.chuli=true
  361. }
  362. };
  363. $scope.yijie=true;
  364. console.log($scope.item.answeredTime);
  365. if(!$scope.item.answeredTime){
  366. $scope.yijie=false;
  367. }
  368. $scope.recordcall = function() {
  369. $scope.colobject.grid.appScope.recordcall($scope.item);
  370. }
  371. $scope.recordcallid = function() {
  372. $scope.colobject.grid.appScope.recordcallid($scope.item);
  373. }
  374. }]);
  375. app.directive('wechatoperator1', function() {
  376. return {
  377. restrict: 'E',
  378. scope: {
  379. item: '=',
  380. colobject: '='
  381. },
  382. controller: 'wechatoperator1',
  383. template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
  384. '<a ng-click="recordcall()" ng-show="chuli&&yijie" class="bianjifont">通话录音</a>' +
  385. '<a ng-click="recordcallid()" ng-show="chuli" class="bianjifont">回拨</a>' +
  386. '</div>'
  387. };
  388. });