fix: use form

pull/5/MERGE
xingyu 2023-04-27 12:57:17 +08:00
parent 57a1be1c15
commit f97f541f30
2 changed files with 6 additions and 7 deletions

View File

@ -1,8 +1,7 @@
import type { ColEx } from '../types' import type { ColEx } from '../types'
import type { AdvanceState } from '../types/hooks' import type { AdvanceState } from '../types/hooks'
import { ComputedRef, getCurrentInstance, Ref, shallowReactive } from 'vue' import { ComputedRef, getCurrentInstance, Ref, shallowReactive, computed, unref, watch } from 'vue'
import type { FormProps, FormSchema } from '../types/form' import type { FormProps, FormSchema } from '../types/form'
import { computed, unref, watch } from 'vue'
import { isBoolean, isFunction, isNumber, isObject } from '@/utils/is' import { isBoolean, isFunction, isNumber, isObject } from '@/utils/is'
import { useBreakpoint } from '@/hooks/event/useBreakpoint' import { useBreakpoint } from '@/hooks/event/useBreakpoint'
import { useDebounceFn } from '@vueuse/core' import { useDebounceFn } from '@vueuse/core'

View File

@ -6,7 +6,7 @@ import { isArray, isFunction, isObject, isString, isDef, isNullOrUnDef, isEmpty
import { deepMerge } from '@/utils' import { deepMerge } from '@/utils'
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper' import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper'
import { dateUtil } from '@/utils/dateUtil' import { dateUtil } from '@/utils/dateUtil'
import { cloneDeep, set, uniqBy } from 'lodash-es' import { cloneDeep, set, uniqBy, get } from 'lodash-es'
import { error } from '@/utils/log' import { error } from '@/utils/log'
interface UseFormActionContext { interface UseFormActionContext {
@ -35,7 +35,7 @@ function tryConstructArray(field: string, values: Recordable = {}): any[] | unde
set(result, index, values[k.trim()]) set(result, index, values[k.trim()])
}) })
return result.length ? result : undefined return result.filter(Boolean).length ? result : undefined
} }
} }
} }
@ -104,9 +104,8 @@ export function useFormEvents({
const validKeys: string[] = [] const validKeys: string[] = []
fields.forEach((key) => { fields.forEach((key) => {
const schema = unref(getSchema).find((item) => item.field === key) const schema = unref(getSchema).find((item) => item.field === key)
let value = values[key] let value = get(values, key)
const hasKey = !!get(values, key)
const hasKey = Reflect.has(values, key)
value = handleInputNumberValue(schema?.component, value) value = handleInputNumberValue(schema?.component, value)
const { componentProps } = schema || {} const { componentProps } = schema || {}
@ -157,6 +156,7 @@ export function useFormEvents({
}) })
validateFields(validKeys).catch((_) => {}) validateFields(validKeys).catch((_) => {})
} }
/** /**
* @description: Delete based on field name * @description: Delete based on field name
*/ */