更新数据截止日2025.12.25
This commit is contained in:
@@ -132,6 +132,9 @@ function generateReport() {
|
||||
|
||||
document.getElementById('report-container').style.display = 'block';
|
||||
|
||||
// 启用图片导出按钮
|
||||
updateImageExportButtonState();
|
||||
|
||||
// 显示统计数据
|
||||
if (data.data.statistics) {
|
||||
displayStatistics(data.data.statistics);
|
||||
@@ -153,33 +156,6 @@ function generateReport() {
|
||||
});
|
||||
}
|
||||
|
||||
function displayStatistics(stats) {
|
||||
const statGrid = document.getElementById('stat-grid');
|
||||
statGrid.innerHTML = '';
|
||||
|
||||
const statistics = [
|
||||
{label: '本周消息量', value: stats.week_message_count, unit: '条'},
|
||||
{label: '上周消息量', value: stats.last_week_message_count, unit: '条'},
|
||||
{label: '消息变化率', value: stats.message_change_rate?.toFixed(1) || '0.0', unit: '%'},
|
||||
{label: '本周活跃用户', value: stats.week_active_users, unit: '人'},
|
||||
{label: '群组数量', value: stats.group_count, unit: '个'},
|
||||
{label: '成员总数', value: stats.member_count, unit: '人'},
|
||||
{label: '问答记录数', value: stats.qa_count, unit: '条'},
|
||||
{label: '热点话题数', value: stats.hot_topics_count || 0, unit: '个'},
|
||||
{label: '客户问题分类', value: Object.keys(stats.category_breakdown || {}).length, unit: '类'}
|
||||
];
|
||||
|
||||
statistics.forEach(stat => {
|
||||
const statItem = document.createElement('div');
|
||||
statItem.className = 'stat-item';
|
||||
statItem.innerHTML = `
|
||||
<div class="stat-value">${stat.value}${stat.unit}</div>
|
||||
<div class="stat-label">${stat.label}</div>
|
||||
`;
|
||||
statGrid.appendChild(statItem);
|
||||
});
|
||||
}
|
||||
|
||||
function displayCategoryChart(categories) {
|
||||
const categoryItems = document.getElementById('category-items');
|
||||
categoryItems.innerHTML = '';
|
||||
@@ -215,6 +191,71 @@ function exportReport() {
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出报告为图片
|
||||
*/
|
||||
async function exportReportAsImage() {
|
||||
const exportBtn = document.getElementById('image-export-btn');
|
||||
const reportContent = document.getElementById('report-content');
|
||||
|
||||
if (!reportContent || reportContent.innerHTML.trim() === '') {
|
||||
alert('请先生成周报内容');
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof convertAndDownload === 'undefined') {
|
||||
alert('图片导出功能未加载,请刷新页面重试');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 显示加载中状态
|
||||
const originalText = exportBtn.textContent;
|
||||
exportBtn.disabled = true;
|
||||
exportBtn.textContent = '导出中...';
|
||||
|
||||
// 获取当前周数 - 修复选择器
|
||||
const week = document.getElementById('week').value || '当前';
|
||||
const filename = `运营周报_v3_${week}.png`;
|
||||
|
||||
console.log('开始导出图片...');
|
||||
console.log('目标元素:', reportContent);
|
||||
console.log('文件名:', filename);
|
||||
|
||||
await convertAndDownload(reportContent, filename, {
|
||||
scale: 2,
|
||||
backgroundColor: '#ffffff',
|
||||
useCORS: true,
|
||||
allowTaint: false
|
||||
});
|
||||
|
||||
console.log('图片导出成功');
|
||||
alert('图片导出成功!');
|
||||
|
||||
} catch (error) {
|
||||
console.error('图片导出失败:', error);
|
||||
alert(`图片导出失败: ${error.message || error}`);
|
||||
} finally {
|
||||
// 恢复按钮状态
|
||||
exportBtn.disabled = false;
|
||||
exportBtn.textContent = '导出图片';
|
||||
}
|
||||
}
|
||||
|
||||
// 启用/禁用图片导出按钮
|
||||
function updateImageExportButtonState() {
|
||||
const reportContent = document.getElementById('report-content');
|
||||
const imageExportBtn = document.getElementById('image-export-btn');
|
||||
|
||||
if (reportContent && reportContent.innerHTML.trim()) {
|
||||
imageExportBtn.disabled = false;
|
||||
imageExportBtn.classList.remove('disabled');
|
||||
} else {
|
||||
imageExportBtn.disabled = true;
|
||||
imageExportBtn.classList.add('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
// 支持回车键生成报告
|
||||
document.getElementById('week').addEventListener('keypress', function (e) {
|
||||
if (e.key === 'Enter') {
|
||||
|
||||
Reference in New Issue
Block a user