frame.jsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 './frame.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} = this.props
  53. return (
  54. <Modal
  55. visible={show}
  56. title={title}
  57. onOk={this.onOK.bind(this)}
  58. onCancel={this.onCancel.bind(this)}
  59. wrapClassName="frame"
  60. footer={[
  61. <Button key="back" size="large" onClick={this.onCancel.bind(this)}>
  62. {lang.cancel}
  63. </Button>,
  64. <Button key="submit" type="primary" size="large" loading={false} onClick={this.onOK.bind(this)}>
  65. {lang.ok}
  66. </Button>
  67. ]}
  68. >
  69. <div className="prompt-body">{body}</div>
  70. {/*<div className="prompt">*/}
  71. {/*<div className="head">{this.props.head}</div>*/}
  72. {/*<div className="body">{this.props.body}</div>*/}
  73. {/*<div className="foot">{this.renderFootButtons()}</div>*/}
  74. {/*</div>*/}
  75. </Modal>
  76. )
  77. }
  78. }