Преглед изворни кода

fix(order-management-ui): 更新订单资源上传组件使用文件实体fullUrl

- 更新AssetItem接口,添加file字段包含文件实体信息
- 修改资产数据获取逻辑,从asset.file.fullUrl获取文件URL
- 更新文件预览弹窗,使用file.fullUrl显示图片和视频
- 添加安全检查,确保fullUrl存在时才显示预览
- 修复订单模块路由文件中的FileSchema导入警告

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname пре 2 недеља
родитељ
комит
d36fa4120e

+ 31 - 14
allin-packages/order-management-ui/src/components/OrderAssetModal.tsx

@@ -56,7 +56,17 @@ interface AssetItem {
   id: number;
   assetType: AssetType;
   assetFileType: AssetFileType;
-  assetUrl: string;
+  fileId: number;
+  file?: {
+    id: number;
+    name: string;
+    type: string | null;
+    size: number | null;
+    path: string;
+    fullUrl?: string;
+    description: string | null;
+    uploadTime: string;
+  };
   relatedTime: string;
   remark?: string;
 }
@@ -134,13 +144,14 @@ export const OrderAssetModal: React.FC<OrderAssetModalProps> = ({
 
       // 添加资产数据
       assets.forEach((asset: any) => {
-        const { personId, assetType, id, assetFileType, assetUrl } = asset;
+        const { personId, assetType, id, assetFileType, fileId, file } = asset;
         if (groupedData[personId]) {
           groupedData[personId][assetType] = {
             id,
             assetType,
             assetFileType,
-            assetUrl,
+            fileId,
+            file,
             relatedTime: asset.relatedTime,
             remark: asset.remark,
           };
@@ -529,18 +540,24 @@ export const OrderAssetModal: React.FC<OrderAssetModalProps> = ({
               <div className="space-y-2">
                 <Label>文件预览</Label>
                 <div className="border rounded-md p-4 text-center">
-                  {currentAsset.assetItem.assetFileType === AssetFileType.IMAGE ? (
-                    <img
-                      src={currentAsset.assetItem.assetUrl}
-                      alt="资产文件"
-                      className="max-w-full h-auto max-h-[200px] mx-auto"
-                    />
+                  {currentAsset.assetItem.file?.fullUrl ? (
+                    currentAsset.assetItem.assetFileType === AssetFileType.IMAGE ? (
+                      <img
+                        src={currentAsset.assetItem.file.fullUrl}
+                        alt="资产文件"
+                        className="max-w-full h-auto max-h-[200px] mx-auto"
+                      />
+                    ) : (
+                      <video
+                        src={currentAsset.assetItem.file.fullUrl}
+                        controls
+                        className="max-w-full h-auto max-h-[200px] mx-auto"
+                      />
+                    )
                   ) : (
-                    <video
-                      src={currentAsset.assetItem.assetUrl}
-                      controls
-                      className="max-w-full h-auto max-h-[200px] mx-auto"
-                    />
+                    <div className="text-muted-foreground py-8">
+                      无法加载文件预览,文件URL不可用
+                    </div>
                   )}
                 </div>
               </div>

+ 1 - 1
allin-packages/order-module/src/routes/order-custom.routes.ts

@@ -15,7 +15,7 @@ import {
   UpdatePersonWorkStatusSchema
 } from '../schemas/order.schema';
 import { OrderStatus, WorkStatus } from '@d8d/allin-enums';
-import { FileSchema } from '@d8d/file-module';
+// FileSchema导入已不再需要,使用简化的SimpleFileSchema
 
 // 简化的文件schema,用于订单资产查询
 const SimpleFileSchema = z.object({