/* 机构动向 */ let curType = ''; async function loadInsts() { try { const d = await api('/api/institutions?type=' + curType); const items = d.items || []; $('#tb').innerHTML = items.map(it => ` ${escapeHtml(it.name)} ${escapeHtml(it.type)} ${escapeHtml(it.description)} … … `).join(''); items.forEach(it => fillCounts(it.id, it.name)); } catch (e) { $('#tb').innerHTML = '加载失败'; } } async function fillCounts(id, name) { try { const d = await api('/api/ratings/upgrades'); const rc = d.items.filter(x => x.inst_name === name).length; $('#rc-' + id).textContent = rc; } catch (e) {} } async function showInst(id) { try { const d = await api('/api/institutions/' + id); const inst = d.institution; const ratings = (d.ratings || []).map(r => ` ${r.name}(${r.stock_code}) ${r.rating} ${r.target_price}${r.rating_date} `).join(''); const holdings = (d.holdings || []).map(h => ` ${h.name}(${h.stock_code})${h.quarter} ${fmtNum(h.hold_value)} ${fmtPct(h.change_pct)} `).join(''); openModal(`

${escapeHtml(inst.name)} ${escapeHtml(inst.type)}

${escapeHtml(inst.description)}

近期评级

${ratings || ''}
暂无

基金持仓

${holdings || ''}
暂无
`); } catch (e) { toast('加载失败'); } } async function loadMoves() { try { const d = await api('/api/holdings/moves'); const q = d.quarter || ''; const inc = (d.increase || []).map(h => ` ${h.name}${escapeHtml(h.inst_name)} ${fmtPct(h.change_pct)} `).join(''); const dec = (d.decrease || []).map(h => ` ${h.name}${escapeHtml(h.inst_name)} ${fmtPct(h.change_pct)} `).join(''); $('#holdBox').innerHTML = `
最新季度:${q}
${inc || ''} ${dec || ''}
增持榜机构环比
暂无
减持榜机构环比
暂无
`; } catch (e) {} } async function loadUpgrades() { try { const d = await api('/api/ratings/upgrades'); $('#upgradeBox').innerHTML = ` ${(d.items || []).slice(0, 14).map(r => ` `).join('')}
股票机构评级日期
`; } catch (e) {} } $$('#typePills .pill').forEach(p => { p.onclick = () => { $$('#typePills .pill').forEach(x => x.classList.remove('active')); p.classList.add('active'); curType = p.dataset.t; loadInsts(); }; }); loadMoves(); loadUpgrades(); loadInsts();