ConfigModal.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import React, { Component } from 'react'
  2. import { Modal, Spin, Button } from 'antd'
  3. import { connect } from 'dva'
  4. // less
  5. import styles from './index.less'
  6. @connect(({ posterList, loading }) => {
  7. const { configDetail = [] } = posterList
  8. return {
  9. configDetail,
  10. loading: loading.effects['posterList/getConfigDetail']
  11. }
  12. }, null, null, { withRef: true })
  13. class ConfigModal extends Component {
  14. constructor (props) {
  15. super(props)
  16. this.state = {
  17. modalVisible: false
  18. }
  19. }
  20. // modal弹窗出现
  21. showConfigModal = (id) => {
  22. this.setState({
  23. modalVisible: true
  24. }, () => {
  25. this.props.dispatch({
  26. type: 'posterList/getConfigDetail',
  27. payload: { id }
  28. })
  29. })
  30. }
  31. // modal弹窗消失
  32. hideConfigModal = () => {
  33. this.setState({
  34. modalVisible: false
  35. })
  36. }
  37. // render弹窗内容分
  38. renderConfigContent = () => {
  39. const { configDetail } = this.props
  40. return configDetail.map((item, index) => {
  41. return <p key={index}>{item}</p>
  42. })
  43. }
  44. render () {
  45. const { modalVisible } = this.state
  46. const { loading } = this.props
  47. return (
  48. <div className={styles.configModal}>
  49. <Modal
  50. title="全部配置"
  51. visible={modalVisible}
  52. onOk={this.hideConfigModal}
  53. onCancel={this.hideConfigModal}
  54. footer={
  55. <Button onClick={this.hideConfigModal}>
  56. 关闭
  57. </Button>
  58. }
  59. >
  60. <Spin spinning={loading}>
  61. {this.renderConfigContent()}
  62. </Spin>
  63. </Modal>
  64. </div>
  65. )
  66. }
  67. }
  68. export default ConfigModal