calllogCtrl.js 18 KB

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