Commit b9d3d60e0f8fe1166a0addcc8295365cbe65a7bf
Committed by
GitHub
1 parent
dc09de1e
perf: Add the style injection of the top row to the form. (#102)
Co-authored-by: NorthLan <lan6995@gmail.com>
Showing
3 changed files
with
13 additions
and
1 deletions
src/components/Form/src/BasicForm.vue
1 | <template> | 1 | <template> |
2 | <Form v-bind="{ ...$attrs, ...$props }" ref="formElRef" :model="formModel"> | 2 | <Form v-bind="{ ...$attrs, ...$props }" ref="formElRef" :model="formModel"> |
3 | - <Row :class="getProps.compact ? 'compact-form-row' : ''"> | 3 | + <Row :class="getProps.compact ? 'compact-form-row' : ''" :style="getRowWrapStyleRef"> |
4 | <slot name="formHeader" /> | 4 | <slot name="formHeader" /> |
5 | <template v-for="schema in getSchema" :key="schema.field"> | 5 | <template v-for="schema in getSchema" :key="schema.field"> |
6 | <FormItem | 6 | <FormItem |
@@ -71,6 +71,11 @@ | @@ -71,6 +71,11 @@ | ||
71 | const schemaRef = ref<Nullable<FormSchema[]>>(null); | 71 | const schemaRef = ref<Nullable<FormSchema[]>>(null); |
72 | const formElRef = ref<Nullable<FormActionType>>(null); | 72 | const formElRef = ref<Nullable<FormActionType>>(null); |
73 | 73 | ||
74 | + const getRowWrapStyleRef = computed((): any => { | ||
75 | + const { baseRowStyle } = unref(getProps); | ||
76 | + return baseRowStyle || {}; | ||
77 | + }); | ||
78 | + | ||
74 | const getMergePropsRef = computed( | 79 | const getMergePropsRef = computed( |
75 | (): FormProps => { | 80 | (): FormProps => { |
76 | return deepMerge(cloneDeep(props), unref(propsRef)); | 81 | return deepMerge(cloneDeep(props), unref(propsRef)); |
@@ -207,6 +212,7 @@ | @@ -207,6 +212,7 @@ | ||
207 | getActionPropsRef, | 212 | getActionPropsRef, |
208 | defaultValueRef, | 213 | defaultValueRef, |
209 | advanceState, | 214 | advanceState, |
215 | + getRowWrapStyleRef, | ||
210 | getProps, | 216 | getProps, |
211 | formElRef, | 217 | formElRef, |
212 | getSchema, | 218 | getSchema, |
src/components/Form/src/props.ts
@@ -28,6 +28,9 @@ export const basicProps = { | @@ -28,6 +28,9 @@ export const basicProps = { | ||
28 | type: Object as PropType<any>, | 28 | type: Object as PropType<any>, |
29 | default: null, | 29 | default: null, |
30 | }, | 30 | }, |
31 | + baseRowStyle: { | ||
32 | + type: Object as PropType<any>, | ||
33 | + }, | ||
31 | baseColProps: { | 34 | baseColProps: { |
32 | type: Object as PropType<any>, | 35 | type: Object as PropType<any>, |
33 | }, | 36 | }, |
src/components/Form/src/types/form.ts
@@ -53,6 +53,9 @@ export interface FormProps { | @@ -53,6 +53,9 @@ export interface FormProps { | ||
53 | // Col configuration for the entire form | 53 | // Col configuration for the entire form |
54 | wrapperCol?: Partial<ColEx>; | 54 | wrapperCol?: Partial<ColEx>; |
55 | 55 | ||
56 | + // General row style | ||
57 | + baseRowStyle?: object; | ||
58 | + | ||
56 | // General col configuration | 59 | // General col configuration |
57 | baseColProps?: Partial<ColEx>; | 60 | baseColProps?: Partial<ColEx>; |
58 | 61 |