onFormMounted(){ const table = document.getElementsByClassName('el-table__body'); const rows = table[0].getElementsByTagName('tbody')[0].getElementsByTagName('tr'); const rows1 = table[1].getElementsByTagName('tbody')[0].getElementsByTagName('tr'); function processMultilineText(text) { // 将文本按换行符分割成数组 const lines = text.split('\n');
ini
// 处理每一行
let htmlOutput = '';
lines.forEach(line => {
if (!line.trim()) return; // 跳过空行
htmlOutput += `<div class="text-line">${line}</div>`;
});
return htmlOutput;
} setTimeout(function() { for (let i = 0; i < rows.length; i++) {
ini
const satAmCell = rows[i].cells[1];
const satPmCell = rows[i].cells[2];
const satAmContent = satAmCell.textContent.trim();
const satPmContent = satPmCell.textContent.trim();
// 检查是否需要合并
if (satAmContent === '' || satPmContent === '') {
// 设置合并单元格
satAmCell.colSpan = 2;
satAmCell.classList.add('merged-cell');
// 确定显示的内容
if (satAmContent !== '') {
satAmCell.textContent = satAmContent;
} else if (satPmContent !== '') {
satAmCell.textContent = satPmContent;
} else {
satAmCell.textContent = '';
satAmCell.classList.add('empty-cell');
}
// 移除下午单元格
satPmCell.style.display = 'none';
}
const satAmCell1 = rows[i].cells[3];
const satPmCell1 = rows[i].cells[4];
console.error(satPmCell1)
const satAmContent1 = satAmCell1.textContent.trim();
const satPmContent1 = satPmCell1.textContent.trim();
// 检查是否需要合并
if (satAmContent1 === '' || satPmContent1 === '') {
// 设置合并单元格
satAmCell1.colSpan = 2;
satAmCell1.classList.add('merged-cell');
// 确定显示的内容
if (satAmContent1 !== '') {
satAmCell1.textContent = satAmContent1;
} else if (satPmContent1 !== '') {
satAmCell1.textContent = satPmContent1;
} else {
satAmCell1.textContent = '';
satAmCell1.classList.add('empty-cell');
}
// 移除下午单元格
satPmCell1.style.display = 'none';
}
}
ini
for (let i = 0; i < rows1.length; i++) {
const satAmCell3 = rows1[i].cells[3];
satAmCell3.innerHTML=processMultilineText(satAmCell3.textContent)
}
}, 1000) }