header.jsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 { connect } from 'dva'
  6. import { ActionCreators } from 'redux-undo'
  7. import { hashHistory } from 'react-router'
  8. import '../../models/chartDesigner'
  9. import './header.less'
  10. const Header = ({ chartDesigner, dispatch }) => {
  11. return (
  12. <div className='header'>
  13. <div className='header-item toolbar-back'>
  14. <Button onClick={() => {
  15. dispatch({ type: 'main/redirect', path: '/chart' });
  16. }}>
  17. 返回
  18. </Button>
  19. </div>
  20. <div className='header-item toolbar-title'>
  21. <Input
  22. className='input-title'
  23. addonAfter={<Icon type="edit"
  24. onClick={() => {
  25. const input = this.refs.titleInput
  26. input.focus()
  27. }}
  28. />}
  29. onChange={(e) => {
  30. dispatch({ type: 'chartDesigner/setField', name: 'header', value: { label: e.target.value } });
  31. }}
  32. value={chartDesigner.header.label}
  33. />
  34. </div>
  35. <div className='header-item toolbar-buttons'>
  36. <div className=''>
  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' onClick={() => {
  45. if(chartDesigner.code && chartDesigner.code != -1) {
  46. dispatch({ type: 'chartDesigner/remoteModify' });
  47. }else {
  48. dispatch({ type: 'chartDesigner/remoteAdd' });
  49. }
  50. }}>保存</Button>
  51. </div>
  52. </div>
  53. </div>
  54. )
  55. }
  56. function mapStateToProps({ present: { chartDesigner } }) {
  57. return { chartDesigner: chartDesigner }
  58. }
  59. export default connect(mapStateToProps)(Header);