import {tPlc, tPlcType} from "../../Table/plc/utils/plc.utils"; /** * 单个缓存的数据类型 * @author 韦胜健 * @date 2023.1.3 21:16 */ export interface iTableOptionCacheItemData { /*缓存的唯一标识*/ id: number, /*缓存命名*/ title: string, /*缓存时间*/ time: string, /*缓存的数据*/ data: Record, } /** * 总的缓存数据类型 * @author 韦胜健 * @date 2023.1.3 21:17 */ export interface iTableOptionCacheData { /*当前table的唯一标识*/ tableId: string, /*当前应用的缓存id*/ activeId: number | undefined, /*所有的缓存数据*/ data: iTableOptionCacheItemData[], } /** * 单个模块在接收应用缓存时需要实现的功能类型 * @author 韦胜健 * @date 2023.1.3 21:19 */ export interface iTableOptionApplyCacheParam { /*某个模块,在应用缓存时。当前的列信息*/ plcList: tPlc[], /*某个模块在应用时,要应用的数据*/ cacheData: CacheData | undefined /*某个模块在应用时,原始的列信息*/ sourceList: tPlcType[], } /** * 单个模块,在被获取要缓存的数据时的函数参数类型 * @author 韦胜健 * @date 2023.1.3 21:22 */ export interface iTableOptionGetCacheParam { /*某个模块,在返回要缓存的数据时。当前的列信息*/ plcList: tPlc[], /*某个模块,在返回要缓存的数据时。原始的列信息*/ sourceList: tPlcType[], } /** * 单个模块,要在缓存模块中注册时的参数类型 * @author 韦胜健 * @date 2023.1.3 21:23 */ export interface iTableOptionCacheRegistryConfig { cacheKey: string, applyCache: (param: iTableOptionApplyCacheParam) => void, getCache: (param: iTableOptionGetCacheParam) => CacheData, } /** * 计算获取表格的唯一标识 * @author 韦胜健 * @date 2023.1.3 21:23 */ export const getTableId = (plcTypeList: tPlcType[]): string => { return plcTypeList.map(i => { if (i.group) { return `${i.props.title || '#'}-${getTableId(i.children)}`; } else { return `${i.props.title || '#'}-${i.props.field || '@'}`; } }).join('_'); };