From d1cf2e1b5d3f56d14e5d75024ce2d054f9142b2e Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 06 八月 2026 17:54:54 +0800
Subject: [PATCH] refactor(components): 重构多个组件以提升代码质量和可维护性

---
 src/packages/@core/ui-kit/form-ui/src/form-api.ts |   53 ++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/src/packages/@core/ui-kit/form-ui/src/form-api.ts b/src/packages/@core/ui-kit/form-ui/src/form-api.ts
index 920b1b6..d69205a 100644
--- a/src/packages/@core/ui-kit/form-ui/src/form-api.ts
+++ b/src/packages/@core/ui-kit/form-ui/src/form-api.ts
@@ -166,7 +166,54 @@
     const values = form.values
       ? this.handleRangeTimeValue(cloneDeep(toRaw(form.values)))
       : {};
-    return this.handleValueFormat(values) as T;
+    const result = this.handleValueFormat(values);
+    // 鑷姩鎻愬彇 FileUpload/Upload 瀛楁涓殑鏂囦欢 ID锛岄伩鍏嶆彁浜ゆ椂鎼哄甫瀹屾暣鏂囦欢瀵硅薄
+    const currentSchema = this.state?.schema ?? [];
+    for (const schema of currentSchema) {
+      // 鍏煎瀛楃涓茬被鍨嬪拰宸茶В鏋愮殑 Vue Component 瀵硅薄
+      const compName: string =
+        typeof schema.component === 'string'
+          ? schema.component
+          : (schema.component as any)?.name ?? '';
+      if (compName !== 'FileUpload' && compName !== 'Upload') {
+        continue;
+      }
+      if (schema.valueFormat) continue;
+      const fieldName = schema.fieldName;
+      const rawValue = result[fieldName];
+      if (
+        rawValue == null ||
+        !Array.isArray(rawValue) ||
+        rawValue.length === 0
+      ) {
+        continue;
+      }
+      if (
+        typeof rawValue[0] !== 'object' ||
+        !('status' in rawValue[0])
+      ) {
+        continue;
+      }
+      const props = (schema.componentProps || {}) as Record<string, any>;
+      const valueKey = props.valueKey || 'url';
+      const maxNumber = props.maxNumber ?? 1;
+      const resultField = props.resultField;
+      const valuePrefix = props.valuePrefix || '';
+      const list = rawValue
+        .filter((item: any) => item?.status === 'done')
+        .map((item: any) => {
+          if (resultField && item?.response) return item.response;
+          const v =
+            item?.response?.[valueKey] ??
+            item?.[valueKey] ??
+            item?.url ??
+            item?.response?.url ??
+            item?.response;
+          return valuePrefix ? `${valuePrefix}${v}` : v;
+        });
+      result[fieldName] = maxNumber === 1 ? (list[0] ?? '') : list;
+    }
+    return result as T;
   }
 
   async isFieldValid(fieldName: string) {
@@ -301,7 +348,7 @@
 
   /**
    * 璁剧疆琛ㄥ崟绂佺敤鐘舵�侊細鐢ㄤ簬闈� Modal 涓娇鐢� Form 鏃讹紝闇�瑕� Form 鑷繁鎺у埗绂佺敤鐘舵��
-   * @author 鑺嬮亾婧愮爜
+   * @author 瓒呯骇绠$悊鍛�
    * @param disabled 鏄惁绂佺敤
    */
   setDisabled(disabled: boolean) {
@@ -322,7 +369,7 @@
 
   /**
    * 璁剧疆琛ㄥ崟鎻愪氦鎸夐挳鐨勫姞杞界姸鎬侊細鐢ㄤ簬闈� Modal 涓娇鐢� Form 鏃讹紝闇�瑕� Form 鑷繁鎺у埗 loading 鐘舵��
-   * @author 鑺嬮亾婧愮爜
+   * @author 瓒呯骇绠$悊鍛�
    * @param loading 鏄惁鍔犺浇涓�
    */
   setLoading(loading: boolean) {

--
Gitblit v1.9.3