This commit is contained in:
Li1304553726 2025-03-13 08:24:14 +08:00
parent 24e936d672
commit 0c031ddff3
7 changed files with 100 additions and 1352 deletions

View File

@ -0,0 +1,38 @@
import { useEffect } from "react";
import { useSearchParams } from "react-router-dom";
import { Form } from "antd";
export default function SubmissionSuccess() {
const [searchParams] = useSearchParams();
useEffect(() => {
window.scrollTo(0, 0);
}, []);
return (
<div className="bg-white min-h-screen flex flex-col items-center rounded-xl p-40">
<h1 className="text-3xl font-bold mb-8 text-green-700"></h1>
{/* 投递时间 */}
<Form className="w-full max-w-2xl"> {/* 新增宽度容器 */}
<Form.Item
className="grid grid-cols-[1fr_2fr] items-center pb-2 gap-4 w-full"
>
<span className="text-gray-600">:</span>
<span className="text-min text-left text-gray-600">
{searchParams.get("submitTime")}
</span>
</Form.Item>
</Form>
{/* 回执编号 */}
<div className="bg-blue-100 p-6 rounded-lg mb-8 w-full max-w-2xl"> {/* 已有相同宽度 */}
<div className="text-4xl font-mono text-center text-blue-600 font-bold">
{searchParams.get("ownCode")}
</div>
</div>
<Form className="w-full max-w-2xl space-y-4 mb-8 text-center">
<span className="mt-8 text-gray-500 text-sm">
便
</span>
</Form>
</div>
);
}

View File

@ -35,7 +35,7 @@ interface LetterFormProviderProps {
const LetterEditorContext = createContext<LetterEditorContextType | null>(null); const LetterEditorContext = createContext<LetterEditorContextType | null>(null);
function generateRandomString(length: number = 6): string { function generateRandomString(length: number = 6): string {
const characters = const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
let result = ""; let result = "";
const charactersLength = characters.length; const charactersLength = characters.length;
@ -43,7 +43,6 @@ function generateRandomString(length: number = 6): string {
const randomIndex = Math.floor(Math.random() * charactersLength); const randomIndex = Math.floor(Math.random() * charactersLength);
result += characters.charAt(randomIndex); result += characters.charAt(randomIndex);
} }
return result; return result;
} }
@ -98,28 +97,51 @@ export function LetterFormProvider({
}, },
}); });
const formattedDateTime = dayjs().format("YYYY-MM-DD HH:mm:ss"); const formattedDateTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
// 创建包含信件编号和提交时间的文本 // 创建包含信件编号和提交时间的文本 信件cuid:${result.id}\n(编号区分大小写)
const fileContent = `信件编号: ${ownCode}\n投递时间: ${formattedDateTime}\n 信件cuid:${result.id}\n(编号区分大小写)`; const fileContent = `信件回执编号: ${ownCode}\n投递时间: ${formattedDateTime}\n `;
// 创建包含信件编号和提交时间的Blob对象 // 创建包含信件编号和提交时间的Blob对象
const blob = new Blob([fileContent], { type: "text/plain" }); const blob = new Blob([fileContent], { type: "text/plain" });
// 创建下载链接 // // 创建下载链接
const downloadUrl = window.URL.createObjectURL(blob); // const downloadUrl = window.URL.createObjectURL(blob);
const link = document.createElement("a"); // const link = document.createElement("a");
link.href = downloadUrl; // link.href = downloadUrl;
link.download = `信件编号(区分大小写)-${ownCode}.txt`; // 设置下载文件名 // link.download = `信件回执编号(区分大小写)-${ownCode}.txt`; // 设置下载文件名
document.body.appendChild(link); // document.body.appendChild(link);
link.click(); // link.click();
document.body.removeChild(link); // document.body.removeChild(link);
window.URL.revokeObjectURL(downloadUrl); // window.URL.revokeObjectURL(downloadUrl);
toast.success( toast.success(
`信件投递成功!信件编号已保存到本地,请妥善保管用于进度查询`, `信件投递成功!`,
{ {
duration: 5000, // 10秒 duration: 5000, // 10秒
} }
); );
const searchParams = new URLSearchParams({
navigate("/"); ownCode,
submitTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
});
// navigate(`/submission-success?${searchParams}`, {
// state: {
// ownCode,
// submitTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
// }
// });
if (data.isPublic) {
navigate("/", {
state: {
successMessage: "信件提交成功",
ownCode
}
});
} else {
navigate(`/submission-success?${searchParams}`, {
state: {
ownCode,
submitTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
}
});
}
// window.open(`/submission-success?${searchParams}`, '_blank');
// navigate(`/${result.id}/detail`, { // navigate(`/${result.id}/detail`, {
// replace: true, // replace: true,
// state: { scrollToTop: true }, // state: { scrollToTop: true },

