header.jsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import React from 'react';
  2. import { Input, Select, Icon, Button } from 'antd';
  3. const Option = Select.Option;
  4. import { Link } from 'react-router-dom'
  5. import './header.less';
  6. import { connect } from 'dva';
  7. import { ActionCreators } from 'redux-undo';
  8. import chartDesigner from '../../models/chartDesigner';
  9. const Header = ({ chartDesigner, dispatch }) => {
  10. return (
  11. <div className='header'>
  12. <div className='header-item toolbar-back'>
  13. <Button>
  14. <Link to='/'>返回</Link>
  15. </Button>
  16. </div>
  17. <div className='header-item toolbar-title'>
  18. <Input
  19. className='input-title'
  20. addonAfter={<Icon type="edit"
  21. onClick={() => {
  22. const input = this.refs.titleInput
  23. input.focus()
  24. }}
  25. />}
  26. onChange={(e) => {
  27. dispatch({ type: 'chartDesigner/setModel', name: 'header', value: { label: e.target.value } });
  28. }}
  29. value={chartDesigner.header.label}
  30. />
  31. </div>
  32. <div className='header-item toolbar-buttons'>
  33. <div className=''>
  34. <Button onClick={() => {
  35. dispatch({ type: 'chartDesigner/fetchChartData'});
  36. }}>请求测试</Button>
  37. <Button className='button-uodo' icon='undo' onClick={() => {
  38. dispatch(ActionCreators.undo());
  39. }}>撤销</Button>
  40. <Button className='button-redo' onClick={() => {
  41. dispatch(ActionCreators.redo());
  42. }}>重做</Button>
  43. <Button className='button-uodo' >预览</Button>
  44. <Button className='button-uodo' >保存</Button>
  45. </div>
  46. </div>
  47. </div>
  48. )
  49. }
  50. function mapStateToProps({ present: { chartDesigner } }) {
  51. return { chartDesigner: chartDesigner }
  52. }
  53. export default connect(mapStateToProps)(Header);