'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 = false; $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]; $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:ss'); } $scope.gridOptions.columnDefs = [{ name: 'item', displayName: '序号', width: 50 }, { name: 'ano', displayName: '主叫号码', width: '10%' }, { name: 'bno', displayName: '拨打号码', width: '10%' }, { name: 'begTime', displayName: '开始时间', width: '15%', cellTemplate: '
' + '
{{grid.appScope.transferTime(row.entity.begTime)}}
' + '
' }, { name: 'endTime', displayName: '结束时间', width: '15%', cellTemplate: '
' + '
{{grid.appScope.transferTime(row.entity.endTime)}}
' + '
' }, , { name: 'duration', displayName: '通话时长(秒)', width: '10%' }, { name: 'isRouteAgent', displayName: '是否被座席接听', width: '10%', cellTemplate: '
' + '
{{grid.appScope.translateone(row.entity.isRouteAgent)}}
' + '
' }, { name: 'routedDN', displayName: '座席工号', width: '15%' }, { name: 'type', displayName: '呼入/呼出', width: '10%', cellTemplate: '
' + '
{{grid.appScope.translatetwo(row.entity.type)}}
' + '
' // }, // { // name: '生成事件', // width: 80, // cellTemplate: '' } // { name: '操作', cellTemplate: '', enableFiltering: false } ]; $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', fildata); } $scope.clear = function() { $scope.searchkeys = {}; $scope.gridOptions.paginationCurrentPage = 1; $scope.memoryfilterData = defaultFilterData; $scope.refreshData('expand-right'); } $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.refreshData('expand-right', filtersData); }); 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', filtersData); }); }; $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("hjzxCall", 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++) { $scope.myData[i]['item'] = i + 1 + $scope.memoryfilterData.idx * $scope.memoryfilterData.sum } // console.log($scope.myData) $scope.ldloading[style.replace('-', '_')] = false; }, function() { $scope.ldloading[style.replace('-', '_')] = false; }); }; $scope.refreshData('expand-right'); }]);