let form, layer, table, laydate, tableIns, user = getUser(), tableHeight; // 渲染星级 function renderStars(count) { if (count == null || count < 0.25) return ''; const fullStars = Math.floor(count); const remainder = count - fullStars; const halfStar = (remainder >= 0.25 && remainder < 0.75); let stars = ''.repeat(fullStars); if (halfStar) { stars += ''; } else if (remainder >= 0.75) { stars += ''; } return stars; } //处理状态数据 function setStatusData(status) { if (status == null){ return ''; } else if (status==='01'){ return '正常'; } else if (status==='02'){ return '解散'; } else { return ''; } } // 实现无缝滚动 function continuousScroll(containerId) { var $container = $(containerId).find('.scroll-content'); var $table = $container.find('table'); var $tbody = $table.find('tbody'); var scrollDelay = 50; var scrollStep = 1; // 如果内容不足以滚动,则不执行滚动 if ($tbody.height() <= $container.height()) { return; } // 复制表格内容 $tbody.append($tbody.html()); function scroll() { var currentTop = $container.scrollTop(); var maxTop = $tbody.height() / 2; if (currentTop >= maxTop) { $container.scrollTop(0); } else { $container.scrollTop(currentTop + scrollStep); } } var scrollInterval = setInterval(scroll, scrollDelay); // 鼠标悬停时暂停滚动 $container.hover( function() { clearInterval(scrollInterval); }, function() { scrollInterval = setInterval(scroll, scrollDelay); } ); } // 填充表格数据 function fillTable(tableId, data) { var tbody = $(tableId).find('.scroll-content tbody'); var html = ''; if (data && data.length > 0) { data.forEach(function(item) { html += '' + '' + (item.teamName || '') + '' + '' + (item.workManager || '') + '' + '' + (item.proName || '') + '' + '' + setStatusData(item.status) + '' + '' + renderStars(item.star) + '' + ''; }); } else { html = '无数据'; } tbody.html(html); // 只有在有数据的情况下才启动滚动 if (data && data.length > 0) { continuousScroll(tableId); } } function blackDataTable(tableId, data) { var tbody = $(tableId).find('.scroll-content tbody'); var html = ''; if (data && data.length > 0) { data.forEach(function(item) { html += '' + '' + (item.workManager || '') + '' + '' + (item.startDay || '') + '' + '' + (item.num || '') + '' + '' + (item.nums || '') + '' + ''; }); } else { html = '无数据'; } tbody.html(html); // 只有在有数据的情况下才启动滚动 if (data && data.length > 0) { continuousScroll(tableId); } } layui.use(['form', 'layer', 'table', 'laydate'], function () { form = layui.form; layer = layui.layer; table = layui.table; laydate = layui.laydate; function initData() { // let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); let url = dataUrl + "proteam/pot/teamManage/getList"; ajaxRequest(url, "POST", null, true, () => {}, (result) => { // layer.close(loadingMsg); if (result.code === 200) { const tables = ['lowerData', 'blackData']; tables.forEach((tableId) => { debugger if(tableId=='blackData'){ // 初始化表格和滚动 blackDataTable('#'+tableId, result[tableId] || []); }else{ // 初始化表格和滚动 fillTable('#'+tableId, result[tableId] || []); } }) } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }); } }, (xhr, status, error) => errorFn(xhr, status, error), null); } function initData1() { let url = dataUrl + "proteam/pot/teamManage/getList1"; ajaxRequest(url, "POST", null, true, () => {}, (result) => { if (result.code === 200) { const tables = ['minData']; tables.forEach((tableId) => { fillTable('#'+tableId, result[tableId] || []); }) } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }); } }, (xhr, status, error) => errorFn(xhr, status, error), null); } function initData2() { let url = dataUrl + "proteam/pot/teamManage/getList2"; ajaxRequest(url, "POST", null, true, () => {}, (result) => { if (result.code === 200) { const tables = ['maxData']; tables.forEach((tableId) => { fillTable('#'+tableId, result[tableId] || []); }) } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }); } }, (xhr, status, error) => errorFn(xhr, status, error), null); } function initData3() { let url = dataUrl + "proteam/pot/teamManage/getList3"; ajaxRequest(url, "POST", null, true, () => {}, (result) => { if (result.code === 200) { const tables = ['newData']; tables.forEach((tableId) => { fillTable('#'+tableId, result[tableId] || []); }) } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }); } }, (xhr, status, error) => errorFn(xhr, status, error), null); } function initData4() { let url = dataUrl + "proteam/pot/teamManage/getList4"; ajaxRequest(url, "POST", null, true, () => {}, (result) => { if (result.code === 200) { const tables = ['noData']; tables.forEach((tableId) => { fillTable('#'+tableId, result[tableId] || []); }) } else if (result.code === 500) { layer.alert(result.msg, { icon: 2 }); } }, (xhr, status, error) => errorFn(xhr, status, error), null); } initData(); initData1(); initData2(); initData3(); initData4(); });