feat(frontend): 管理端页面 — 任务全景树/创建产品/标签打印/认证守卫

App.tsx:
- AntApp + AuthProvider + ToastProvider 三层包裹
- /admin/login 独立登录页
- /admin/* 路由认证守卫

AdminLayout:
- 未登录→跳转登录; 顶部栏显示用户名+登出
- 侧边栏: 全局概览/产品管理/任务全景

CreateProductDialog (Ant Design 重写):
- MOM物料手风琴选择器 (Collapse+Table)
- 分组懒加载 + useRef缓存 + 防抖搜索
- HEX ID只读展示 + 序列号/订单号选填

AdminProductsPage:
- 打印预览弹窗 (Base64标签预览 + 份数选择)
- 打印机设置入口 → AdminPrintConfigPage

扫码组件对齐:
- ProductCard: material_name/spec_model/current_location
- TaskListCard: 递归 task_tree + 状态配色 + 返工/裂变标签
- QueryResult: task_tree 优先
- ScanPage: 宏观状态栏
This commit is contained in:
2026-08-05 14:01:36 +08:00
parent d04085fc38
commit 59c182a743
9 changed files with 919 additions and 220 deletions

View File

@ -1,20 +1,23 @@
/** 产品信息卡片 */
import { Package } from "lucide-react";
import type { ProductScanResponse } from "../../types/api";
import { TASK_STATUS } from "../../types/api";
const STATUS_LABELS: Record<string, string> = {
pending: "待处理",
in_progress: "进行中",
completed: "已完成",
cancelled: "已取消",
[TASK_STATUS.PENDING]: "待接收",
[TASK_STATUS.WIP]: "进行中",
[TASK_STATUS.COMPLETED]: "已完成",
[TASK_STATUS.REJECTED]: "已驳回",
[TASK_STATUS.ARCHIVED]: "已入库",
};
function statusColor(status: string): string {
switch (status) {
case "pending": return "bg-yellow-100 text-yellow-700";
case "in_progress": return "bg-blue-100 text-blue-700";
case "completed": return "bg-green-100 text-green-700";
default: return "bg-gray-100 text-gray-600";
case TASK_STATUS.PENDING: return "bg-yellow-100 text-yellow-700";
case TASK_STATUS.WIP: return "bg-blue-100 text-blue-700";
case TASK_STATUS.COMPLETED: return "bg-green-100 text-green-700";
case TASK_STATUS.REJECTED: return "bg-red-100 text-red-700";
default: return "bg-gray-100 text-gray-600";
}
}
@ -38,13 +41,23 @@ export default function ProductCard({ product }: ProductCardProps) {
<p className="font-mono font-medium text-gray-800">{product.serial_number}</p>
</div>
<div>
<span className="text-gray-400"></span>
<p className="font-medium text-gray-800">{product.order_no}</p>
<span className="text-gray-400"></span>
<p className="font-medium text-gray-800">{product.material_name || product.material_id || "—"}</p>
</div>
{product.material_id && (
<div>
<span className="text-gray-400"></span>
<p className="font-medium text-gray-800">{product.spec_model || "—"}</p>
</div>
<div>
<span className="text-gray-400"></span>
<p className="font-medium text-gray-800">{product.order_no || "—"}</p>
</div>
{product.current_location_id && (
<div>
<span className="text-gray-400"> ID</span>
<p className="font-medium text-gray-800">{product.material_id}</p>
<span className="text-gray-400"></span>
<p className={`font-medium ${product.current_location_id === "virtual_warehouse" ? "text-purple-600" : "text-gray-800"}`}>
{product.current_location_id === "virtual_warehouse" ? "🏭 仓库" : product.current_location_id}
</p>
</div>
)}
</div>