index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { FullscreenExitOutlined, FullscreenOutlined, RedoOutlined, SearchOutlined, SettingOutlined } from "@ant-design/icons";
  2. import { Button, Col, Row, Space, Tooltip } from "antd";
  3. import React, { useContext } from "react";
  4. import { DispatchHeader } from "../TablePro";
  5. /**
  6. * 头部
  7. * @returns
  8. */
  9. const Settings: React.FC = () => {
  10. /******************************/
  11. const { isFullscreen, setIsFullscreen, isFull, toggleFull, setVisible, czChild, leftChild, ajax } = useContext(DispatchHeader)!;
  12. const colData = czChild ? { span: 24 } : { flex: '1 1 150px' }
  13. /******************************/
  14. return <Col span={24}>
  15. <Row gutter={[0, 10]} align='bottom'>
  16. <Col {...colData}>
  17. {isFullscreen && leftChild}
  18. </Col>
  19. {czChild && <Col flex='1 1 150px'>{czChild}</Col>}
  20. <Col flex='0 1 150px'>
  21. <Space style={{ float: 'right', marginBottom: 4 }}>
  22. <Button size='small' type='text' style={{ color: '#F56C6C' }} onClick={() => { setIsFullscreen(!isFullscreen) }}>
  23. <Tooltip title={isFullscreen ? '隐藏搜索' : '显示搜索'}><SearchOutlined /></Tooltip>
  24. </Button>
  25. {ajax && <Button size='small' type='text' style={{ color: '#67C23A' }} onClick={() => { ajax.refresh() }}>
  26. <Tooltip title='刷新'><RedoOutlined /></Tooltip>
  27. </Button>}
  28. <Button size='small' type='text' style={{ color: '#E6A23C' }} onClick={() => { setVisible(true) }}>
  29. <Tooltip title='设置'><SettingOutlined /></Tooltip>
  30. </Button>
  31. <Button type='text' size='small' style={{ color: '#409EFF' }} onClick={toggleFull}>
  32. {<Tooltip title={!isFull ? '全屏' : '退出全屏'}>{!isFull ? <FullscreenOutlined /> : <FullscreenExitOutlined />}</Tooltip>}
  33. </Button>
  34. </Space>
  35. </Col>
  36. </Row>
  37. </Col>
  38. }
  39. export default React.memo(Settings)