修复: 08-07-business-routing-regression-repair 关闭资产创建跳转回归
这个提交包含在:
@@ -27,7 +27,10 @@ import { fetchCostCenters, fetchDocumentCategories, fetchLegalEntities } from ".
|
||||
import { useAuth } from "../auth/AuthContext";
|
||||
import { hasAnyPermission, hasPermission } from "../auth/permissions";
|
||||
import { DateTextInput } from "../components/common/DateTextInput";
|
||||
import { useUnsavedChangesGuard } from "../components/common/UnsavedChangesGuard";
|
||||
import {
|
||||
usePostSaveNavigation,
|
||||
useUnsavedChangesGuard,
|
||||
} from "../components/common/UnsavedChangesGuard";
|
||||
import { StatusBadge } from "../components/common/StatusBadge";
|
||||
import { TableSkeleton } from "../components/common/TableSkeleton";
|
||||
import {
|
||||
@@ -405,6 +408,7 @@ function AssetRegistryWorkspace({
|
||||
Boolean(isCreatingAsset || selectedAssetId) && Boolean(canEditCurrent) && JSON.stringify(assetForm) !== savedAssetFormSignature,
|
||||
"资产表单",
|
||||
);
|
||||
const runAfterSuccessfulSave = usePostSaveNavigation();
|
||||
const hasAdvancedAssetFilters = Boolean(
|
||||
sensitivityFilter ||
|
||||
categoryFilter ||
|
||||
@@ -575,19 +579,38 @@ function AssetRegistryWorkspace({
|
||||
return patchAsset(selectedAssetId, buildPatchAssetPayload());
|
||||
},
|
||||
onSuccess: async (data) => {
|
||||
if (isCreatingAsset) {
|
||||
const detailPath = buildAssetDetailPath(data.asset.id);
|
||||
if (detailPath === "/assets") {
|
||||
const message = "资产已创建,但未返回可用的资产标识,请返回资产列表确认。";
|
||||
setAssetFormError(message);
|
||||
toast.error(message);
|
||||
return;
|
||||
}
|
||||
|
||||
setAssetFormError("");
|
||||
setSavedAssetFormSignature(JSON.stringify(assetForm));
|
||||
toast.success("资产卡片已创建");
|
||||
runAfterSuccessfulSave(() => {
|
||||
navigate(detailPath, {
|
||||
replace: true,
|
||||
state: { from: backSource },
|
||||
});
|
||||
});
|
||||
void Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["assets", "list"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["assets", "detail"] }),
|
||||
]).catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["assets", "list"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["assets", "detail"] }),
|
||||
]);
|
||||
setAssetFormError("");
|
||||
setSavedAssetFormSignature(JSON.stringify(assetForm));
|
||||
toast.success(isCreatingAsset ? "资产卡片已创建" : "资产卡片已更新");
|
||||
if (isCreatingAsset) {
|
||||
navigate(buildAssetDetailPath(data.asset.id), {
|
||||
replace: true,
|
||||
state: { from: backSource },
|
||||
});
|
||||
}
|
||||
toast.success("资产卡片已更新");
|
||||
},
|
||||
onError: (error) => {
|
||||
const message = resolveError(error);
|
||||
|
||||
在新工单中引用
屏蔽一个用户