feat: 移除pdf下载功能
This commit is contained in:
@ -174,67 +174,67 @@ const tabHeightFn = () => {
|
||||
};
|
||||
/** 以pdf形式下载 */
|
||||
const downLoadPdf = async () => {
|
||||
downLoading.value = true;
|
||||
ElMessage.info('下载界面会展开,是正常的。');
|
||||
// downLoading.value = true;
|
||||
// ElMessage.info('下载界面会展开,是正常的。');
|
||||
|
||||
try {
|
||||
// 强制刷新所有图表
|
||||
const resizeEvent = new Event('resize');
|
||||
window.dispatchEvent(resizeEvent);
|
||||
// try {
|
||||
// // 强制刷新所有图表
|
||||
// const resizeEvent = new Event('resize');
|
||||
// window.dispatchEvent(resizeEvent);
|
||||
|
||||
// 等待图表重绘
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
// // 等待图表重绘
|
||||
// await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
// 保存原始样式
|
||||
const originalOverflow = tableBox.value.style.overflow;
|
||||
const originalHeight = tableBox.value.style.height;
|
||||
const originalPaddingBottom = tableBox.value.style.paddingBottom;
|
||||
const originalMarginBottom = tableBox.value.style.marginBottom;
|
||||
// // 保存原始样式
|
||||
// const originalOverflow = tableBox.value.style.overflow;
|
||||
// const originalHeight = tableBox.value.style.height;
|
||||
// const originalPaddingBottom = tableBox.value.style.paddingBottom;
|
||||
// const originalMarginBottom = tableBox.value.style.marginBottom;
|
||||
|
||||
// 确保所有内容都可见,并增加底部间距
|
||||
tableBox.value.style.overflow = 'visible';
|
||||
tableBox.value.style.height = 'auto';
|
||||
tableBox.value.style.paddingBottom = '50px'; // 增加底部内边距
|
||||
tableBox.value.style.marginBottom = '30px'; // 增加底部外边距
|
||||
// // 确保所有内容都可见,并增加底部间距
|
||||
// tableBox.value.style.overflow = 'visible';
|
||||
// tableBox.value.style.height = 'auto';
|
||||
// tableBox.value.style.paddingBottom = '50px'; // 增加底部内边距
|
||||
// tableBox.value.style.marginBottom = '30px'; // 增加底部外边距
|
||||
|
||||
// 为最后的总结分析部分添加特殊样式,避免分页截断
|
||||
const summaryElements = tableBox.value.querySelectorAll('h2');
|
||||
const lastH2 = summaryElements[summaryElements.length - 1];
|
||||
if (lastH2 && lastH2.textContent.includes('总结分析')) {
|
||||
lastH2.style.pageBreakBefore = 'always';
|
||||
lastH2.style.pageBreakInside = 'avoid';
|
||||
// // 为最后的总结分析部分添加特殊样式,避免分页截断
|
||||
// const summaryElements = tableBox.value.querySelectorAll('h2');
|
||||
// const lastH2 = summaryElements[summaryElements.length - 1];
|
||||
// if (lastH2 && lastH2.textContent.includes('总结分析')) {
|
||||
// lastH2.style.pageBreakBefore = 'always';
|
||||
// lastH2.style.pageBreakInside = 'avoid';
|
||||
|
||||
// 确保总结分析的段落不被分页截断
|
||||
const nextP = lastH2.nextElementSibling;
|
||||
if (nextP && nextP.tagName === 'P') {
|
||||
nextP.style.pageBreakInside = 'avoid';
|
||||
nextP.style.marginBottom = '30px';
|
||||
}
|
||||
}
|
||||
// // 确保总结分析的段落不被分页截断
|
||||
// const nextP = lastH2.nextElementSibling;
|
||||
// if (nextP && nextP.tagName === 'P') {
|
||||
// nextP.style.pageBreakInside = 'avoid';
|
||||
// nextP.style.marginBottom = '30px';
|
||||
// }
|
||||
// }
|
||||
|
||||
await downloadPDF(tableBox.value, '警情分析报告');
|
||||
// await downloadPDF(tableBox.value, '警情分析报告');
|
||||
|
||||
// 恢复原始样式
|
||||
tableBox.value.style.overflow = originalOverflow;
|
||||
tableBox.value.style.height = originalHeight;
|
||||
tableBox.value.style.paddingBottom = originalPaddingBottom;
|
||||
tableBox.value.style.marginBottom = originalMarginBottom;
|
||||
// // 恢复原始样式
|
||||
// tableBox.value.style.overflow = originalOverflow;
|
||||
// tableBox.value.style.height = originalHeight;
|
||||
// tableBox.value.style.paddingBottom = originalPaddingBottom;
|
||||
// tableBox.value.style.marginBottom = originalMarginBottom;
|
||||
|
||||
// 恢复总结分析部分的样式
|
||||
if (lastH2) {
|
||||
lastH2.style.pageBreakBefore = '';
|
||||
lastH2.style.pageBreakInside = '';
|
||||
const nextP = lastH2.nextElementSibling;
|
||||
if (nextP && nextP.tagName === 'P') {
|
||||
nextP.style.pageBreakInside = '';
|
||||
nextP.style.marginBottom = '';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('下载失败:', error);
|
||||
} finally {
|
||||
downLoading.value = false;
|
||||
}
|
||||
// // 恢复总结分析部分的样式
|
||||
// if (lastH2) {
|
||||
// lastH2.style.pageBreakBefore = '';
|
||||
// lastH2.style.pageBreakInside = '';
|
||||
// const nextP = lastH2.nextElementSibling;
|
||||
// if (nextP && nextP.tagName === 'P') {
|
||||
// nextP.style.pageBreakInside = '';
|
||||
// nextP.style.marginBottom = '';
|
||||
// }
|
||||
// }
|
||||
// } catch (error) {
|
||||
// console.error('下载失败:', error);
|
||||
// } finally {
|
||||
// downLoading.value = false;
|
||||
// }
|
||||
}
|
||||
const downloadWithStyles = async () => {
|
||||
if (!tableBox.value?.innerHTML) return;
|
||||
|
||||
Reference in New Issue
Block a user