MyFrame.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /**
  2. * @author oldj
  3. * @blog http://oldj.net
  4. */
  5. 'use strict'
  6. import React from 'react'
  7. import Agent from '../Agent'
  8. import { Modal, Button } from 'antd'
  9. import './MyFrame.less'
  10. export default class MyFrame extends React.Component {
  11. constructor (props) {
  12. super(props)
  13. }
  14. componentDidMount () {
  15. Agent.on('esc', () => {
  16. this.onCancel()
  17. })
  18. }
  19. onOK () {
  20. this.props.onOK()
  21. }
  22. onCancel () {
  23. this.props.onCancel()
  24. }
  25. renderFootButtons () {
  26. let html = []
  27. let {lang} = this.props
  28. html.push(
  29. <div
  30. className="button btn-cancel"
  31. key="btn-cancel"
  32. onClick={this.onCancel.bind(this)}
  33. >
  34. {this.props.cancel_title || lang.cancel}
  35. </div>
  36. )
  37. html.push(
  38. <div
  39. className="button btn-ok btn-default"
  40. key="btn-ok"
  41. onClick={this.onOK.bind(this)}
  42. >
  43. {this.props.ok_title || lang.ok}
  44. </div>
  45. )
  46. return html
  47. }
  48. render () {
  49. if (!this.props.show) {
  50. return null
  51. }
  52. let {show, title, body, lang, width, okText} = this.props
  53. return (
  54. <Modal
  55. visible={show}
  56. title={(<h3>{title}</h3>)}
  57. onOk={this.onOK.bind(this)}
  58. onCancel={this.onCancel.bind(this)}
  59. wrapClassName="frame"
  60. width={width}
  61. footer={[
  62. <Button key="back" size="large" onClick={this.onCancel.bind(this)}>
  63. {lang.cancel}
  64. </Button>,
  65. <Button key="submit" type="primary" size="large" loading={false} onClick={this.onOK.bind(this)}>
  66. {okText || lang.ok}
  67. </Button>
  68. ]}
  69. >
  70. <div className="prompt-body">{body}</div>
  71. {/*<div className="prompt">*/}
  72. {/*<div className="head">{this.props.head}</div>*/}
  73. {/*<div className="body">{this.props.body}</div>*/}
  74. {/*<div className="foot">{this.renderFootButtons()}</div>*/}
  75. {/*</div>*/}
  76. </Modal>
  77. )
  78. }
  79. }