/**
* 年呼叫数据对比
* */
var token = $.cookie("token"),
theadCon, //表头数据
tbodyCon; //表内数据
$(function() {
$('.tool_bars').authorizeButton();
var preYear = helper.DateFormat.getPreYear();
var nowYear = helper.DateFormat.getNowYear();
var nowValue = preYear + ' - ' + nowYear;
laydate.render({
elem: '#choseTime',
type: 'year',
theme: '#249fea',
value: nowValue,
range: true //或 range: '~' 来自定义分割字符
});
getDataList(preYear,nowYear);
//搜索事件
$("#sc_btns").click(function() {
var st = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
var et = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
if(st == et){
layer.confirm('选择的年份不能一样!', {
icon: 2,
btn: ['确定'] //按钮
});
return;
}
$('.thTable thead tr').html('');
$('.thTable tbody').html('');
getDataList(st,et);
});
});
//表格数据
function getDataList(pYear,nYear) {
var arr = [];
var allData = [];
$.ajax({
type: 'get',
url: huayi.config.callcenter_url + 'YearContrast/GetDataList',
dataType: 'json',
data: {
beginyear: pYear,
endyear: nYear,
token: token,
},
async: false,
success: function(res) {
var content = res.data;
if(content){
$.each(content, function(index, ele) {
arr.push(content[index].key)
allData.push(content[index].value)
});
}
}
});
theadCon = arr;
tbodyCon = allData;
if(theadCon.length > 0 && tbodyCon.length > 0){
$('
月份 | ').appendTo('.thTable thead tr');
for(var i = 0; i < theadCon.length; i++) {
$('' + theadCon[i] + ' | ').appendTo('.thTable thead tr');
};
$('| 1月份 | ' + tbodyCon[0][0] + ' | ' + tbodyCon[1][0] + ' | ' + tbodyCon[2][0] + ' | ' + tbodyCon[3][0] + ' | ' + tbodyCon[4][0] + ' | ' + tbodyCon[5][0] + ' |
' +
'| 2月份 | ' + tbodyCon[0][1] + ' | ' + tbodyCon[1][1] + ' | ' + tbodyCon[2][1] + ' | ' + tbodyCon[3][1] + ' | ' + tbodyCon[4][1] + ' | ' + tbodyCon[5][1] + ' |
' +
'| 3月份 | ' + tbodyCon[0][2] + ' | ' + tbodyCon[1][2] + ' | ' + tbodyCon[2][2] + ' | ' + tbodyCon[3][2] + ' | ' + tbodyCon[4][2] + ' | ' + tbodyCon[5][2] + ' |
' +
'| 4月份 | ' + tbodyCon[0][3] + ' | ' + tbodyCon[1][3] + ' | ' + tbodyCon[2][3] + ' | ' + tbodyCon[3][3] + ' | ' + tbodyCon[4][3] + ' | ' + tbodyCon[5][3] + ' |
' +
'| 5月份 | ' + tbodyCon[0][4] + ' | ' + tbodyCon[1][4] + ' | ' + tbodyCon[2][4] + ' | ' + tbodyCon[3][4] + ' | ' + tbodyCon[4][4] + ' | ' + tbodyCon[5][4] + ' |
' +
'| 6月份 | ' + tbodyCon[0][5] + ' | ' + tbodyCon[1][5] + ' | ' + tbodyCon[2][5] + ' | ' + tbodyCon[3][5] + ' | ' + tbodyCon[4][5] + ' | ' + tbodyCon[5][5] + ' |
' +
'| 7月份 | ' + tbodyCon[0][6] + ' | ' + tbodyCon[1][6] + ' | ' + tbodyCon[2][6] + ' | ' + tbodyCon[3][6] + ' | ' + tbodyCon[4][6] + ' | ' + tbodyCon[5][6] + ' |
' +
'| 8月份 | ' + tbodyCon[0][7] + ' | ' + tbodyCon[1][7] + ' | ' + tbodyCon[2][7] + ' | ' + tbodyCon[3][7] + ' | ' + tbodyCon[4][7] + ' | ' + tbodyCon[5][7] + ' |
' +
'| 9月份 | ' + tbodyCon[0][8] + ' | ' + tbodyCon[1][8] + ' | ' + tbodyCon[2][8] + ' | ' + tbodyCon[3][8] + ' | ' + tbodyCon[4][8] + ' | ' + tbodyCon[5][8] + ' |
' +
'| 10月份 | ' + tbodyCon[0][9] + ' | ' + tbodyCon[1][9] + ' | ' + tbodyCon[2][9] + ' | ' + tbodyCon[3][9] + ' | ' + tbodyCon[4][9] + ' | ' + tbodyCon[5][9] + ' |
' +
'| 11月份 | ' + tbodyCon[0][10] + ' | ' + tbodyCon[1][10] + ' | ' + tbodyCon[2][10] + ' | ' + tbodyCon[3][10] + ' | ' + tbodyCon[4][10] + ' | ' + tbodyCon[5][10] + ' |
' +
'| 12月份 | ' + tbodyCon[0][11] + ' | ' + tbodyCon[1][11] + ' | ' + tbodyCon[2][11] + ' | ' + tbodyCon[3][11] + ' | ' + tbodyCon[4][11] + ' | ' + tbodyCon[5][11] + ' |
').appendTo('.thTable tbody');
}else{
$('| 暂无数据 |
').appendTo('.thTable tbody');
}
}
//导出功能
function btn_export() {
var url = huayi.config.callcenter_url + "YearContrast/ExptList?token=" + token;
var byear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[0];
var lyear = $('#choseTime').val() && $('#choseTime').val().split(' - ')[1];
url += "&beginyear=" + byear + "&endyear=" + lyear;
window.location.href = url;
}