Commit 3ef5087be64ed98d84429a1a111182f761e0ffa9
1 parent
2d3d04f5
style: formatting code
Showing
7 changed files
with
64 additions
and
81 deletions
src/components/Table/src/components/editable/EditableCell.vue
... | ... | @@ -131,16 +131,14 @@ |
131 | 131 | return option?.label ?? value; |
132 | 132 | }); |
133 | 133 | |
134 | - const getWrapperStyle = computed( | |
135 | - (): CSSProperties => { | |
136 | - if (unref(getIsCheckComp) || unref(getRowEditable)) { | |
137 | - return {}; | |
138 | - } | |
139 | - return { | |
140 | - width: 'calc(100% - 48px)', | |
141 | - }; | |
134 | + const getWrapperStyle = computed((): CSSProperties => { | |
135 | + if (unref(getIsCheckComp) || unref(getRowEditable)) { | |
136 | + return {}; | |
142 | 137 | } |
143 | - ); | |
138 | + return { | |
139 | + width: 'calc(100% - 48px)', | |
140 | + }; | |
141 | + }); | |
144 | 142 | |
145 | 143 | const getRowEditable = computed(() => { |
146 | 144 | const { editable } = props.record || {}; | ... | ... |
src/components/Table/src/components/settings/index.vue
... | ... | @@ -36,17 +36,15 @@ |
36 | 36 | setup(props) { |
37 | 37 | const { t } = useI18n(); |
38 | 38 | |
39 | - const getSetting = computed( | |
40 | - (): TableSetting => { | |
41 | - return { | |
42 | - redo: true, | |
43 | - size: true, | |
44 | - setting: true, | |
45 | - fullScreen: false, | |
46 | - ...props.setting, | |
47 | - }; | |
48 | - } | |
49 | - ); | |
39 | + const getSetting = computed((): TableSetting => { | |
40 | + return { | |
41 | + redo: true, | |
42 | + size: true, | |
43 | + setting: true, | |
44 | + fullScreen: false, | |
45 | + ...props.setting, | |
46 | + }; | |
47 | + }); | |
50 | 48 | |
51 | 49 | return { getSetting, t }; |
52 | 50 | }, | ... | ... |
src/components/Table/src/hooks/useColumns.ts
... | ... | @@ -109,7 +109,7 @@ export function useColumns( |
109 | 109 | propsRef: ComputedRef<BasicTableProps>, |
110 | 110 | getPaginationRef: ComputedRef<boolean | PaginationProps> |
111 | 111 | ) { |
112 | - const columnsRef = (ref(unref(propsRef).columns) as unknown) as Ref<BasicColumn[]>; | |
112 | + const columnsRef = ref(unref(propsRef).columns) as unknown as Ref<BasicColumn[]>; | |
113 | 113 | let cacheColumns = unref(propsRef).columns; |
114 | 114 | |
115 | 115 | const getColumnsRef = computed(() => { | ... | ... |
src/components/Table/src/hooks/useDataSource.ts
... | ... | @@ -150,15 +150,8 @@ export function useDataSource( |
150 | 150 | } |
151 | 151 | |
152 | 152 | async function fetch(opt?: FetchParams) { |
153 | - const { | |
154 | - api, | |
155 | - searchInfo, | |
156 | - fetchSetting, | |
157 | - beforeFetch, | |
158 | - afterFetch, | |
159 | - useSearchForm, | |
160 | - pagination, | |
161 | - } = unref(propsRef); | |
153 | + const { api, searchInfo, fetchSetting, beforeFetch, afterFetch, useSearchForm, pagination } = | |
154 | + unref(propsRef); | |
162 | 155 | if (!api || !isFunction(api)) return; |
163 | 156 | try { |
164 | 157 | setLoading(true); | ... | ... |
src/components/Table/src/hooks/useTable.ts
... | ... | @@ -15,9 +15,7 @@ type UseTableMethod = TableActionType & { |
15 | 15 | getForm: () => FormActionType; |
16 | 16 | }; |
17 | 17 | |
18 | -export function useTable( | |
19 | - tableProps?: Props | |
20 | -): [ | |
18 | +export function useTable(tableProps?: Props): [ | |
21 | 19 | (instance: TableActionType, formInstance: UseTableMethod) => void, |
22 | 20 | TableActionType & { |
23 | 21 | getForm: () => FormActionType; |
... | ... | @@ -129,7 +127,7 @@ export function useTable( |
129 | 127 | return toRaw(getTableInstance().getCacheColumns()); |
130 | 128 | }, |
131 | 129 | getForm: () => { |
132 | - return (unref(formRef) as unknown) as FormActionType; | |
130 | + return unref(formRef) as unknown as FormActionType; | |
133 | 131 | }, |
134 | 132 | setShowPagination: async (show: boolean) => { |
135 | 133 | getTableInstance().setShowPagination(show); | ... | ... |
src/components/Table/src/hooks/useTableForm.ts
... | ... | @@ -9,18 +9,16 @@ export function useTableForm( |
9 | 9 | fetch: (opt?: FetchParams | undefined) => Promise<void>, |
10 | 10 | getLoading: ComputedRef<boolean | undefined> |
11 | 11 | ) { |
12 | - const getFormProps = computed( | |
13 | - (): Partial<FormProps> => { | |
14 | - const { formConfig } = unref(propsRef); | |
15 | - const { submitButtonOptions } = formConfig || {}; | |
16 | - return { | |
17 | - showAdvancedButton: true, | |
18 | - ...formConfig, | |
19 | - submitButtonOptions: { loading: unref(getLoading), ...submitButtonOptions }, | |
20 | - compact: true, | |
21 | - }; | |
22 | - } | |
23 | - ); | |
12 | + const getFormProps = computed((): Partial<FormProps> => { | |
13 | + const { formConfig } = unref(propsRef); | |
14 | + const { submitButtonOptions } = formConfig || {}; | |
15 | + return { | |
16 | + showAdvancedButton: true, | |
17 | + ...formConfig, | |
18 | + submitButtonOptions: { loading: unref(getLoading), ...submitButtonOptions }, | |
19 | + compact: true, | |
20 | + }; | |
21 | + }); | |
24 | 22 | |
25 | 23 | const getFormSlotKeys = computed(() => { |
26 | 24 | const keys = Object.keys(slots); | ... | ... |
src/components/Table/src/hooks/useTableHeader.ts
... | ... | @@ -8,41 +8,39 @@ import { isString } from '/@/utils/is'; |
8 | 8 | import { getSlot } from '/@/utils/helper/tsxHelper'; |
9 | 9 | |
10 | 10 | export function useTableHeader(propsRef: ComputedRef<BasicTableProps>, slots: Slots) { |
11 | - const getHeaderProps = computed( | |
12 | - (): Recordable => { | |
13 | - const { title, showTableSetting, titleHelpMessage, tableSetting } = unref(propsRef); | |
14 | - const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; | |
15 | - if (hideTitle && !isString(title)) { | |
16 | - return {}; | |
17 | - } | |
18 | - | |
19 | - return { | |
20 | - title: hideTitle | |
21 | - ? null | |
22 | - : () => | |
23 | - h( | |
24 | - TableHeader, | |
25 | - { | |
26 | - title, | |
27 | - titleHelpMessage, | |
28 | - showTableSetting, | |
29 | - tableSetting, | |
30 | - } as Recordable, | |
31 | - { | |
32 | - ...(slots.toolbar | |
33 | - ? { | |
34 | - toolbar: () => getSlot(slots, 'toolbar'), | |
35 | - } | |
36 | - : {}), | |
37 | - ...(slots.tableTitle | |
38 | - ? { | |
39 | - tableTitle: () => getSlot(slots, 'tableTitle'), | |
40 | - } | |
41 | - : {}), | |
42 | - } | |
43 | - ), | |
44 | - }; | |
11 | + const getHeaderProps = computed((): Recordable => { | |
12 | + const { title, showTableSetting, titleHelpMessage, tableSetting } = unref(propsRef); | |
13 | + const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; | |
14 | + if (hideTitle && !isString(title)) { | |
15 | + return {}; | |
45 | 16 | } |
46 | - ); | |
17 | + | |
18 | + return { | |
19 | + title: hideTitle | |
20 | + ? null | |
21 | + : () => | |
22 | + h( | |
23 | + TableHeader, | |
24 | + { | |
25 | + title, | |
26 | + titleHelpMessage, | |
27 | + showTableSetting, | |
28 | + tableSetting, | |
29 | + } as Recordable, | |
30 | + { | |
31 | + ...(slots.toolbar | |
32 | + ? { | |
33 | + toolbar: () => getSlot(slots, 'toolbar'), | |
34 | + } | |
35 | + : {}), | |
36 | + ...(slots.tableTitle | |
37 | + ? { | |
38 | + tableTitle: () => getSlot(slots, 'tableTitle'), | |
39 | + } | |
40 | + : {}), | |
41 | + } | |
42 | + ), | |
43 | + }; | |
44 | + }); | |
47 | 45 | return { getHeaderProps }; |
48 | 46 | } | ... | ... |