10 小时以前 487008281c7ba87712a1647d09899383e12fa759
src/packages/@core/ui-kit/form-ui/src/form-api.ts
@@ -7,13 +7,13 @@
import type { ComponentPublicInstance } from 'vue';
import type { Recordable } from '..\..\..\base\typings\src';
import type { Recordable } from '../../../base/typings/src';
import type { FormActions, FormSchema, VbenFormProps } from './types';
import { isRef, toRaw } from 'vue';
import { Store } from '..\..\..\base\shared\src\store';
import { Store } from '../../../base/shared/src/store';
import {
  bindMethods,
  cloneDeep,
@@ -27,7 +27,7 @@
  mergeWithArrayOverride,
  set,
  StateHandler,
} from '..\..\..\base\shared\src\utils';
} from '../../../base/shared/src/utils';
import { resolveFieldNamePath } from './field-name';
@@ -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) {