/** * 接通呼损统计 * */ var token = $.cookie("token"), tabtu, xzhou, jtCount, //接通次数 hsCount, //呼损次数 jtPercent, //接通率 hsPercent; //呼损率 $(document).ready(function() { $('.tool_bars').authorizeButton(); laydate.render({ elem: '#chooseTime', theme: '#249fea', range: '~', }); //图形 tabtu = echarts.init(document.getElementById('tabtu')); option = { tooltip: { trigger: 'axis', }, legend: { data: ['接通次数', '呼损次数', '接通率', '呼损率'], bottom: 0 }, xAxis: [{ type: 'category', data: xzhou, axisPointer: { type: '' }, axisLabel: { rotate: 30, interval: 0 } }], yAxis: [{ type: 'value', name: '通话次数(通)', nameLocation: 'middle', nameGap: 40, // min: 0, // max:300, interval: 50, axisLabel: { formatter: '{value}' } }, { type: 'value', name: '百分比(%)', nameLocation: 'middle', nameGap: 35, min: 0, max: 100, interval: 10, axisLabel: { formatter: '{value}%' } } ], series: [{ type: 'bar', name: '接通次数', data: jtCount }, { type: 'bar', name: '呼损次数', data: hsCount }, { type: 'line', name: '接通率', data: jtPercent, yAxisIndex: 1, }, { type: 'line', name: '呼损率', data: hsPercent, yAxisIndex: 1, } ], color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f'] }; 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() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "SwitchedlossCall/GetColumnList", async: true, dataType: 'json', data: { token: token }, success: function(res) { var con = res.data; for(var i = 0; i < con.length; i++) { $('' + con[i] + '').appendTo('.thTable thead tr') } } }); } //导出 function btn_export() { var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + token; var st = $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[0]; var et = $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[1]; url += "&stime=" + st + "&endtime=" + et; window.location.href = url; } //获取数据 function getDatalist() { var jtshu = [], hsshu = [], jtlv = [], hslv = [], riqi = []; $.ajax({ type: 'get', url: huayi.config.callcenter_url + 'SwitchedlossCall/GetDataList', async: false, dataType: 'json', data: { token: token, stime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[0], endtime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[1] }, success: function(data) { var tbodyCon = data.data; for(var j = 0; j < tbodyCon.length; j++) { $('' + tbodyCon[j].日期 + '' + tbodyCon[j].接通次数 + '' + tbodyCon[j].呼损次数 + '' + tbodyCon[j].接通率 + '' + tbodyCon[j].呼损率 + '').appendTo('.thTable tbody'); riqi.push(tbodyCon[j].日期) jtshu.push(tbodyCon[j].坐席名称); hsshu.push(tbodyCon[j].呼入次数); jtlv.push(tbodyCon[j].呼出次数); hslv.push(tbodyCon[j].通话总时长); } } }); xzhou = riqi; jtCount = jtshu; hsCount = hsshu; jtPercent = jtlv; hsPercent = hslv; option.xAxis[0].data = xzhou; option.series[0].data = jtCount; option.series[1].data = hsCount; option.series[2].data = jtPercent; option.series[3].data = hsPercent; }