Browse Source
fix:修复showAdvancedButton为true时,FormSchema中ifshow是与model有关的函数时候,查询按钮位置不重新计算的问题。 (#4304)
pull/4307/head
lijian3828940
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
27 additions and
4 deletions
-
src/components/Form/src/BasicForm.vue
-
src/components/Form/src/hooks/useAdvanced.ts
|
|
|
@ -124,7 +124,9 @@ |
|
|
|
const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) }) as AntFormProps); |
|
|
|
|
|
|
|
const getSchema = computed((): FormSchema[] => { |
|
|
|
const schemas: FormSchema[] = cloneDeep(unref(schemaRef) || (unref(getProps).schemas as any)); |
|
|
|
const schemas: (FormSchema & { ifshow2?: boolean })[] = cloneDeep( |
|
|
|
unref(schemaRef) || (unref(getProps).schemas as any), |
|
|
|
); |
|
|
|
for (const schema of schemas) { |
|
|
|
const { |
|
|
|
defaultValue, |
|
|
|
@ -134,7 +136,16 @@ |
|
|
|
field, |
|
|
|
isHandleDefaultValue = true, |
|
|
|
valueFormat, |
|
|
|
ifShow, |
|
|
|
} = schema; |
|
|
|
|
|
|
|
//fix:修复showAdvancedButton为true时,FormSchema中ifshow是与model有关的函数时候,查询按钮位置不重新计算的问题。 |
|
|
|
if (unref(getProps).showAdvancedButton) { |
|
|
|
schema.ifshow2 = isFunction(ifShow) |
|
|
|
? ifShow({ schema, values: formModel, model: formModel, field }) |
|
|
|
: ifShow; |
|
|
|
} |
|
|
|
|
|
|
|
// handle date type |
|
|
|
if ( |
|
|
|
isHandleDateDefaultValue && |
|
|
|
|
|
|
|
@ -1,6 +1,15 @@ |
|
|
|
import type { ColEx } from '../types'; |
|
|
|
import type { AdvanceState } from '../types/hooks'; |
|
|
|
import { ComputedRef, getCurrentInstance, Ref, shallowReactive, computed, unref, watch } from 'vue'; |
|
|
|
import { |
|
|
|
ComputedRef, |
|
|
|
getCurrentInstance, |
|
|
|
Ref, |
|
|
|
shallowReactive, |
|
|
|
computed, |
|
|
|
unref, |
|
|
|
watch, |
|
|
|
nextTick, |
|
|
|
} from 'vue'; |
|
|
|
import type { FormProps, FormSchemaInner as FormSchema } from '../types/form'; |
|
|
|
import { isBoolean, isFunction, isNumber, isObject } from '@/utils/is'; |
|
|
|
import { useBreakpoint } from '@/hooks/event/useBreakpoint'; |
|
|
|
@ -49,14 +58,17 @@ export default function ({ |
|
|
|
return 0; |
|
|
|
}); |
|
|
|
|
|
|
|
const debounceUpdateAdvanced = useDebounceFn(updateAdvanced, 30); |
|
|
|
// const debounceUpdateAdvanced = useDebounceFn(updateAdvanced, 30);
|
|
|
|
|
|
|
|
watch( |
|
|
|
[() => unref(getSchema), () => advanceState.isAdvanced, () => unref(realWidthRef)], |
|
|
|
() => { |
|
|
|
const { showAdvancedButton } = unref(getProps); |
|
|
|
if (showAdvancedButton) { |
|
|
|
debounceUpdateAdvanced(); |
|
|
|
// debounceUpdateAdvanced();
|
|
|
|
nextTick(() => { |
|
|
|
updateAdvanced(); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ immediate: true }, |
|
|
|
|