import React, { useContext, useEffect, useState } from 'react'; import './index.less'; interface IProps { middleList: any[][]; modelFootList: any; modelTopList: any; styleType: string; control: (e: any) => void; showIcon?: boolean; } const getItem = (len: number) => { const itemLen = len; const itemWidth = Math.floor((1 / itemLen) * 1000) / 10 + '%'; const style = { gridTemplateColumns: `repeat(${itemLen}, ${itemWidth})`, }; return style; }; const IOTAllGrid = ({ middleList, modelFootList, modelTopList, styleType, control, showIcon = false }: IProps) => { useEffect(() => { // console.log(modelFootList, 'modelFootList') }, [modelFootList]); const itemGrid = (item: any, index: number, modelFootList: any) => { return
{ if (item.value === null || item['disabled']) return; control(item); }} key={index} > { showIcon && item.icon && (
) }
3 ? 'text-ellipse' : ''}`}>{item.text}
{ item['disabled'] && (
) }
} return (
{ styleType !== '1' &&
} {modelTopList.length > 0 && (
{modelTopList.map((item: any, index: number) => { return (
{ if (item['disabled']) return; control(item); }} key={index} > { showIcon && item.icon && (
) }
3 ? 'text-ellipse' : ''}`}>{item.text}
{ item['disabled'] && (
) }
); })}
)} {middleList.length > 0 && (
{middleList.map((out: any, ind: number) => { return (
{/* { styleType === '1' &&
} */}
{out.map((item: any, ins: number) => { return (
{ if (item['disabled']) return; control(item); }} key={`middle-items-${ins}`} > { item['disabled'] && (
) } { showIcon && item.icon && (
) }
3 ? 'text-ellipse' : ''}`}>{item.text}
); })}
); })}
)} {modelFootList.length > 0 && ( <> {/* { styleType === '1' &&
} */}
{modelFootList.map((item: any, index: number) => { return ( styleType === '1' ? itemGrid(item, index, modelFootList) : item.text && itemGrid(item, index, modelFootList) ); })}
)} { styleType === '1' &&
}
); }; export default IOTAllGrid;