Commit 08df198710ff597af2cbffa2afbb3a6ca13a1d63
1 parent
3b126e01
fix(form): form-item style error
Showing
8 changed files
with
44 additions
and
91 deletions
src/components/Form/src/BasicForm.vue
... | ... | @@ -53,7 +53,6 @@ |
53 | 53 | export default defineComponent({ |
54 | 54 | name: 'BasicForm', |
55 | 55 | components: { FormItem, Form, Row, FormAction }, |
56 | - inheritAttrs: false, | |
57 | 56 | props: basicProps, |
58 | 57 | emits: ['advanced-change', 'reset', 'submit', 'register'], |
59 | 58 | setup(props, { emit }) { |
... | ... | @@ -279,7 +278,7 @@ |
279 | 278 | |
280 | 279 | &--compact { |
281 | 280 | .ant-form-item { |
282 | - margin-bottom: 8px; | |
281 | + margin-bottom: 8px !important; | |
283 | 282 | } |
284 | 283 | } |
285 | 284 | } | ... | ... |
src/components/Form/src/components/FormAction.vue
src/components/Form/src/components/FormItem.tsx
... | ... | @@ -97,7 +97,7 @@ export default defineComponent({ |
97 | 97 | return disabled; |
98 | 98 | }); |
99 | 99 | |
100 | - const getShow = computed(() => { | |
100 | + function getShow() { | |
101 | 101 | const { show, ifShow } = props.schema; |
102 | 102 | const { showAdvancedButton } = props.formProps; |
103 | 103 | const itemIsAdvanced = showAdvancedButton |
... | ... | @@ -122,7 +122,7 @@ export default defineComponent({ |
122 | 122 | } |
123 | 123 | isShow = isShow && itemIsAdvanced; |
124 | 124 | return { isShow, isIfShow }; |
125 | - }); | |
125 | + } | |
126 | 126 | |
127 | 127 | function handleRules(): ValidationRule[] { |
128 | 128 | const { |
... | ... | @@ -310,7 +310,7 @@ export default defineComponent({ |
310 | 310 | const { baseColProps = {} } = props.formProps; |
311 | 311 | |
312 | 312 | const realColProps = { ...baseColProps, ...colProps }; |
313 | - const { isIfShow, isShow } = unref(getShow); | |
313 | + const { isIfShow, isShow } = getShow(); | |
314 | 314 | |
315 | 315 | const getContent = () => { |
316 | 316 | return colSlot | ... | ... |
src/components/Form/src/hooks/useFormEvents.ts
... | ... | @@ -178,11 +178,12 @@ export function useFormEvents({ |
178 | 178 | } |
179 | 179 | |
180 | 180 | async function validateFields(nameList?: NamePath[] | undefined) { |
181 | - return await unref(formElRef)?.validateFields(nameList); | |
181 | + const res = await unref(formElRef)?.validateFields(nameList || []); | |
182 | + return res; | |
182 | 183 | } |
183 | 184 | |
184 | 185 | async function validate(nameList?: NamePath[] | undefined) { |
185 | - return await unref(formElRef)?.validate(nameList); | |
186 | + return await unref(formElRef)?.validate(nameList || []); | |
186 | 187 | } |
187 | 188 | |
188 | 189 | async function clearValidate(name?: string | string[]) { | ... | ... |
src/components/Markdown/src/index.vue
src/components/Table/src/BasicTable.vue
... | ... | @@ -80,14 +80,13 @@ |
80 | 80 | const innerPropsRef = ref<Partial<BasicTableProps>>(); |
81 | 81 | const [registerForm, { getFieldsValue }] = useForm(); |
82 | 82 | |
83 | - const getMergeProps = computed( | |
84 | - (): BasicTableProps => { | |
85 | - return { | |
86 | - ...props, | |
87 | - ...unref(innerPropsRef), | |
88 | - } as BasicTableProps; | |
89 | - } | |
90 | - ); | |
83 | + const getMergeProps = computed(() => { | |
84 | + return { | |
85 | + ...props, | |
86 | + ...unref(innerPropsRef), | |
87 | + } as BasicTableProps; | |
88 | + }); | |
89 | + | |
91 | 90 | const { loadingRef } = useLoading(getMergeProps); |
92 | 91 | const { getPaginationRef, setPagination } = usePagination(getMergeProps); |
93 | 92 | const { getColumnsRef, setColumns } = useColumns(getMergeProps, getPaginationRef); |
... | ... | @@ -123,7 +122,7 @@ |
123 | 122 | getMergeProps |
124 | 123 | ); |
125 | 124 | const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; |
126 | - const titleData: any = | |
125 | + const titleData: Recordable = | |
127 | 126 | hideTitle && !isString(title) |
128 | 127 | ? {} |
129 | 128 | : { |
... | ... | @@ -313,6 +312,7 @@ |
313 | 312 | useExpose<TableActionType>(tableAction); |
314 | 313 | |
315 | 314 | emit('register', tableAction); |
315 | + | |
316 | 316 | return { |
317 | 317 | tableElRef, |
318 | 318 | getBindValues, | ... | ... |
src/components/Table/src/props.ts
... | ... | @@ -10,51 +10,31 @@ import type { |
10 | 10 | } from './types/table'; |
11 | 11 | import type { FormProps } from '/@/components/Form'; |
12 | 12 | import { DEFAULT_SORT_FN, FETCH_SETTING } from './const'; |
13 | +import { propTypes } from '/@/utils/propTypes'; | |
13 | 14 | |
14 | 15 | // 注释看 types/table |
15 | 16 | export const basicProps = { |
16 | 17 | tableSetting: { |
17 | 18 | type: Object as PropType<TableSetting>, |
18 | 19 | }, |
19 | - inset: { | |
20 | - type: Boolean as PropType<boolean>, | |
21 | - default: false, | |
22 | - }, | |
20 | + inset: propTypes.bool, | |
23 | 21 | sortFn: { |
24 | 22 | type: Function as PropType<(sortInfo: SorterResult) => any>, |
25 | 23 | default: DEFAULT_SORT_FN, |
26 | 24 | }, |
27 | 25 | |
28 | - showTableSetting: { | |
29 | - type: Boolean as PropType<boolean>, | |
30 | - default: false, | |
31 | - }, | |
32 | - autoCreateKey: { | |
33 | - type: Boolean as PropType<boolean>, | |
34 | - default: true, | |
35 | - }, | |
36 | - striped: { | |
37 | - type: Boolean as PropType<boolean>, | |
38 | - default: true, | |
39 | - }, | |
40 | - showSummary: { | |
41 | - type: Boolean as PropType<boolean>, | |
42 | - default: false, | |
43 | - }, | |
26 | + showTableSetting: propTypes.bool, | |
27 | + autoCreateKey: propTypes.bool.def(true), | |
28 | + striped: propTypes.bool.def(true), | |
29 | + showSummary: propTypes.bool, | |
44 | 30 | |
45 | 31 | summaryFunc: { |
46 | 32 | type: [Function, Array] as PropType<(...arg: any[]) => any[]>, |
47 | 33 | default: null, |
48 | 34 | }, |
49 | 35 | |
50 | - canColDrag: { | |
51 | - type: Boolean as PropType<boolean>, | |
52 | - default: true, | |
53 | - }, | |
54 | - isTreeTable: { | |
55 | - type: Boolean as PropType<boolean>, | |
56 | - default: false, | |
57 | - }, | |
36 | + canColDrag: propTypes.bool.def(true), | |
37 | + isTreeTable: propTypes.bool, | |
58 | 38 | api: { |
59 | 39 | type: Function as PropType<(...arg: any[]) => Promise<any>>, |
60 | 40 | default: null, |
... | ... | @@ -78,22 +58,16 @@ export const basicProps = { |
78 | 58 | }, |
79 | 59 | }, |
80 | 60 | // 立即请求接口 |
81 | - immediate: { type: Boolean as PropType<boolean>, default: true }, | |
61 | + immediate: propTypes.bool.def(true), | |
82 | 62 | |
83 | - emptyDataIsShowTable: { | |
84 | - type: Boolean as PropType<boolean>, | |
85 | - default: true, | |
86 | - }, | |
63 | + emptyDataIsShowTable: propTypes.bool.def(true), | |
87 | 64 | // 额外的请求参数 |
88 | 65 | searchInfo: { |
89 | 66 | type: Object as PropType<any>, |
90 | 67 | default: null, |
91 | 68 | }, |
92 | 69 | // 使用搜索表单 |
93 | - useSearchForm: { | |
94 | - type: Boolean as PropType<boolean>, | |
95 | - default: false, | |
96 | - }, | |
70 | + useSearchForm: propTypes.bool, | |
97 | 71 | // 表单配置 |
98 | 72 | formConfig: { |
99 | 73 | type: Object as PropType<Partial<FormProps>>, |
... | ... | @@ -103,10 +77,7 @@ export const basicProps = { |
103 | 77 | type: [Array] as PropType<BasicColumn[]>, |
104 | 78 | default: null, |
105 | 79 | }, |
106 | - showIndexColumn: { | |
107 | - type: Boolean as PropType<boolean>, | |
108 | - default: true, | |
109 | - }, | |
80 | + showIndexColumn: propTypes.bool.def(true), | |
110 | 81 | indexColumnProps: { |
111 | 82 | type: Object as PropType<BasicColumn>, |
112 | 83 | default: null, |
... | ... | @@ -115,22 +86,10 @@ export const basicProps = { |
115 | 86 | type: Object as PropType<BasicColumn>, |
116 | 87 | default: null, |
117 | 88 | }, |
118 | - ellipsis: { | |
119 | - type: Boolean as PropType<boolean>, | |
120 | - default: true, | |
121 | - }, | |
122 | - canResize: { | |
123 | - type: Boolean as PropType<boolean>, | |
124 | - default: true, | |
125 | - }, | |
126 | - clearSelectOnPageChange: { | |
127 | - type: Boolean as PropType<boolean>, | |
128 | - default: false, | |
129 | - }, | |
130 | - resizeHeightOffset: { | |
131 | - type: Number as PropType<number>, | |
132 | - default: 0, | |
133 | - }, | |
89 | + ellipsis: propTypes.bool.def(true), | |
90 | + canResize: propTypes.bool.def(true), | |
91 | + clearSelectOnPageChange: propTypes.bool, | |
92 | + resizeHeightOffset: propTypes.number.def(0), | |
134 | 93 | rowSelection: { |
135 | 94 | type: Object as PropType<TableRowSelection | null>, |
136 | 95 | default: null, |
... | ... | @@ -142,30 +101,22 @@ export const basicProps = { |
142 | 101 | titleHelpMessage: { |
143 | 102 | type: [String, Array] as PropType<string | string[]>, |
144 | 103 | }, |
145 | - maxHeight: { | |
146 | - type: Number as PropType<number>, | |
147 | - }, | |
104 | + maxHeight: propTypes.number, | |
148 | 105 | dataSource: { |
149 | - type: Array as PropType<any[]>, | |
106 | + type: Array as PropType<Recordable[]>, | |
150 | 107 | default: null, |
151 | 108 | }, |
152 | 109 | rowKey: { |
153 | - type: [String, Function] as PropType<string | ((record: any) => string)>, | |
110 | + type: [String, Function] as PropType<string | ((record: Recordable) => string)>, | |
154 | 111 | default: '', |
155 | 112 | }, |
156 | - bordered: { | |
157 | - type: Boolean as PropType<boolean>, | |
158 | - default: false, | |
159 | - }, | |
113 | + bordered: propTypes.bool, | |
160 | 114 | pagination: { |
161 | 115 | type: [Object, Boolean] as PropType<PaginationProps | boolean>, |
162 | 116 | default: null, |
163 | 117 | }, |
164 | 118 | |
165 | - loading: { | |
166 | - type: Boolean as PropType<boolean>, | |
167 | - default: false, | |
168 | - }, | |
119 | + loading: propTypes.bool, | |
169 | 120 | rowClassName: { |
170 | 121 | type: Function as PropType<(record: TableCustomRecord<any>, index: number) => string>, |
171 | 122 | }, | ... | ... |
src/components/Table/src/types/tableAction.ts
1 | 1 | import { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'; |
2 | 2 | export interface ActionItem extends ButtonProps { |
3 | - onClick?: any; | |
3 | + onClick?: Fn; | |
4 | 4 | label: string; |
5 | 5 | color?: 'success' | 'error' | 'warning'; |
6 | 6 | icon?: string; |
... | ... | @@ -11,7 +11,7 @@ export interface PopConfirm { |
11 | 11 | title: string; |
12 | 12 | okText?: string; |
13 | 13 | cancelText?: string; |
14 | - confirm: any; | |
15 | - cancel?: any; | |
14 | + confirm: Fn; | |
15 | + cancel?: Fn; | |
16 | 16 | icon?: string; |
17 | 17 | } | ... | ... |