feat(08-05-business-detail-routing): 完成采购与资产独立路由
这个提交包含在:
@@ -4,6 +4,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { searchGlobal, type GlobalSearchHit } from "../api/search";
|
||||
import { isApiError } from "../api/types";
|
||||
import { buildAssetDetailPath, buildPurchaseRequestDetailPath } from "../lib/businessDetailRoutes";
|
||||
import { Button } from "./ui/button";
|
||||
import { Input } from "./ui/input";
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "./ui/dialog";
|
||||
@@ -88,6 +89,16 @@ function resolveBrowseHref(groupKey: SearchGroupKey, items: GlobalSearchHit[]) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function resolveSearchHitHref(item: GlobalSearchHit) {
|
||||
if (item.entityType === "purchase_request") {
|
||||
return buildPurchaseRequestDetailPath(item.entityId);
|
||||
}
|
||||
if (item.entityType === "asset") {
|
||||
return buildAssetDetailPath(item.entityId);
|
||||
}
|
||||
return item.href;
|
||||
}
|
||||
|
||||
export function GlobalSearchDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {
|
||||
const navigate = useNavigate();
|
||||
const [keyword, setKeyword] = useState("");
|
||||
@@ -158,7 +169,7 @@ export function GlobalSearchDialog({ open, onOpenChange }: { open: boolean; onOp
|
||||
key={`${item.entityType}-${item.entityId}`}
|
||||
type="button"
|
||||
className="w-full rounded-lg border border-zinc-200 px-3 py-3 text-left hover:bg-zinc-50"
|
||||
onClick={() => closeAndNavigate(item.href)}
|
||||
onClick={() => closeAndNavigate(resolveSearchHitHref(item))}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="font-medium text-zinc-900">{item.title}</div>
|
||||
|
||||
在新工单中引用
屏蔽一个用户