calllogCtrl.js 16 KB

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