//物料入库看板 var interval_do=null;//页面刷新定时器 clearInterval(interval_do); var MyMarhq = '';//滚动定时器 clearInterval(MyMarhq); $(function() { getKanbanBl() doData() interval_do = setInterval(getKanbanData,3000 * 1000); // 启动,执行默认方法 interval_do2 = setInterval(getKanbanBl,100 * 1000); // 启动,执行默认方法 }) function doData(){ tableBox() BL() } function BL(){ var item=Bl.data // 获取数据 var todayMaterialData = item[0].今日备料 var todayIncompleteData = item[0].未完成 var twoDaysIncompleteData = item[0].两天未完成 var fourDaysIncompleteData = item[0].四天未完成 console.log(todayMaterialData); // 插入到相应的元素 $('#todayMaterial').text( todayMaterialData); $('#todayIncomplete').text( todayIncompleteData); $('#twoDaysIncomplete').text( twoDaysIncompleteData); $('#fourDaysIncomplete').text( fourDaysIncompleteData); } 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.BOARD_ITEM)+''+ ''+isNull(item.预计开工时间)+''+ ''+isNull(item.通知备料时间)+''+ ''+isNull(item.产品编码)+''+ ''+isNull(item.产品名称)+''+ ''+isNull(item.产品规格)+''+ ''+isNull(item.工单数)+''+ ''+'
'+isNull(item.注塑件仓)+'
'+ ''+'
'+isNull(item.装配前工序仓)+'
'+ ''+'
'+isNull(item.综合仓库)+'
'+ ''+'
'+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.BOARD_ITEM)+''+ ''+isNull(item.预计开工时间)+''+ ''+isNull(item.通知备料时间)+''+ ''+isNull(item.产品编码)+''+ ''+isNull(item.产品名称)+''+ ''+isNull(item.产品规格)+''+ ''+isNull(item.工单数)+''+ '
'+isNull(item.注塑件仓)+'
'+ '
'+isNull(item.装配前工序仓)+'
'+ '
'+isNull(item.综合仓库)+'
'+ '
'+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 getKanbanBl(){ $.ajax({ type : "GET", url : context + "kanban/getBZBl", data : {floor:1}, dataType : "json", success : function(res) { console.log(res) if (res.result) { Bl=res doData() } else { //clearInterval(interval_do);//错误-关闭定时器 } } }); } function getKanbanData(){ $.ajax({ type : "GET", url : context + "kanban/getMaterialAllSetList", 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 } }