2
0

日志管理+任务管理

This commit is contained in:
lai
2024-12-13 19:14:32 +08:00
parent 57e33781d1
commit e0d991da15
20 changed files with 1472 additions and 39 deletions

View File

@@ -6,10 +6,8 @@ import { useAppStore } from '@/store/modules/app';
import { $t } from '@/locales';
type TableData<T = object> = AntDesign.TableData<T>;
type GetTableData<A extends AntDesign.TableApiFn> = AntDesign.GetTableData<A>;
type TableColumn<T> = AntDesign.TableColumn<T>;
export function useTable<A extends AntDesign.TableApiFn>(config: AntDesign.AntDesignTableConfig<A>) {
export function useTable(config: any) {
const scope = effectScope();
const appStore = useAppStore();
@@ -26,21 +24,21 @@ export function useTable<A extends AntDesign.TableApiFn>(config: AntDesign.AntDe
searchParams,
updateSearchParams,
resetSearchParams
} = useHookTable<A, GetTableData<A>, TableColumn<AntDesign.TableDataWithIndex<GetTableData<A>>>>({
} = useHookTable({
apiFn,
apiParams,
columns: config.columns,
transformer: res => {
transformer: (res:any) => {
const { rows = [], total = 0 } = res.data || {};
return {
rows: rows.map((row, index) => ({ ...row, id: rowKey ? row[rowKey] : index })),
rows: rows.map((row:any, index:any) => ({ ...row, id: rowKey ? row[rowKey] : index })),
total
};
},
getColumnChecks: cols => {
getColumnChecks: (cols:any) => {
const checks: AntDesign.TableColumnCheck[] = [];
cols.forEach(column => {
cols.forEach((column:any) => {
if (column.key) {
checks.push({
key: column.key as string,
@@ -52,22 +50,22 @@ export function useTable<A extends AntDesign.TableApiFn>(config: AntDesign.AntDe
return checks;
},
getColumns: (cols, checks) => {
const columnMap = new Map<string, TableColumn<GetTableData<A>>>();
getColumns: (cols:any, checks:any) => {
const columnMap = new Map<string, any>();
cols.forEach(column => {
cols.forEach((column:any) => {
if (column.key) {
columnMap.set(column.key as string, column);
}
});
const filteredColumns = checks
.filter(item => item.checked)
.map(check => columnMap.get(check.key) as TableColumn<GetTableData<A>>);
.filter((item:any) => item.checked)
.map((check:any) => columnMap.get(check.key) );
return filteredColumns;
},
onFetched: async transformed => {
onFetched: async (transformed:any) => {
const { total } = transformed;
updatePagination({
@@ -150,7 +148,7 @@ export function useTableOperate<T extends TableData<{ [key: string]: any }>>(
) {
const { bool: drawerVisible, setTrue: openDrawer, setFalse: closeDrawer } = useBoolean();
const operateType = ref<AntDesign.TableOperateType>('add');
const operateType = ref<any>('add');
const { getData, idKey = 'id' } = options;
/** the editing row data */
const editingData: Ref<T | null> = ref(null);