/**
* 质检数据报表
* */
var token = $.cookie("token");
var expor;
$(function() {
$('.tool_bars').authorizeButton();
laydate.render({
elem: '#chooseTime',
theme: '#249fea',
range: '~',
});
//部门下拉数据
getDeptLists();
getColumnList();
getDataList();
//点击搜索事件
$('#sc_btns').click(function() {
$('.zjTable tbody').html('');
getDataList();
})
$('#department').on('focus click', function() {
$('#deptTreeView').removeClass('hidden').addClass('show');
});
$('#department').on('keyup', function() {
if($(this).val() == '') {
$('deptTreeView').treeview('uncheckAll', {
silent: true
});
$(this).attr('data-id', '-1');
}
});
$('#department + .caret').on('click', function() {
$('#deptTreeView').removeClass('hidden').addClass('show');
});
$('#deptTreeView').mouseleave(function() {
$(this).removeClass('show').addClass('hidden');
});
});
//表头
function getColumnList() {
$.ajax({
type: "get",
dataType: "json",
url: huayi.config.callcenter_url + "QCResult/GetColumnList?expor",
async: true,
data: {
token: token,
isext: expor
},
success: function(data) {
var content = data.data;
for(var i = 0; i < content.length; i++) {
$('
' + content[i].Qcname + ' | ').appendTo('.zjTable thead tr.one')
if(content[i].Qcscore !== null) {
$('' + content[i].Qcscore + ' | ').appendTo('.zjTable thead tr.four')
}
if(content[i].Qclist !== null) {
var twoCon = content[i].Qclist;
for(var j = 0; j < twoCon.length; j++) {
$('' + twoCon[j].Qcname + ' | ').appendTo('.zjTable thead tr.two')
if(twoCon[j].Qclist !== null) {
var threeCon = twoCon[j].Qclist;
for(var g = 0; g < threeCon.length; g++) {
$('' + threeCon[g].Qcname + ' | ').appendTo('.zjTable thead tr.three')
$('' + threeCon[g].Qcscore + ' | ').appendTo('.zjTable thead tr.four')
}
}
}
}
}
}
});
}
//表格数据
function getDataList() {
$.ajax({
type: "get",
dataType: "json",
url: huayi.config.callcenter_url + "QCResult/GetDataList?expor",
async: true,
data: {
stime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[0],
endtime: $('#chooseTime').val() && $('#chooseTime').val().split(' ~ ')[1],
dpt: $("#department").val(),
isext: expor,
token: token,
},
success: function(result) {
var tbodyCon = result.data;
if(tbodyCon.length > 0) {
for(var i = 0; i < tbodyCon.length; i++) {
$('| ' + tbodyCon[i].QCName + ' | ' + tbodyCon[i].UserName + ' | ' + tbodyCon[i].UserCode + ' | ' + tbodyCon[i].ZJCount + ' | ' + tbodyCon[i].Q1 + ' | ' + tbodyCon[i].Q2 + ' | ' + tbodyCon[i].Q4 + ' | ' + tbodyCon[i].Q5 + ' | ' + tbodyCon[i].Q6 + ' | ' + tbodyCon[i].Q7 + ' | ' + tbodyCon[i].Q8 + ' | ' + tbodyCon[i].Q9 + ' | ' + tbodyCon[i].Q10 + ' | ' + tbodyCon[i].df0 + ' | ' + tbodyCon[i].Q12 + ' | ' + tbodyCon[i].Q13 + ' | ' + tbodyCon[i].Q14 + ' | ' + tbodyCon[i].Q15 + ' | ' + tbodyCon[i].Q16 + ' | ' + tbodyCon[i].Q17 + ' | ' + tbodyCon[i].Q18 + ' | ' + tbodyCon[i].df1 + ' | ' + tbodyCon[i].Q19 + ' | ' + tbodyCon[i].Q20 + ' | ' + tbodyCon[i].Q21 + ' | ' + tbodyCon[i].Q22 + ' | ' + tbodyCon[i].Q23 + ' | ' + tbodyCon[i].Q24 + ' | ' + tbodyCon[i].Q25 + ' | ' + tbodyCon[i].Q26 + ' | ' + tbodyCon[i].df2 + ' | ' + tbodyCon[i].AllScore + ' |
').appendTo('.zjTable tbody')
}
}else{
$('| 没有数据... |
').appendTo('.zjTable tbody');
}
}
});
}
//获取部门
function getDeptLists() {
$.getJSON(huayi.config.callcenter_url + 'Department/GetDeptList', {
token: $.cookie("token")
}, function(result) {
if(result.state.toLowerCase() == "success") {
var defaultDatas = result.data;
var $sTree = $('#deptTreeView').treeview({
color: "#428bca",
expandIcon: 'glyphicon glyphicon-chevron-right',
collapseIcon: 'glyphicon glyphicon-chevron-down',
nodeIcon: 'fa fa-folder-o',
data: defaultDatas,
onNodeSelected: function(event, node) {
$sTree.treeview('clearSearch');
$('#department').val(node.text);
$('#department').attr('data-id', node.id);
$('#deptTreeView').removeClass('show').addClass('hidden');
},
onNodeUnselected: function(event, node) {
$('#department').val('');
$('#department').attr('data-id', '-1');
}
});
var findSNodes = function() {
return $sTree.treeview('search', [$('#department').val(), {
ignoreCase: false,
exactMatch: false
}]);
};
$('#department').on('keyup', function(e) {
var selectableNodes = findSNodes();
});
}
})
}