Commit 3ef5087be64ed98d84429a1a111182f761e0ffa9

Authored by zuihou
1 parent 2d3d04f5

style: formatting code

src/components/Table/src/components/editable/EditableCell.vue
@@ -131,16 +131,14 @@ @@ -131,16 +131,14 @@
131 return option?.label ?? value; 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 const getRowEditable = computed(() => { 143 const getRowEditable = computed(() => {
146 const { editable } = props.record || {}; 144 const { editable } = props.record || {};
src/components/Table/src/components/settings/index.vue
@@ -36,17 +36,15 @@ @@ -36,17 +36,15 @@
36 setup(props) { 36 setup(props) {
37 const { t } = useI18n(); 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 return { getSetting, t }; 49 return { getSetting, t };
52 }, 50 },
src/components/Table/src/hooks/useColumns.ts
@@ -109,7 +109,7 @@ export function useColumns( @@ -109,7 +109,7 @@ export function useColumns(
109 propsRef: ComputedRef<BasicTableProps>, 109 propsRef: ComputedRef<BasicTableProps>,
110 getPaginationRef: ComputedRef<boolean | PaginationProps> 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 let cacheColumns = unref(propsRef).columns; 113 let cacheColumns = unref(propsRef).columns;
114 114
115 const getColumnsRef = computed(() => { 115 const getColumnsRef = computed(() => {
src/components/Table/src/hooks/useDataSource.ts
@@ -150,15 +150,8 @@ export function useDataSource( @@ -150,15 +150,8 @@ export function useDataSource(
150 } 150 }
151 151
152 async function fetch(opt?: FetchParams) { 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 if (!api || !isFunction(api)) return; 155 if (!api || !isFunction(api)) return;
163 try { 156 try {
164 setLoading(true); 157 setLoading(true);
src/components/Table/src/hooks/useTable.ts
@@ -15,9 +15,7 @@ type UseTableMethod = TableActionType &amp; { @@ -15,9 +15,7 @@ type UseTableMethod = TableActionType &amp; {
15 getForm: () => FormActionType; 15 getForm: () => FormActionType;
16 }; 16 };
17 17
18 -export function useTable(  
19 - tableProps?: Props  
20 -): [ 18 +export function useTable(tableProps?: Props): [
21 (instance: TableActionType, formInstance: UseTableMethod) => void, 19 (instance: TableActionType, formInstance: UseTableMethod) => void,
22 TableActionType & { 20 TableActionType & {
23 getForm: () => FormActionType; 21 getForm: () => FormActionType;
@@ -129,7 +127,7 @@ export function useTable( @@ -129,7 +127,7 @@ export function useTable(
129 return toRaw(getTableInstance().getCacheColumns()); 127 return toRaw(getTableInstance().getCacheColumns());
130 }, 128 },
131 getForm: () => { 129 getForm: () => {
132 - return (unref(formRef) as unknown) as FormActionType; 130 + return unref(formRef) as unknown as FormActionType;
133 }, 131 },
134 setShowPagination: async (show: boolean) => { 132 setShowPagination: async (show: boolean) => {
135 getTableInstance().setShowPagination(show); 133 getTableInstance().setShowPagination(show);
src/components/Table/src/hooks/useTableForm.ts
@@ -9,18 +9,16 @@ export function useTableForm( @@ -9,18 +9,16 @@ export function useTableForm(
9 fetch: (opt?: FetchParams | undefined) => Promise<void>, 9 fetch: (opt?: FetchParams | undefined) => Promise<void>,
10 getLoading: ComputedRef<boolean | undefined> 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 const getFormSlotKeys = computed(() => { 23 const getFormSlotKeys = computed(() => {
26 const keys = Object.keys(slots); 24 const keys = Object.keys(slots);
src/components/Table/src/hooks/useTableHeader.ts
@@ -8,41 +8,39 @@ import { isString } from &#39;/@/utils/is&#39;; @@ -8,41 +8,39 @@ import { isString } from &#39;/@/utils/is&#39;;
8 import { getSlot } from '/@/utils/helper/tsxHelper'; 8 import { getSlot } from '/@/utils/helper/tsxHelper';
9 9
10 export function useTableHeader(propsRef: ComputedRef<BasicTableProps>, slots: Slots) { 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 return { getHeaderProps }; 45 return { getHeaderProps };
48 } 46 }