ERP-node/frontend/types/table-options.ts

94 lines
3.0 KiB
TypeScript
Raw Permalink Normal View History

/**
*
*/
/**
*
*/
export interface TableFilter {
columnName: string;
operator: "equals" | "contains" | "startsWith" | "endsWith" | "gt" | "lt" | "gte" | "lte" | "notEquals";
value: string | number | boolean;
filterType?: "text" | "number" | "date" | "select"; // 필터 입력 타입
width?: number; // 필터 입력 필드 너비 (px)
}
/**
*
*/
export interface GroupSumConfig {
enabled: boolean; // 그룹핑 활성화 여부
groupByColumn: string; // 그룹 기준 컬럼
groupByColumnLabel?: string; // 그룹 기준 컬럼 라벨 (UI 표시용)
}
/**
*
*/
export interface ColumnVisibility {
columnName: string;
visible: boolean;
width?: number;
order?: number;
fixed?: boolean; // 좌측 고정 여부
}
/**
*
*/
export interface TableColumn {
columnName: string;
columnLabel: string;
inputType: string;
visible: boolean;
width: number;
sortable?: boolean;
filterable?: boolean;
}
/**
*
*/
export interface TableRegistration {
tableId: string; // 고유 ID (예: "table-list-123")
label: string; // 사용자에게 보이는 이름 (예: "품목 관리")
tableName: string; // 실제 DB 테이블명 (예: "item_info")
columns: TableColumn[];
dataCount?: number; // 현재 표시된 데이터 건수
// 탭 관련 정보 (탭 내부에 있는 테이블의 경우)
parentTabId?: string; // 부모 탭 ID
parentTabsComponentId?: string; // 부모 탭 컴포넌트 ID
screenId?: number; // 소속 화면 ID
// 콜백 함수들
onFilterChange: (filters: TableFilter[]) => void;
onGroupChange: (groups: string[]) => void;
onColumnVisibilityChange: (columns: ColumnVisibility[]) => void;
onGroupSumChange?: (config: GroupSumConfig | null) => void; // 그룹별 합산 설정 변경
onFrozenColumnCountChange?: (count: number, updatedColumns?: Array<{ columnName: string; visible: boolean }>) => void; // 틀고정 컬럼 수 변경
2025-12-18 10:15:33 +09:00
// 현재 설정 값 (읽기 전용)
frozenColumnCount?: number; // 현재 틀고정 컬럼 수
// 데이터 조회 함수 (선택 타입 필터용)
getColumnUniqueValues?: (columnName: string) => Promise<Array<{ label: string; value: string }>>;
}
/**
* Context
*/
export interface TableOptionsContextValue {
registeredTables: Map<string, TableRegistration>;
registerTable: (registration: TableRegistration) => void;
unregisterTable: (tableId: string) => void;
getTable: (tableId: string) => TableRegistration | undefined;
updateTableDataCount: (tableId: string, count: number) => void; // 데이터 건수 업데이트
selectedTableId: string | null;
setSelectedTableId: (tableId: string | null) => void;
// 활성 탭 기반 필터링
getActiveTabTables: () => TableRegistration[]; // 현재 활성 탭의 테이블만 반환
getTablesForTab: (tabId: string) => TableRegistration[]; // 특정 탭의 테이블만 반환
}