122 lines
3.6 KiB
JavaScript
122 lines
3.6 KiB
JavaScript
|
|
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 = '<i class="layui-icon layui-icon-rate-solid star"></i>'.repeat(fullStars);
|
||
|
|
|
||
|
|
if (halfStar) {
|
||
|
|
stars += '<i class="layui-icon layui-icon-rate-half star"></i>';
|
||
|
|
} else if (remainder >= 0.75) {
|
||
|
|
stars += '<i class="layui-icon layui-icon-rate-solid star"></i>';
|
||
|
|
}
|
||
|
|
|
||
|
|
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 += '<tr>' +
|
||
|
|
'<td class="col-1">' + (item.teamName || '') + '</td>' +
|
||
|
|
'<td class="col-2">' + (item.workManager || '') + '</td>' +
|
||
|
|
'<td class="col-3">' + (item.proName || '') + '</td>' +
|
||
|
|
'<td class="col-4">' + setStatusData(item.status) + '</td>' +
|
||
|
|
'<td class="col-5">' + renderStars(item.star) + '</td>' +
|
||
|
|
'</tr>';
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
html = '<tr><td colspan="5" style="text-align: center;">无数据</td></tr>';
|
||
|
|
}
|
||
|
|
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 url = dataUrl + "proteam/pot/teamManage/getList";
|
||
|
|
ajaxRequest(url, "POST", null, true, () => {}, (result) => {
|
||
|
|
if (result.code === 200) {
|
||
|
|
const tables = ['lowerData', 'noData', 'blackData', 'minData', 'newData', 'maxData'];
|
||
|
|
tables.forEach((tableId) => {
|
||
|
|
// 初始化表格和滚动
|
||
|
|
fillTable('#'+tableId, result[tableId] || []);
|
||
|
|
// continuousScroll('#'+tableId);
|
||
|
|
})
|
||
|
|
} else if (result.code === 500) {
|
||
|
|
layer.alert(result.msg, { icon: 2 });
|
||
|
|
}
|
||
|
|
}, (xhr, status, error) => errorFn(xhr, status, error), null);
|
||
|
|
}
|
||
|
|
|
||
|
|
initData();
|
||
|
|
});
|