2023-10-25 10:26:14 +08:00
|
|
|
import type { PaginationProps, TableRowSelection } from '@arco-design/web-vue';
|
2024-03-22 20:01:05 +08:00
|
|
|
import type { TableExpandable } from '@arco-design/web-vue/es/table/interface';
|
2023-09-29 23:45:01 +08:00
|
|
|
import { reactive } from 'vue';
|
2023-11-24 16:48:47 +08:00
|
|
|
import { useAppStore } from '@/store';
|
|
|
|
|
import { isNumber } from '@/utils/is';
|
2023-11-24 19:19:05 +08:00
|
|
|
import { TablePageSizeOptions } from '@/types/const';
|
2023-08-11 16:17:07 +08:00
|
|
|
|
2023-09-29 23:45:01 +08:00
|
|
|
/**
|
|
|
|
|
* 创建列表分页
|
|
|
|
|
*/
|
2024-07-29 10:25:11 +08:00
|
|
|
export const useTablePagination = (ext?: PaginationProps): PaginationProps => {
|
2023-11-24 16:48:47 +08:00
|
|
|
const appStore = useAppStore();
|
2023-09-29 23:45:01 +08:00
|
|
|
return reactive({
|
|
|
|
|
total: 0,
|
|
|
|
|
current: 1,
|
2023-11-24 19:19:05 +08:00
|
|
|
pageSize: isNumber(appStore.defaultTablePageSize) ? appStore.defaultTablePageSize : TablePageSizeOptions[0],
|
2023-09-29 23:45:01 +08:00
|
|
|
showTotal: true,
|
|
|
|
|
showPageSize: true,
|
2024-02-07 16:24:41 +08:00
|
|
|
pageSizeOptions: TablePageSizeOptions,
|
|
|
|
|
...ext
|
2023-09-29 23:45:01 +08:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建行选择器
|
|
|
|
|
*/
|
2024-02-07 16:24:41 +08:00
|
|
|
export const useRowSelection = (ext?: TableRowSelection): TableRowSelection => {
|
2023-10-02 22:56:43 +08:00
|
|
|
return reactive({
|
2024-02-07 16:24:41 +08:00
|
|
|
type: 'checkbox',
|
2023-09-29 23:45:01 +08:00
|
|
|
showCheckedAll: true,
|
|
|
|
|
onlyCurrent: true,
|
2024-02-07 16:24:41 +08:00
|
|
|
...ext
|
2023-10-02 22:56:43 +08:00
|
|
|
});
|
2023-09-29 23:45:01 +08:00
|
|
|
};
|
2024-03-13 19:17:50 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建表格展开
|
|
|
|
|
*/
|
|
|
|
|
export const useExpandable = (ext?: TableExpandable): TableExpandable => {
|
|
|
|
|
return reactive({
|
|
|
|
|
width: 50,
|
|
|
|
|
fixed: true,
|
|
|
|
|
...ext
|
|
|
|
|
});
|
|
|
|
|
};
|