//物料入库看板
var interval_do=null;//页面刷新定时器
clearInterval(interval_do);
var MyMarhq = '';//滚动定时器
clearInterval(MyMarhq);
$(function() {
doData()
interval_do = setInterval(getKanbanData,3000 * 1000); // 启动,执行默认方法
})
function doData(){
tableBox()
}
function tableBox(){
var Items = KANBAN_DATA.data
$('.tbl-body tbody').empty();
$('.tbl-header tbody').empty();
var str = '';
var style = '';
var border = '';
var style1 = '';
if(Items.length<=15){//不滚动
$.each(Items,function (i, item) {
if(i==Items.length-1){
//style = "style='border-bottom: 2px solid #333399;padding:5px;'";
border='border-bottom: 2px solid #333399;padding:5px;'
style = "style='border-bottom: 2px solid #333399;padding:5px;'";
}else{
style = "style='padding:5px;'";
}
if(item.URGENT_FLAG>0){
style1 = "style='color:#CC0033;"+border+"'";
}else{
style1 = "style='color:#FFFFFF;"+border+"'";
}
str = '
'+
''+isNull(item.综合仓)+' | '+
''+isNull(item.包装车间)+' | '+
''+isNull(item.注塑件仓)+' | '+
'
'
$('.tbl-body tbody').append(str);
$('.tbl-header tbody').append(str);
});
}else{//会滚动
$.each(Items,function (i, item) {
style = "style=''";
if(item.URGENT_FLAG>0){
style1 = "style='color:#CC0033;"+border+"'";
}else{
style1 = "style='color:#FFFFFF;"+border+"'";
}
str = ''+
''+isNull(item.综合仓)+' | '+
''+isNull(item.包装车间)+' | '+
''+isNull(item.注塑件仓)+' | '+
'
'
$('.tbl-body tbody').append(str);
$('.tbl-header tbody').append(str);
});
}
if (MyMarhq != null) {// 判断计时器是否为空-关闭
clearInterval(MyMarhq);
MyMarhq = null;
}
if(Items.length > 15){
$('.tbl-body tbody').html($('.tbl-body tbody').html()+$('.tbl-body tbody').html());
$('.tbl-body').css('top', '0');
var tblTop = 0;
var speedhq = 50; // 数值越大越慢
var outerHeight = $('.tbl-body tbody').find("tr").outerHeight();
function Marqueehq(){
if(tblTop <= -outerHeight*Items.length){
tblTop = 0;
} else {
tblTop -= 1;
}
$('.tbl-body').css('top', tblTop+'px');
}
MyMarhq = setInterval(Marqueehq,speedhq);
// 鼠标移上去取消事件
$(".tbl-header tbody").hover(function (){
clearInterval(MyMarhq);
},function (){
clearInterval(MyMarhq);
MyMarhq = setInterval(Marqueehq,speedhq);
})
}
}
function getKanbanData(){
$.ajax({
type : "GET",
url : context + "/kanban/TOKCSET",
data : {floor:FLOOR},
dataType : "json",
success : function(res) {
console.log(res)
if (res.result) {
KANBAN_DATA=res
doData()
} else {
//clearInterval(interval_do);//错误-关闭定时器
}
}
});
}
//插入样式
function setColor(style,value){
var bgcolor=''
if(value=='N'){
}else{
if(value=="0"){
bgcolor='background-color:#999999;'
}else if(value=="100"){
bgcolor='background-color:#33CC99;'
}else{
bgcolor='background-color:#FF9900;'
}
var s=style.substring(0, style.length-1)
style = s+bgcolor+"'";
}
return style
}
function isNull(str){
if(str==null){
return ""
}else{
return str
}
}