window.DashboardPage = (function() { 'use strict'; async function render() { try { const res = await API.get('/companies?page=1&page_size=5'); const data = res.data || {}; const items = data.items || []; const total = data.total || 0; const tiers = {}, statuses = {}; items.forEach(c => { tiers[c.customer_tier] = (tiers[c.customer_tier] || 0) + 1; statuses[c.customer_status] = (statuses[c.customer_status] || 0) + 1; }); let html = '
'; html += `
${total}
客户总数
`; html += `
${items.length}
近期客户
`; html += `
${tiers.strategic || 0}
战略客户
`; html += `
${tiers.key || 0}
重点客户
`; html += `
${statuses.active || 0}
活跃客户
`; html += `
${statuses.champion || 0}
标杆客户
`; html += '
'; html += '

最近更新的客户

'; if (items.length === 0) { html += UI.emptyState('暂无客户数据,请先创建客户'); } else { html += ''; items.forEach(c => { html += ``; }); html += '
客户名称行业级别状态地区更新时间
${esc(c.company_name)} ${esc(c.industry)} ${UI.tierBadge(c.customer_tier)} ${UI.statusBadge(c.customer_status)} ${esc(c.province)} ${esc(c.city)} ${UI.formatDate(c.update_time)}
'; } return html; } catch (e) { Logger.error('Dashboard渲染失败: ' + e.message); return '
仪表盘加载失败
'; } } function esc(s) { return (s || '').replace(/&/g,'&').replace(//g,'>').replace(/"/g,'"'); } return { render }; })();