CardStatics.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import Title from '@/pages/home/components/Title';
  2. import React from 'react';
  3. import './index.less';
  4. type StatisticsItem = {
  5. name: string;
  6. value: number | string;
  7. children: React.ReactNode | string;
  8. permission?: any;
  9. node?: any;
  10. };
  11. interface StatisticsProps {
  12. extra?: React.ReactNode | string;
  13. style?: any;
  14. height?: any;
  15. data: StatisticsItem[];
  16. title: string;
  17. }
  18. const defaultImage = require('/public/images/home/top-1.svg');
  19. const CardStatistics = (props: StatisticsProps) => {
  20. return (
  21. <div className={'home-statistics'} style={{ height: props.height }}>
  22. <Title title={props.title} extra={props.extra} />
  23. <div className={'home-statistics-body'} style={props.style}>
  24. {props.data.map((item) => (
  25. <div className={'home-guide-item'} key={item.name}>
  26. <div className={'item-english'}>{item.name}</div>
  27. {item.node ? (
  28. <div style={{ display: 'flex', marginTop: 15, width: '80%' }}>
  29. {item.node.map((i: any) => (
  30. <div key={i.name + i.value} style={{ minWidth: 58, marginRight: 8, zIndex: 1 }}>
  31. <div style={{ fontSize: '14px', fontWeight: 'bold' }}>{i.value}</div>
  32. <div className={`state ${i.className}`}>{i.name}</div>
  33. </div>
  34. ))}
  35. </div>
  36. ) : (
  37. <div className={'item-title'}>{item.permission ? item.permission : item.value}</div>
  38. )}
  39. {typeof item.children === 'string' ? (
  40. <div className={`item-index`}>
  41. <img src={item.children || defaultImage} />
  42. </div>
  43. ) : (
  44. <div
  45. className={'item-index-echarts'}
  46. style={item.style || { height: 75, width: 110 }}
  47. >
  48. {item.children}
  49. </div>
  50. )}
  51. </div>
  52. ))}
  53. </div>
  54. </div>
  55. );
  56. };
  57. export default CardStatistics;