var token = $.cookie("token"); var tabtu, legend = []; //图例 $(document).ready(function() { laydate.render({ elem: '#startTime', range: '~', theme: '#00a1cb', }); //tab切换 $('.th-tab li').click(function() { $(this).addClass('active') .siblings().removeClass('active'); var index = $(this).index(); $('.th-content >div').eq(index).show() .siblings().hide(); }) //搜索事件 $(".sear").click(function() { $('.thTable tbody').html(''); Ajax(); }); //导出功能 $('.export').click(function() { dcexcel(this); }) //图形 tabtu = echarts.init(document.getElementById('tabtu')); tabtu.setOption({ tooltip: { trigger: 'axis', }, legend: { data: legend, bottom: 0 }, xAxis: [{ type: 'category', data: [], axisPointer: { type: '' } }], yAxis: [{ type: 'value', name: '通话次数(通)', nameLocation: 'middle', nameGap: 35, // interval: 50, axisLabel: { formatter: '{value} ' } }, { type: 'value', name: '通话时长(s)', nameLocation: 'middle', nameGap: 35, // interval: 100, axisLabel: { formatter: '{value} ' } } ], series: [{ type: 'bar', name: '呼入次数', data: [] }, { type: 'line', name: '呼入时长', yAxisIndex: 1, data: [] }, { type: 'bar', name: '呼出次数', data: [] }, { type: 'line', name: '呼出时长', yAxisIndex: 1, data: [] }, { type: 'bar', name: '呼出未接通次数', data: [] }, { type: 'line', name: '振铃时长', yAxisIndex: 1, data: [] }, { type: 'line', name: '通话总时长', yAxisIndex: 1, data: [] }, { type: 'line', name: '平均通话时长', yAxisIndex: 1, data: [] } ], color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f', '#cddc39', '#ff5722', '#e91e63', '#673ab7'] }); Ajax(); }) //表头数据 //var con; $.ajax({ type: "get", url: huayi.config.callcenter_url + "TalkTime/GetColumnList", async: false, dataType: 'json', data: { token: token }, success: function(res) { var con = res.data; $('#thead thead tr').html('');; for(var i = 0; i < con.length; i++) { $('' + con[i]+ '').appendTo('#thead thead tr'); } legend=con; } }); //legend = con; //导出 function dcexcel(obj) { var url = huayi.config.callcenter_url + "TalkTime/ExptList?token=" + $.cookie("token"); url += "&stime=" + ($('#startTime').val() && $('#startTime').val().split('~')[0]) + "&endtime=" + ($('#startTime').val() && $('#startTime').val().split('~')[1]); obj.href = url; } //表格数据 function Ajax() { 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: $('#startTime').val() && $('#startTime').val().split('~')[0], endtime: $('#startTime').val() && $('#startTime').val().split('~')[1] }, success: function(data) { var tbodyCon = data.data; console.log(tbodyCon); for(var j = 0; j < tbodyCon.length; j++) { $('' + tbodyCon[j].坐席名称+ '' + tbodyCon[j].呼入次数+ '' + studyTime(tbodyCon[j].呼入时长)+ '' + tbodyCon[j].呼出次数+ '' + studyTime(tbodyCon[j].呼出时长)+ '' + tbodyCon[j].呼出未接通次数+ '' + studyTime(tbodyCon[j].振铃时长) + '' + studyTime(tbodyCon[j].通话总时长)+ '' + studyTime(tbodyCon[j].平均通话总时长)+ '').appendTo('.thTable tbody') zx_name.push(tbodyCon[j].坐席名称); huru.push(tbodyCon[j].呼入次数) huruTime.push(((tbodyCon[j].呼入时长/60).toFixed(2))*1) huchu.push(tbodyCon[j].呼出次数) huchuTime.push(((tbodyCon[j].呼出时长/60).toFixed(2))*1) hcNo.push(tbodyCon[j].呼出未接通次数) zlTime.push(((tbodyCon[j].振铃时长/60).toFixed(2))*1) allCall.push(((tbodyCon[j].通话总时长/60).toFixed(2))*1) averange.push(((tbodyCon[j].平均通话总时长/60).toFixed(2))*1) } tabtu.setOption({ xAxis: { data: zx_name }, series: [{ data: huru }, { data: huruTime }, { data: huchu }, { data: huchuTime }, { data: hcNo }, { data: zlTime }, { data: allCall }, { data: averange }] }) } }); } var hour = 0, minute = 0, second = 0; function studyTime(t) { console.log(t) hour = Math.floor(t / 60 / 60); minute = Math.floor(t / 60 % 60); second = Math.floor(t % 60); if(hour < 10) { hour = "0" + hour; } if(minute < 10) { minute = "0" + minute; } if(second < 10) { second = "0" + second; } return hour +":"+ minute +":"+ second; }