import React, { CSSProperties, useEffect, useMemo, useState } from 'react';
import Icon from '../Icon/index';
import LargeScreenComponentCollapseItem from '../LargeScreenComponentCollapseItem/index';
import { Spin } from 'antd';
function LargeScreenComponentCard(props: ILargeScreenComponentCard) {
const {
list = [],
cardStyle,
change,
styles,
cardLoading,
height,
sceneEvent
} = props;
const [listCopy, setListCopy] = useState([]); //卡片的样式数据和卡片数据合并之后的数据
useEffect(() => {
//合并卡片的样式数据和卡片数据
let _list = list?.map((item) => {
return {
...item,
style: cardStyle[item?.styleType]
};
});
setListCopy(_list);
}, [list[0].cardList, list[0].activeIndex]);
const Dom = useMemo(() => {
return (
{cardLoading ? (
) : (
{listCopy?.length > 0 &&
listCopy?.map((item) => {
return (
{item?.title ? (
{item?.titleIcon ? (
{
if (item?.titleClick) {
change(null, null, 'cardTitleClick');
}
}}
/>
) : (
<>>
)}
{
if (item?.titleClick) {
change(null, null, 'cardTitleClick');
}
}}
>
{item.title}
) : (
<>>
)}
{item?.cardList?.length > 0 ? (
) : (
暂无图表
)}
);
})}
)}
);
}, [listCopy, cardStyle, styles, cardLoading]);
return Dom;
}
export default LargeScreenComponentCard;
export interface ILargeScreenComponentCard {
list: IList[];
cardStyle?: ICardStyle[];
change?: Function;
styles?: React.CSSProperties;
cardLoading?: boolean;
height?: number;
sceneEvent?: Function;
}
export interface IList {
key?: string;
title?: string;
styleType?: string;
cardList?: any;
activeIndex?: number | string;
}
export interface ICardStyle {
[key: string]: string | number | boolean | object | CSSProperties;
}