View File

@ -30,14 +30,12 @@ export function LetterBasicForm() {
try { try {
await form.validateFields(); await form.validateFields();
form.submit(); form.submit();
// toast.success("提交成功!"); // toast.success("提交成功!");
} catch (error) { } catch (error) {
// 提取所有错误信息 // 提取所有错误信息
const errorMessages = (error as any).errorFields const errorMessages = (error as any).errorFields
.map((field) => field.errors[0]) .map((field) => field.errors[0])
.filter(Boolean); .filter(Boolean);
// 显示 toast 错误提示 // 显示 toast 错误提示
toast.error( toast.error(
<div className="flex flex-col gap-1"> <div className="flex flex-col gap-1">

View File

@ -13,6 +13,7 @@ import { adminRoute } from "./admin-route";
import InboxPage from "../app/main/letter/inbox/page"; import InboxPage from "../app/main/letter/inbox/page";
import OutboxPage from "../app/main/letter/outbox/page"; import OutboxPage from "../app/main/letter/outbox/page";
import IndexPage from "../app/main/letter/index/page"; import IndexPage from "../app/main/letter/index/page";
import SubmissionSuccess from "../app/SubmissionSuccess";
export const routes: CustomRouteObject[] = [ export const routes: CustomRouteObject[] = [
{ {
path: "/", path: "/",
@ -64,6 +65,10 @@ export const routes: CustomRouteObject[] = [
path: "help", path: "help",
element: <HelpPage></HelpPage>, element: <HelpPage></HelpPage>,
}, },
{
path: "submission-success",
element: <SubmissionSuccess></SubmissionSuccess>,
}
], ],
}, },
adminRoute, adminRoute,
@ -71,9 +76,9 @@ export const routes: CustomRouteObject[] = [
}, },
{ {
path: "/auth", path: "/auth",
element: <AuthPage></AuthPage>, element: <AuthPage></AuthPage>,
}, },
]; ];
export const router = createBrowserRouter(routes); export const router = createBrowserRouter(routes);

View File

@ -101,7 +101,7 @@ server {
# 仅供内部使用 # 仅供内部使用
internal; internal;
# 代理到认证服务 # 代理到认证服务
proxy_pass http://host.docker.internal:3002/auth/file; proxy_pass http://host.docker.internal:/auth/file;
# 请求优化:不传递请求体 # 请求优化:不传递请求体
proxy_pass_request_body off; proxy_pass_request_body off;
proxy_set_header Content-Length ""; proxy_set_header Content-Length "";

View File

@ -199,7 +199,7 @@ export enum PostState {
export const PostStateLabels = { export const PostStateLabels = {
[PostState.PENDING]: "待处理", [PostState.PENDING]: "待处理",
[PostState.PROCESSING]: "处理中", [PostState.PROCESSING]: "处理中",
[PostState.RESOLVED]: "已完成", [PostState.RESOLVED]: "已回复",
}; };
export enum RoleName { export enum RoleName {
Basic = "基层", // 基层 Basic = "基层", // 基层

File diff suppressed because it is too large Load Diff