| | |
| | | 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) { |