/** * 通话时长统计 * */ var token = $.cookie("token"), tabtu, legend = [], //图例 zxn, //坐席名称 callIn, //呼入次数 callInTime, //呼入时长 callOut, //呼出次数 callOutTime, //呼出时长 hcNoCount, //呼出未接通次数 zhenLing, //振铃时长 total, //通话总时长 pingjun; //平均通话时长 $(document).ready(function() { $('.tool_bars').authorizeButton(); laydate.render({ elem: '#choseTime', theme: '#249fea', range: '~', }); //图形 tabtu = echarts.init(document.getElementById('tabtu')); option = { tooltip: { trigger: 'axis', }, legend: { data: legend, bottom: 0 }, xAxis: [{ type: 'category', data: zxn, axisPointer: { type: '' } }], yAxis: [{ type: 'value', name: '通话次数(通)', nameLocation: 'middle', nameGap: 35, // min: 0, // max:300, interval: 50, axisLabel: { formatter: '{value} ' } }, { type: 'value', name: '通话时长(s)', nameLocation: 'middle', nameGap: 35, // min: 0, // max: 150, interval: 100, axisLabel: { formatter: '{value} ' } } ], series: [{ type: 'bar', name: '呼入次数', data: callIn }, { type: 'line', name: '呼入时长', yAxisIndex: 1, data: callInTime }, { type: 'bar', name: '呼出次数', data: callOut }, { type: 'line', name: '呼出时长', yAxisIndex: 1, data: callOutTime }, { type: 'bar', name: '呼出未接通次数', data: hcNoCount }, { type: 'line', name: '振铃时长', yAxisIndex: 1, data: zhenLing }, { type: 'line', name: '通话总时长', yAxisIndex: 1, data: total }, { type: 'line', name: '平均通话时长', yAxisIndex: 1, data: pingjun } ], color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7'] }; getDataList(); tabtu.setOption(option); getColumnList(); //tab切换 $('.th-tab li').click(function() { $(this).addClass('active') .siblings().removeClass('active'); var index = $(this).index(); $('.th-content >div').eq(index).show() .siblings().hide(); }) //搜索事件 $("#sc_btns").click(function() { $('.thTable tbody').html(''); getDataList(); tabtu.setOption(option); }); }) //表头数据 function getColumnList() { var con; $.ajax({ type: "get", url: huayi.config.callcenter_url + "TalkTime/GetColumnList", async: false, dataType: 'json', data: { token: token }, success: function(res) { con = res.data; for(var i = 0; i < con.length; i++) { $('' + con[i] + '').appendTo('.thTable thead tr') } return con } }); legend = con; } //导出功能 function btn_export() { var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + token; var st = $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[0]; var et = $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[1]; url += "&stime=" + st + "&endtime=" + et; window.location.href = url; } //图形数据 function getDataList() { var zx_name = [], huru = [], huruTime = [], huchu = [], huchuTime = [], hcNo = [], zlTime = [], allCall = [], averange = []; $.ajax({ type: 'get', url: huayi.config.callcenter_url + 'TalkTime/GetDataList', async: false, dataType: 'json', data: { token: token, stime: $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[0], endtime: $('#choseTime').val() && $('#choseTime').val().split(' ~ ')[1] }, success: function(data) { debugger; var tbodyCon = data.data; if(tbodyCon) { for(var j = 0; j < tbodyCon.length; j++) { $('' + tbodyCon[j].坐席名称 + '' + tbodyCon[j].呼入次数 + '' + tbodyCon[j].呼入时长 + '' + tbodyCon[j].呼出次数 + '' + tbodyCon[j].呼出时长 + '' + tbodyCon[j].呼出未接通次数 + '' + tbodyCon[j].振铃时长 + '' + tbodyCon[j].通话总时长 + '' + tbodyCon[j].平均通话总时长 + '').appendTo('.thTable tbody') zx_name.push(tbodyCon[j].坐席名称); huru.push(tbodyCon[j].呼入次数) huruTime.push(tbodyCon[j].呼入时长) huchu.push(tbodyCon[j].呼出次数) huchuTime.push(tbodyCon[j].呼出时长) hcNo.push(tbodyCon[j].呼出未接通次数) zlTime.push(tbodyCon[j].振铃时长) allCall.push(tbodyCon[j].通话总时长) averange.push(tbodyCon[j].平均通话总时长) } } } }); // console.log(leg); // legend=leg;//图例 zxn = zx_name; callIn = huru; //呼入次数 callInTime = huruTime; //呼入时长 callOut = huchu; //呼出次数 callOutTime = huchuTime; //呼出时长 hcNoCount = hcNo; //呼出未接通次数 zhenLing = zlTime; //振铃时长 total = allCall; //通话总时长 pingjun = averange; //平均通话时长 //console.log(zxn); option.xAxis[0].data = zxn; option.series[0].data = callIn; option.series[1].data = callInTime; option.series[2].data = callOut; option.series[3].data = callOutTime; option.series[4].data = hcNoCount; option.series[5].data = zhenLing; option.series[6].data = total; option.series[7].data = pingjun; }