/* AI 分析详情页:研报正文 + 数据源 */ const CODE_AID = parseInt(location.pathname.split('/').pop(), 10); async function load() { try { const d = await api('/api/analyses/' + CODE_AID); const a = d.analysis, stock = d.stock || {}; $('#aStock').textContent = a.stock_name || stock.name || '—'; $('#aCode').textContent = a.code; $('#aIndustry').textContent = stock ? (stock.name + ' · ' + (stock.industry || '') + ' · ' + (stock.board || '')) : ''; $('#aTime').textContent = a.created_at; $('#aFocus').textContent = a.focus || '整体投资价值'; $('#reportBox').innerHTML = mdRender(a.report); renderSources(a.sources || {}); } catch (e) { $('#reportBox').innerHTML = '
加载失败:' + escapeHtml(e.message) + '
'; } } function srcBlock(title, icon, inner, count) { return `
${icon} ${title} ${count !== undefined ? `${count}` : ''}
${inner || '
'}
`; } function renderSources(s) { let html = ''; // 1. RAG 相关资讯 const news = s.news || []; html += srcBlock('RAG 相关资讯(向量检索命中)', '📰', news.map(n => `
${escapeHtml(n.title)}
${n.date || '—'} 情感 ${Number(n.sentiment).toFixed(2)} 相似度 ${(1 - (n.distance || 0)).toFixed(3)}
${escapeHtml(n.text)}
`).join(''), news.length); // 2. 公司概况 html += srcBlock('公司概况(RAG 检索)', '🏢', s.profile ? `

${escapeHtml(s.profile)}

` : '', s.profile ? 1 : 0); // 3. 技术指标 html += srcBlock('技术指标', '📈', s.indicators ? `
${escapeHtml(s.indicators)}
` : '', s.indicators ? 1 : 0); // 4. 综合评分 if (s.score) { const sc = s.score; html += srcBlock('综合评分', '🎯', `
总分
${sc.total}
评级
${sc.rating}
趋势
${sc.trend}
动量
${sc.momentum}
技术
${sc.technical}
量能
${sc.volume}
消息
${sc.news}
机构
${sc.institutional}
`, 1); } // 5. 机构评级 const ratings = s.ratings || []; html += srcBlock('机构评级', '🏦', ratings.length ? ` ${ratings.map(r => ``).join('')}
机构评级目标价日期
${escapeHtml(r.inst_name)} ${r.rating} ${r.target_price}${r.rating_date}
` : '', ratings.length); // 6. 基金持仓 const holdings = s.holdings || []; html += srcBlock('基金持仓', '💼', holdings.length ? ` ${holdings.map(h => ``).join('')}
机构季度持仓市值环比
${escapeHtml(h.inst_name)}${h.quarter} ${fmtNum(h.hold_value)} ${fmtPct(h.change_pct)}
` : '', holdings.length); // 7. 完整提示词 html += srcBlock('完整提示词(Prompt)', '🧠', s.prompt ? `
${escapeHtml(s.prompt)}
` : '', s.prompt ? 1 : 0); $('#sourceBox').innerHTML = html; } load();