elementConfig.jsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import React from 'react'
  2. import ReactDOM from 'react-dom'
  3. import dashboardDesigner from '../../models/dashboardDesigner'
  4. import { Modal, Select } from 'antd'
  5. import { connect } from 'dva'
  6. import BraftEditor from 'braft-editor'
  7. import 'braft-editor/dist/braft.css'
  8. const Option = Select.Option
  9. const ElementConfig = ({operation, visibleBox, hideElementConfigBox, dashboardDesigner, dispatch}) => {
  10. const okHandler = (model) => {
  11. if(operation == 'create') {
  12. }else if(operation == 'modify') {
  13. }
  14. }
  15. const handleChange = (content) => {
  16. console.log(content)
  17. }
  18. const handleRawChange = (rawContent) => {
  19. console.log(rawContent)
  20. }
  21. const editorProps = {
  22. height: 300,
  23. contentFormat: 'raw',
  24. initialContent: '<p>Hello World!</p>',
  25. onChange: handleChange(),
  26. onRawChange: handleRawChange()
  27. }
  28. return (
  29. <Modal
  30. className='element-config'
  31. title={`${operation=='create'?'新增':'修改'}元素`}
  32. visible={visibleBox}
  33. onOk={() => {okHandler()}}
  34. onCancel={hideElementConfigBox}
  35. maskClosable={false}
  36. destroyOnClose={true}
  37. width="925px"
  38. >
  39. <div>
  40. <Select defaultValue={dashboardDesigner.configBoxForm.type} style={{ width: 120 }}
  41. onChange={(value) => { dispatch( {type: 'dashboardDesigner/handleFieldChange', name: 'type', value: value})}}>
  42. <Option value="chart">图表</Option>
  43. <Option value="simple">基础元素</Option>
  44. </Select>
  45. </div>
  46. <div style={{display: `${dashboardDesigner.configBoxForm.type == "simple" ? "inline":"none"}`}}>
  47. <BraftEditor {...editorProps}/>
  48. </div>
  49. </Modal>
  50. )
  51. }
  52. function mapStateToProps({ present: { dashboardDesigner } }) {
  53. return { dashboardDesigner: dashboardDesigner };
  54. }
  55. export default connect(mapStateToProps)(ElementConfig)