35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
<script type="text/javascript">
|
|
function applyRowColoring() {
|
|
var rows = document.querySelectorAll('tr.ant-table-row-level-0');
|
|
|
|
rows.forEach(row => {
|
|
var value10 = parseFloat(row.querySelector('td:nth-child(10) span').textContent);
|
|
var value11 = parseFloat(row.querySelector('td:nth-child(11) span').textContent);
|
|
var leaveType = row.querySelector('td:nth-child(6) span').textContent;
|
|
|
|
var difvalue = value10 - value11;
|
|
|
|
// 检查当前背景色是否已设置
|
|
var currentColor = row.style.backgroundColor;
|
|
|
|
if (leaveType === '年假' || leaveType === '调休') {
|
|
if (difvalue < -20 && currentColor !== 'green') {
|
|
row.style.backgroundColor = 'green';
|
|
} else if (difvalue >= -20 && difvalue < -10 && currentColor !== 'blue') {
|
|
row.style.backgroundColor = 'blue';
|
|
} else if (difvalue >= -10 && difvalue <= 10 && currentColor !== '') {
|
|
row.style.backgroundColor = ''; // 不变
|
|
} else if (difvalue > 10 && difvalue <= 20 && currentColor !== 'orange') {
|
|
row.style.backgroundColor = 'orange';
|
|
} else if (difvalue > 20 && currentColor !== 'red') {
|
|
row.style.backgroundColor = 'red';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// 定时器每200毫秒执行一次
|
|
setInterval(function() {
|
|
applyRowColoring();
|
|
}, 200);
|
|
</script> |