diff --git a/app/static/js/plan_common.js b/app/static/js/plan_common.js
new file mode 100644
index 0000000..1ff58be
--- /dev/null
+++ b/app/static/js/plan_common.js
@@ -0,0 +1,93 @@
+// 方案相关公共函数(currentPlanId 在各页面自行声明)
+
+// 查看方案详情
+async function viewPlan(planId) {
+ currentPlanId = planId;
+ const response = await fetch(`/api/plans/${planId}`);
+ const data = await response.json();
+
+ let html = `
+
+ 学员:${data.student_name}
+ 练习时间:${data.content.practice_time}
+ 生成时间:${data.created_at}
+
+ 问题诊断
+
+ `;
+
+ data.content.problems.forEach(p => {
+ html += `${p.name}(${p.severity}) `;
+ });
+
+ html += `
`;
+
+ if (data.content.ai_report) {
+ const aiReportHtml = marked.parse(data.content.ai_report);
+ html += `
+ AI个性化练习报告
+ ${aiReportHtml}
+ `;
+ } else if (data.content.ai_report_error) {
+ html += `
+ AI报告
+ AI生成失败: ${data.content.ai_report_error}
+ `;
+ }
+
+ html += `
+ 每日练习计划(共${data.content.total_daily_minutes}分钟)
+
+ | 环节 | 时长 | 内容 | 目的 |
+
+ `;
+
+ data.content.daily_schedule.forEach(item => {
+ html += `| ${item.phase} | ${item.duration} | ${item.content} | ${item.purpose} |
`;
+ });
+
+ html += '
';
+
+ document.getElementById('planDetailContent').innerHTML = html;
+ new bootstrap.Modal(document.getElementById('planDetailModal')).show();
+}
+
+// 下载PDF
+function downloadPDF() {
+ const templateId = document.getElementById('reportTemplateSelect')?.value;
+ const url = templateId ? `/api/plans/${currentPlanId}/pdf?template_id=${templateId}` : `/api/plans/${currentPlanId}/pdf`;
+ window.open(url, '_blank');
+}
+
+// 下载MD
+function downloadMD() {
+ const templateId = document.getElementById('reportTemplateSelect')?.value;
+ const url = templateId ? `/api/plans/${currentPlanId}/md?template_id=${templateId}` : `/api/plans/${currentPlanId}/md`;
+ window.open(url, '_blank');
+}
+
+// 别名(兼容旧代码)
+const downloadPlanPDF = downloadPDF;
+const downloadPlanMD = downloadMD;
+
+// 预览报告模板
+async function previewReportTemplate() {
+ if (!currentPlanId) {
+ alert('请先选择一个方案');
+ return;
+ }
+ const templateId = document.getElementById('reportTemplateSelect')?.value;
+ const url = templateId ? `/api/plans/${currentPlanId}/md?template_id=${templateId}` : `/api/plans/${currentPlanId}/md`;
+ try {
+ const resp = await fetch(url);
+ if (resp.ok) {
+ const md = await resp.text();
+ document.getElementById('reportPreviewContent').innerHTML = marked.parse(md);
+ new bootstrap.Modal(document.getElementById('reportPreviewModal')).show();
+ } else {
+ alert('预览失败');
+ }
+ } catch (e) {
+ alert('预览失败: ' + e.message);
+ }
+}
\ No newline at end of file
diff --git a/app/templates/api_settings.html b/app/templates/api_settings.html
index 31803dd..cb354a2 100644
--- a/app/templates/api_settings.html
+++ b/app/templates/api_settings.html
@@ -2,34 +2,6 @@
{% block title %}API设置 - 钢琴练习方案系统{% endblock %}
-{% block sidebar_nav %}
-
- 学员管理
-
-
- 问题配置
-
-
- API设置
-
-
- 模板管理
-
-
- 班级管理
-
-
- 用户管理
-
-
-
- 修改密码
-
-
- 退出登录
-
-{% endblock %}
-
{% block content %}