提交 3ef5087b 编写于 作者: Z zuihou

style: formatting code

上级 2d3d04f5
...@@ -131,16 +131,14 @@ ...@@ -131,16 +131,14 @@
return option?.label ?? value; return option?.label ?? value;
}); });
const getWrapperStyle = computed( const getWrapperStyle = computed((): CSSProperties => {
(): CSSProperties => { if (unref(getIsCheckComp) || unref(getRowEditable)) {
if (unref(getIsCheckComp) || unref(getRowEditable)) { return {};
return {};
}
return {
width: 'calc(100% - 48px)',
};
} }
); return {
width: 'calc(100% - 48px)',
};
});
const getRowEditable = computed(() => { const getRowEditable = computed(() => {
const { editable } = props.record || {}; const { editable } = props.record || {};
......
...@@ -36,17 +36,15 @@ ...@@ -36,17 +36,15 @@
setup(props) { setup(props) {
const { t } = useI18n(); const { t } = useI18n();
const getSetting = computed( const getSetting = computed((): TableSetting => {
(): TableSetting => { return {
return { redo: true,
redo: true, size: true,
size: true, setting: true,
setting: true, fullScreen: false,
fullScreen: false, ...props.setting,
...props.setting, };
}; });
}
);
return { getSetting, t }; return { getSetting, t };
}, },
......
...@@ -109,7 +109,7 @@ export function useColumns( ...@@ -109,7 +109,7 @@ export function useColumns(
propsRef: ComputedRef<BasicTableProps>, propsRef: ComputedRef<BasicTableProps>,
getPaginationRef: ComputedRef<boolean | PaginationProps> getPaginationRef: ComputedRef<boolean | PaginationProps>
) { ) {
const columnsRef = (ref(unref(propsRef).columns) as unknown) as Ref<BasicColumn[]>; const columnsRef = ref(unref(propsRef).columns) as unknown as Ref<BasicColumn[]>;
let cacheColumns = unref(propsRef).columns; let cacheColumns = unref(propsRef).columns;
const getColumnsRef = computed(() => { const getColumnsRef = computed(() => {
......
...@@ -150,15 +150,8 @@ export function useDataSource( ...@@ -150,15 +150,8 @@ export function useDataSource(
} }
async function fetch(opt?: FetchParams) { async function fetch(opt?: FetchParams) {
const { const { api, searchInfo, fetchSetting, beforeFetch, afterFetch, useSearchForm, pagination } =
api, unref(propsRef);
searchInfo,
fetchSetting,
beforeFetch,
afterFetch,
useSearchForm,
pagination,
} = unref(propsRef);
if (!api || !isFunction(api)) return; if (!api || !isFunction(api)) return;
try { try {
setLoading(true); setLoading(true);
......
...@@ -15,9 +15,7 @@ type UseTableMethod = TableActionType & { ...@@ -15,9 +15,7 @@ type UseTableMethod = TableActionType & {
getForm: () => FormActionType; getForm: () => FormActionType;
}; };
export function useTable( export function useTable(tableProps?: Props): [
tableProps?: Props
): [
(instance: TableActionType, formInstance: UseTableMethod) => void, (instance: TableActionType, formInstance: UseTableMethod) => void,
TableActionType & { TableActionType & {
getForm: () => FormActionType; getForm: () => FormActionType;
...@@ -129,7 +127,7 @@ export function useTable( ...@@ -129,7 +127,7 @@ export function useTable(
return toRaw(getTableInstance().getCacheColumns()); return toRaw(getTableInstance().getCacheColumns());
}, },
getForm: () => { getForm: () => {
return (unref(formRef) as unknown) as FormActionType; return unref(formRef) as unknown as FormActionType;
}, },
setShowPagination: async (show: boolean) => { setShowPagination: async (show: boolean) => {
getTableInstance().setShowPagination(show); getTableInstance().setShowPagination(show);
......
...@@ -9,18 +9,16 @@ export function useTableForm( ...@@ -9,18 +9,16 @@ export function useTableForm(
fetch: (opt?: FetchParams | undefined) => Promise<void>, fetch: (opt?: FetchParams | undefined) => Promise<void>,
getLoading: ComputedRef<boolean | undefined> getLoading: ComputedRef<boolean | undefined>
) { ) {
const getFormProps = computed( const getFormProps = computed((): Partial<FormProps> => {
(): Partial<FormProps> => { const { formConfig } = unref(propsRef);
const { formConfig } = unref(propsRef); const { submitButtonOptions } = formConfig || {};
const { submitButtonOptions } = formConfig || {}; return {
return { showAdvancedButton: true,
showAdvancedButton: true, ...formConfig,
...formConfig, submitButtonOptions: { loading: unref(getLoading), ...submitButtonOptions },
submitButtonOptions: { loading: unref(getLoading), ...submitButtonOptions }, compact: true,
compact: true, };
}; });
}
);
const getFormSlotKeys = computed(() => { const getFormSlotKeys = computed(() => {
const keys = Object.keys(slots); const keys = Object.keys(slots);
......
...@@ -8,41 +8,39 @@ import { isString } from '/@/utils/is'; ...@@ -8,41 +8,39 @@ import { isString } from '/@/utils/is';
import { getSlot } from '/@/utils/helper/tsxHelper'; import { getSlot } from '/@/utils/helper/tsxHelper';
export function useTableHeader(propsRef: ComputedRef<BasicTableProps>, slots: Slots) { export function useTableHeader(propsRef: ComputedRef<BasicTableProps>, slots: Slots) {
const getHeaderProps = computed( const getHeaderProps = computed((): Recordable => {
(): Recordable => { const { title, showTableSetting, titleHelpMessage, tableSetting } = unref(propsRef);
const { title, showTableSetting, titleHelpMessage, tableSetting } = unref(propsRef); const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting;
const hideTitle = !slots.tableTitle && !title && !slots.toolbar && !showTableSetting; if (hideTitle && !isString(title)) {
if (hideTitle && !isString(title)) { return {};
return {};
}
return {
title: hideTitle
? null
: () =>
h(
TableHeader,
{
title,
titleHelpMessage,
showTableSetting,
tableSetting,
} as Recordable,
{
...(slots.toolbar
? {
toolbar: () => getSlot(slots, 'toolbar'),
}
: {}),
...(slots.tableTitle
? {
tableTitle: () => getSlot(slots, 'tableTitle'),
}
: {}),
}
),
};
} }
);
return {
title: hideTitle
? null
: () =>
h(
TableHeader,
{
title,
titleHelpMessage,
showTableSetting,
tableSetting,
} as Recordable,
{
...(slots.toolbar
? {
toolbar: () => getSlot(slots, 'toolbar'),
}
: {}),
...(slots.tableTitle
? {
tableTitle: () => getSlot(slots, 'tableTitle'),
}
: {}),
}
),
};
});
return { getHeaderProps }; return { getHeaderProps };
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册