123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
- 'use strict';
- 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) {
- $scope.langs = i18nService.getAllLangs();
- $scope.lang = 'zh-cn';
- i18nService.setCurrentLang($scope.lang);
- // $(window).resize(function() {
- // // console.log("1111")
- // });
- var loginUser = $rootScope.user;
- // var voiceurl=$rootScope.audioiIp;
- // delete $rootScope.user.authority;
- var pdKey = $state.current.pdKey;
- $scope.gridOptions = {};
- $scope.gridOptions.data = 'myData';
- $scope.gridOptions.enableColumnResizing = true;
- $scope.gridOptions.enableFiltering = false;
- $scope.gridOptions.enableGridMenu = true;
- $scope.gridOptions.enableRowSelection = true;
- $scope.gridOptions.showGridFooter = true;
- $scope.gridOptions.showColumnFooter = false;
- $scope.gridOptions.fastWatch = true;
- // $scope.gridOptions.useExternalFiltering=true;
- $scope.gridOptions.useExternalPagination = true;
- $scope.gridOptions.paginationPageSizes = [10, 20, 50, 100];
- $scope.gridOptions.paginationPageSize = 10;
- $scope.gridOptions.multiSelect = true;
- var mun = $scope.gridOptions.paginationPageSize;
- $scope.gridOptions.rowIdentity = function(row) {
- return row.id;
- };
- $scope.gridOptions.getRowIdentity = function(row) {
- return row.id;
- };
- $scope.translateone = function(item) {
- if (item) {
- return '已接';
- } else {
- return '未接';
- }
- }
- $scope.translatetwo = function(item) {
- if (item) {
- return '呼入';
- } else {
- return '呼出';
- }
- }
- $scope.transferTime = function(time) {
- return moment(time).format('YYYY-MM-DD HH:mm');
- }
- $scope.gridOptions.columnDefs = [{
- name: 'item',
- displayName: '序号',
- width: 50
- }, {
- name: 'callerIdNumber',
- displayName: '主叫号码',
- width: '12%'
- },
- {
- name: 'destinationNumber',
- displayName: '拨打号码',
- width: '10%'
- },
- {
- name: 'createdTime',
- displayName: '开始时间',
- width: '17%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.createdTime)}} </div>' +
- '</div>'
- }, {
- name: 'overTime',
- displayName: '结束时间',
- width: '17%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.transferTime(row.entity.overTime)}}</div>' +
- '</div>'
- } ,
- {
- name: 'duration',
- displayName: '通话时长(秒)',
- width: '10%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{(row.entity.overTime-row.entity.createdTime)/1000}}</div>' +
- '</div>'
- },
- {
- name: 'isRouteAgent',
- displayName: '已接/未接',
- width: '10%',
- cellTemplate: '<div>' +
- '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translateone(row.entity.answeredTime)}}</div>' +
- '</div>'
- },
- // {
- // name: 'routedDN',
- // displayName: '座席工号',
- // width: '15%'
- // },
- // {
- // name: 'type',
- // displayName: '呼入/呼出',
- // width: '10%',
- // cellTemplate: '<div>' +
- // '<div class="ui-grid-cell-contents" style="cursor:pointer;text-align:center" >{{grid.appScope.translatetwo(row.entity.type)}}</div>' +
- // '</div>'
- // // },
- // // {
- // // name: '生成事件',
- // // width: 80,
- // // cellTemplate: '<div class="links cl-effect-1">' +
- // // '<a ng-click="grid.appScope.selectRowFunction(row.entity)" tooltip="新建事件" tooltip-placement="left"><i class="fa fa-pencil-square-o"></i></a>' +
- // // '</div>'
- // },
- // { name: '操作', cellTemplate: '<wechatoperator1 item="row.entity" colobject="col">', enableFiltering: false }
- {
- name: '操作',
- enableFiltering: false,
- cellTemplate: '<div class="links cl-effect-1 pull-left ui-grid-cell-contents">' +
- '<a ng-click="grid.appScope.recordcall(row.entity)" ng-show="grid.appScope.chuli&&grid.appScope.yijieFn(row.entity)" class="bianjifont">通话录音</a>' +
- '<a ng-click="grid.appScope.recordcallid(row.entity)" ng-show="grid.appScope.chuli&&grid.appScope.isHuibo(row.entity)" class="bianjifont">回拨</a>' +
- '</div>'
- },
- ];
- $scope.yijieFn=function(data){
- if(data.answeredTime){
- return true
- }else{
- return false
- }
- }
- $scope.isHuibo=function(data){
- var phones = JSON.parse(sessionStorage.getItem('phones'));
- console.log(phones,data.callerIdNumber)
- var isHuajihao = phones.length?phones.some(v=>v == data.callerIdNumber):false;
- return !isHuajihao;
- }
- $scope.chuli=false;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="tonghualiebiao_chuli"){
- $scope.chuli=true
- }
- };
- $scope.value = 10;
- $scope.decrement = function() {
- $scope.value = $scope.value - 1;
- };
- $scope.selected = {
- items: []
- }
- $scope.memoryfilterData = defaultFilterData = {
- // "assignee":$rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- "idx": 0,
- "sum": 10
- };
- $scope.type = [{ id: 1, name: '呼入' }, { id: 0, name: '呼出' }]
- var defaultFilterData = {
- // "assignee":$rootScope.user.id,
- // "candidateGroups":$rootScope.user.group[0].id,
- "idx": 0,
- "sum": 10
- };
- $scope.searchkeys = {};
- // $scope.chicecalllog = function(item) {
- // var fildata = { hjzxCall: {} };
- // if (item.ano && item.ano != "") {
- // fildata.hjzxCall.ano = item.ano;
- // }
- // if (item.bno && item.bno != "") {
- // fildata.hjzxCall.bno = item.bno;
- // }
- // if (item.routedDN && item.routedDN != "") {
- // fildata.hjzxCall.routedDN = item.routedDN;
- // }
- // if (item.type && item.type != "") {
- // fildata.hjzxCall.type = item.type.id;
- // }
- // $scope.gridOptions.paginationCurrentPage = 1;
- // $scope.refreshData('expand-right', $scope.fileData);
- // }
- // $scope.clear = function() {
- // $scope.searchkeys = {};
- // $scope.gridOptions.paginationCurrentPage = 1;
- // $scope.memoryfilterData = defaultFilterData;
- // $scope.refreshData('expand-right',$scope.fileData);
- // }
- $scope.gridOptions.onRegisterApi = function(gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function(newPage, pageSize) {
- var filtersData = $scope.memoryfilterData;
- filtersData.idx = newPage - 1;
- filtersData.sum = pageSize;
- defaultFilterData = filtersData;
- $scope.fileData.idx=newPage - 1;
- $scope.fileData.sum=pageSize;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- gridApi.selection.on.rowSelectionChanged($scope, function(scope) {
- var j = 0;
- for (var i = 0; i <= scope.grid.appScope.selected.items.length; i++) {
- if (scope.grid.appScope.selected.items[i] == scope.entity) {
- j++;
- break;
- }
- }
- // console.log("j="+j)
- if (j == 1) {
- scope.grid.appScope.selected.items.splice(i, 1);
- } else {
- scope.grid.appScope.selected.items.push(scope.entity)
- }
- });
- gridApi.core.on.filterChanged($scope, function() {
- var grid = this.grid;
- var filtersData = $scope.memoryfilterData;
- angular.forEach(grid.columns, function(item) {
- if (item.enableFiltering) {
- if (angular.isDefined(item.filters[0].term) && item.filters[0].term != '') {
- if (angular.isUndefined(filtersData['user'])) {
- filtersData['notice'] = {};
- filtersData['notice'][item.field] = item.filters[0].term;
- } else {
- filtersData.notice[item.field] = item.filters[0].term;
- }
- }
- }
- });
- $scope.memoryfilterData = filtersData;
- $scope.refreshData('expand-right', $scope.fileData);
- });
- };
- //录音
- $scope.recordcall = function(data) {
- var modalInstance = $modal.open({
- backdrop: "static",
- templateUrl: 'assets/views/incident/tpl/audio.html',
- controller: function($rootScope, $scope, $modalInstance, $sce, $http, api_playservice) {
- $scope.audioUrl=$sce.trustAsResourceUrl(callIp+data.recordingFileName);
- // $rootScope.setbusy();
- // $scope.datasurl = "";
- // $http({
- // url: callIp + "/recording/recording?recordId=" + data.id,
- // method: 'GET',
- // headers: {},
- // }).success(function(data, status, headers, config) {
- // $scope.data = {
- // "name": "视频",
- // "url": $sce.trustAsResourceUrl("http://" + data.rrpath)
- // };
- // $scope.datasurl = data.rrpath;
- // }).error(function(data, status, headers, config) {});
- // $scope.download = function(contentId, filename) {
- // $http({
- // url: "http://" + $scope.datasurl,
- // method: 'GET',
- // headers: {
- // 'Content-type': 'application/octet-stream',
- // },
- // responseType: 'arraybuffer'
- // }).success(function(data, status, headers, config) {
- // var file = new Blob([data], {
- // type: 'application/octet-stream'
- // });
- // //trick to download store a file having its URL
- // var fileURL = URL.createObjectURL(file);
- // var a = document.createElement('a');
- // a.href = fileURL;
- // a.target = '_blank';
- // a.download = filename;
- // document.body.appendChild(a);
- // a.click();
- // }).error(function(data, status, headers, config) {
- // // console.log(data);
- // });
- // }
- $scope.cancel = function() {
- $modalInstance.dismiss('cancel');
- };
- $modalInstance.close();
- }
- });
- modalInstance.result.then(function(result) {
- // $rootScope.setidle();
- }, function(reason) {
- $rootScope.setidle();
- });
- };
- $scope.fileData={
- "idx":0,
- "sum":10,
- "callrecord":{}
- }
- $scope.jsearchkeys={};
- $scope.search=function(){
- if($scope.jsearchkeys.type){
- $scope.fileData.callrecord.type=$scope.jsearchkeys.type.id
- }
- $scope.refreshData('expand-right',$scope.fileData);
- }
- $scope.clear=function(){
- delete $scope.fileData.callrecord.callerIdNumber;
- delete $scope.fileData.callrecord.destinationNumber;
- delete $scope.fileData.callrecord.type;
- $scope.jsearchkeys={};
- $scope.refreshData('expand-right',$scope.fileData);
- }
-
- $scope.recordcallid = function(data) {
- // var telephone = '9' + data.ano;
- // $rootScope.callout = 2;
- // if ($rootScope.takes) {
- // api_text.dialout($rootScope.takes, "@0", telephone).then(function(data) {
- // if (data.errno == 0) {
- // $rootScope.status = 6;
- // $scope.oldRecord(data);
- // }
- // })
- // } else {
- // SweetAlert.swal({
- // title: "呼叫失败",
- // text: "请先签入呼叫中心!",
- // type: "error",
- // confirmButtonColor: "#DD6B55"
- // });
- // }
- // $rootScope.dial(data.callerIdNumber)
- // var agcount = tlwsa.tlaGetagentcount();
- // var agcountFlag = false;
- // console.log(data.callerIdNumber)
- // // 查询当前话机是否签入
- // for (var i = 0; i < agcount; i++) {
- // if (tlwsa.tlaGetagentwid(i) == $rootScope.phoneNumber) {
- // agcountFlag = true;
- // }
- // }
- if (localStorage.getItem('fenjiNumber')) {
- // var caller = localStorage.getItem('phoneNumber');//呼叫人
- // console.log(sessionStorage.getItem('phones'))
- // var phones = JSON.parse(sessionStorage.getItem('phones'));
- // var isHuajihao = phones.length?phones.some(v=>v == data.callerIdNumber):false;
- // console.log(isHuajihao)
- // if(isHuajihao){
- // tlwsa.tlaCallagc(data.callerIdNumber);//呼叫坐席
- // }else{
- // tlwsa.tlaCallout(data.callerIdNumber, caller, 0);//呼叫外线
- // }
- var caller = localStorage.getItem('fenjiNumber');//呼叫人
- tlwsa.tlaCallout(data.callerIdNumber, caller, 0);
- } else {
- SweetAlert.swal({
- title: "呼叫失败",
- text: "请先签入呼叫中心!",
- type: "error",
- confirmButtonColor: "#DD6B55",
- });
- }
- };
- $scope.ldloading = {};
- $scope.refreshData = function(style, filterData) {
- $scope.ldloading[style.replace('-', '_')] = true;
- var faldata = { idx: 0, sum: 10 };
- if (filterData) {
- faldata = angular.extend(faldata, filterData)
- }
- $scope.memoryfilterData = faldata;
- api_bpm_data.fetchDataList("callrecord", faldata).then(function(data) {
- var myData = Restangular.stripRestangular(data);
- $scope.gridOptions['totalItems'] = myData.totalNum;
- $scope.myData = myData.list;
- for (var i = 0; i < $scope.myData.length; i++) {
- if(!$scope.myData[i]["id"]){
- $scope.myData[i]["id"]=i + 1 + $scope.fileData.idx * $scope.fileData.sum;
- }
- $scope.myData[i]['item'] = i + 1 + $scope.fileData.idx * $scope.fileData.sum;
- };
- // console.log($scope.myData)
- $scope.ldloading[style.replace('-', '_')] = false;
- }, function() {
- $scope.ldloading[style.replace('-', '_')] = false;
- });
- };
- $scope.refreshData('expand-right',$scope.fileData);
- $scope.timer=$interval(function(){
- $scope.refreshData('expand-right', $scope.fileData);
- },$rootScope.refreshTime);
- $scope.$on('$destroy',function(){
- $interval.cancel($scope.timer)
- });
- }]);
- app.controller('wechatoperator1', ['$rootScope', '$http', '$scope', '$modal', function($rootScope, $http, $scope, $modal) {
- var loginUser = $rootScope.user;
- $scope.chuli=false;
- for(var i=0;i<loginUser.menu.length;i++){
- if(loginUser.menu[i].link=="tonghualiebiao_chuli"){
- $scope.chuli=true
- }
- };
- $scope.yijie=true;
- console.log($scope.item.answeredTime);
- if(!$scope.item.answeredTime){
- $scope.yijie=false;
- }
- $scope.recordcall = function() {
- $scope.colobject.grid.appScope.recordcall($scope.item);
- }
- $scope.recordcallid = function() {
- $scope.colobject.grid.appScope.recordcallid($scope.item);
- }
- }]);
- app.directive('wechatoperator1', function() {
- return {
- restrict: 'E',
- scope: {
- item: '=',
- colobject: '='
- },
- controller: 'wechatoperator1',
- template: '<div class="links cl-effect-1 ui-grid-cell-contents pull-left" >' +
- '<a ng-click="recordcall()" ng-show="chuli&&yijie" class="bianjifont">通话录音</a>' +
- '<a ng-click="recordcallid()" ng-show="chuli" class="bianjifont">回拨</a>' +
- '</div>'
- };
- });
|