var token = $.cookie("token"); var tabtu; $(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() { Ajax(); }); //导出 $('.export').click(function() { dcexcel(this); }) Ajax(); //表格数据 tableHead(); //表头 }) //图形 tabtu = echarts.init(document.getElementById('tabtu')); tabtu.setOption({ tooltip: { trigger: 'axis', }, legend: { data: ['接通次数', '呼损次数', '接通率', '呼损率'], bottom: 0 }, xAxis: [{ type: 'category', data: [], axisPointer: { type: '' }, axisLabel: { rotate: 30, interval: 0 } }], yAxis: [{ type: 'value', name: '通话次数(通)', nameLocation: 'middle', nameGap: 40, axisLabel: { formatter: '{value} ' } }, { type: 'value', name: '百分比(%)', nameLocation: 'middle', nameGap: 35, axisLabel: { formatter: '{value} ' } } ], series: [{ type: 'bar', name: '接通次数', data: [] }, { type: 'bar', name: '呼损次数', data: [] }, { type: 'line', name: '接通率', data: [], yAxisIndex: 1, }, { type: 'line', name: '呼损率', data: [], yAxisIndex: 1, } ], color: ['#1ab394', '#fbbe5b', '#88ebc4', '#fa957f'] }); //表头数据 function tableHead() { $.ajax({ type: "get", url: huayi.config.callcenter_url + "SwitchedlossCall/GetColumnList", async: true, 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') } } }); } //表格数据 function Ajax() { var jtshu = [], hsshu = [], jtlv = [], hslv = [], riqi = []; $.ajax({ type: 'get', url: huayi.config.callcenter_url + 'SwitchedlossCall/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; $('.thTable tbody').html(''); 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].呼损率); } } }); tabtu.setOption({ xAxis: { data: riqi }, series: [{ data: jtshu }, { data: hsshu }, { data: jtlv }, { data: hslv }] }) } //导出 function dcexcel(obj) { console.log($.cookie("token")) var url = huayi.config.callcenter_url + "SwitchedlossCall/ExptList?token=" + $.cookie("token"); url += "&stime=" + ($('#startTime').val() ? $('#startTime').val().split('~')[0]:'') + "&endtime=" + ($('#startTime').val()?$('#startTime').val().split('~')[1] : ''); obj.href = url; }