index.tsx 868 B

12345678910111213141516171819202122232425262728
  1. import React, { useState, useEffect } from 'react';
  2. import mapstyles from '@/assets/css/map.less';
  3. import { getMapList } from '@/services/ant-design-pro/environment';
  4. import cx from 'classnames';
  5. type MapProps = {
  6. //mapList: API.MapInfo[];
  7. type: string;
  8. render: (item: API.MapInfo, index: number) => React.ReactNode;
  9. };
  10. const Map: React.FC<MapProps> = ({ type, render }) => {
  11. const [mapList, setMapList] = useState<API.MapInfo[]>([]);
  12. useEffect(() => {
  13. getMapList({ floorId: 'sffsdfdsfdf', floorNumber: 22 }).then(function (res) {
  14. var data: API.MapInfo[] = res.data || [];
  15. setMapList(data);
  16. });
  17. }, []);
  18. return (
  19. <div className={cx(mapstyles.map, { [mapstyles.equipmentMap]: type == 'equipment' })}>
  20. {mapList.map(function (item, index) {
  21. return render(item, index);
  22. })}
  23. </div>
  24. );
  25. };
  26. export default Map;