calllogCtrl.js 18 KB

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