diff --git a/frontend/src/app/(founder)/reports/submit/page.tsx b/frontend/src/app/(founder)/reports/submit/page.tsx new file mode 100644 index 0000000..3fc5e15 --- /dev/null +++ b/frontend/src/app/(founder)/reports/submit/page.tsx @@ -0,0 +1,146 @@ +"use client"; + +import { useState } from "react"; +import { FileText, Send, Loader2 } from "lucide-react"; +import { listCompanies, type Company } from "@/lib/companies"; +import { createReport, submitReport } from "@/lib/reports"; +import { useEffect } from "react"; + +/** + * 创始人端 — 提交月报页。 + */ +export default function FounderReportSubmitPage() { + const [companies, setCompanies] = useState([]); + const [companyId, setCompanyId] = useState(""); + const [year, setYear] = useState(new Date().getFullYear()); + const [month, setMonth] = useState(new Date().getMonth() + 1); + const [content, setContent] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const [message, setMessage] = useState(""); + + useEffect(() => { + async function load() { + try { + const resp = await listCompanies({ page: 1, page_size: 100 }); + if (resp.data) { + setCompanies(resp.data.items); + if (resp.data.items.length > 0) setCompanyId(resp.data.items[0].id); + } + } catch { + // ignore + } + } + load(); + }, []); + + async function handleSubmit() { + if (!companyId || !content.trim()) return; + setIsLoading(true); + setMessage(""); + try { + const createResp = await createReport({ + company_id: companyId, + period_year: year, + period_month: month, + raw_content: content, + }); + if (createResp.data) { + const submitResp = await submitReport(createResp.data.id); + if (submitResp.data) { + setMessage("月报已提交成功!等待 AI 解析..."); + setContent(""); + } + } + } catch (err) { + setMessage(err instanceof Error ? err.message : "提交失败"); + } finally { + setIsLoading(false); + } + } + + return ( +
+
+

提交月报

+

填写本月经营情况,提交后 AI 将自动解析

+
+ + {/* 表单 */} +
+ {/* 企业选择 */} +
+ + +
+ + {/* 年月选择 */} +
+
+ + +
+
+ + +
+
+ + {/* 月报内容 */} +
+ +