// 碳排放报告生成 + 完整 PDF 风格预览 const { useState, useMemo } = React; const DR = window.__CARBON_DATA; function ReportPage() { const { orgId, org, path } = useOrg(); const toast = useToast(); const [showPreview, setShowPreview] = useState(true); const [config, setConfig] = useState({ reportPeriod: '2024', title: '', // empty → auto standard: 'ISO', includeChart: true, includeBenchmark: true, includeAppendix: true, showLogo: true, statement: '本报告依据 ISO 14064-1:2018《组织层面温室气体排放和清除的量化和报告规范》及国家相关行业核算指南编制,已通过内部三级审核。', reportTo: '集团 ESG 委员会', scope: 'self' // self | consolidated }); // Determine target orgs const targetOrgs = config.scope === 'consolidated' ? [org].concat(DR.getDescendants(orgId).filter(id => id !== orgId).map(id => DR.ORG_FLAT.find(o => o.id === id))) : [org]; // Period range const yearPeriods = DR.PERIODS.filter(p => p.startsWith(config.reportPeriod)); const filter = yearPeriods.length ? { start: yearPeriods[0], end: yearPeriods[yearPeriods.length - 1] } : null; const agg = useMemo(() => DR.aggregate(orgId, filter), [orgId, config.reportPeriod]); // recent reports const [history, setHistory] = useState([ { id: 'R-2025-004', title: '中绿能源控股集团 2024 年度温室气体排放报告', org: '中绿能源控股集团', period: '2024', scope: 'consolidated', status: 'final', updateDate: '2025-03-21 16:42', size: '4.2 MB' }, { id: 'R-2025-003', title: '中绿电力板块 2024 Q4 温室气体排放报告', org: '中绿电力板块', period: '2024Q4', scope: 'consolidated', status: 'final', updateDate: '2025-01-18 11:08', size: '2.8 MB' }, { id: 'R-2024-018', title: '河北唐山燃煤电厂 2024 年度核查报告', org: '河北唐山燃煤电厂', period: '2024', scope: 'self', status: 'final', updateDate: '2024-12-30 09:21', size: '1.6 MB' }, { id: 'R-2024-017', title: '中绿钢铁板块 2024 年度温室气体排放报告', org: '中绿钢铁板块', period: '2024', scope: 'consolidated', status: 'draft', updateDate: '2024-12-15 14:33', size: '3.1 MB' } ]); const generate = () => { toast.push('报告已生成 · 进入预览'); const newReport = { id: 'R-' + new Date().getFullYear() + '-' + String(history.length + 5).padStart(3, '0'), title: config.title || `${org.name} ${config.reportPeriod} 年度温室气体排放报告`, org: org.name, period: config.reportPeriod, scope: config.scope, status: 'draft', updateDate: new Date().toISOString().slice(0, 19).replace('T', ' '), size: '2.3 MB' }; setHistory(prev => [newReport, ...prev]); setShowPreview(true); }; return ( <> } />
{/* Config panel */}
p.name).join(' / ')} disabled style={{ width: '100%' }} /> setConfig({ ...config, standard: v })} options={[ { value: 'ISO', label: 'ISO 14064-1:2018' }, { value: 'INDUSTRY', label: '国家行业核算指南' }, { value: 'BOTH', label: 'ISO 14064-1 + 行业指南' } ]} style={{ width: '100%', minWidth: 'auto' }} /> setConfig({ ...config, title: v })} placeholder={`${org.name} ${config.reportPeriod} 年度温室气体排放报告`} style={{ width: '100%' }} /> setConfig({ ...config, reportTo: v })} style={{ width: '100%' }} />