fix: Fix ts type error
parent
91c34175da
commit
285d4ab779
|
@ -77,11 +77,21 @@ const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) })
|
|||
const getSchema = computed((): FormSchema[] => {
|
||||
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any)
|
||||
for (const schema of schemas) {
|
||||
const { defaultValue, component, isHandleDateDefaultValue = true } = schema
|
||||
const {
|
||||
defaultValue,
|
||||
component,
|
||||
componentProps,
|
||||
isHandleDateDefaultValue = true,
|
||||
} = schema
|
||||
|
||||
// eslint-disable-next-line dot-notation
|
||||
const valueFormat = componentProps ? componentProps['valueFormat'] : null
|
||||
// handle date type
|
||||
if (isHandleDateDefaultValue && defaultValue && dateItemType.includes(component)) {
|
||||
if (!Array.isArray(defaultValue)) {
|
||||
schema.defaultValue = dateUtil(defaultValue)
|
||||
schema.defaultValue = valueFormat
|
||||
? dateUtil(defaultValue).format(valueFormat)
|
||||
: dateUtil(defaultValue)
|
||||
}
|
||||
else {
|
||||
const def: any[] = []
|
||||
|
|
|
@ -91,7 +91,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
|||
form.setFieldsValue(values)
|
||||
},
|
||||
|
||||
appendSchemaByField: async (schema: FormSchema | FormSchema[], prefixField: string | undefined, first: boolean) => {
|
||||
appendSchemaByField: async (schema: FormSchema | FormSchema[], prefixField: string | undefined, first?: boolean) => {
|
||||
const form = await getForm()
|
||||
form.appendSchemaByField(schema, prefixField, first)
|
||||
},
|
||||
|
@ -101,7 +101,7 @@ export function useForm(props?: Props): UseFormReturnType {
|
|||
return form.submit()
|
||||
},
|
||||
|
||||
validate: async (nameList?: NamePath[]): Promise<Recordable> => {
|
||||
validate: async (nameList?: NamePath[] | false): Promise<Recordable> => {
|
||||
const form = await getForm()
|
||||
return form.validate(nameList)
|
||||
},
|
||||
|
|
|
@ -35,11 +35,11 @@ export function renderThumbStyle({ move, size, bar }) {
|
|||
return style
|
||||
}
|
||||
|
||||
function extend<T, K>(to: T, _from: K): T & K {
|
||||
function extend<T extends object, K extends object>(to: T, _from: K): T & K {
|
||||
return Object.assign(to as any, _from)
|
||||
}
|
||||
|
||||
export function toObject<T>(arr: Array<T>): Recordable<T> {
|
||||
export function toObject<T extends object>(arr: Array<T>): Recordable<T> {
|
||||
const res = {}
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i])
|
||||
|
|
|
@ -13,8 +13,7 @@ function genBem(name: string, mods?: Mods): string {
|
|||
return ` ${name}--${mods}`
|
||||
|
||||
if (Array.isArray(mods))
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
||||
return mods.reduce((ret, item) => ret + genBem(name, item), '')
|
||||
return (mods as Mod[]).reduce<string>((ret, item) => ret + genBem(name, item), '')
|
||||
|
||||
return Object.keys(mods).reduce((ret, key) => ret + (mods[key] ? genBem(name, key) : ''), '')
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue