1
0

index.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import React, { Component } from 'react';
  2. import './index.less';
  3. import { Modal, Icon } from 'antd';
  4. import AnswerButton from '../AnswerButton';
  5. export default class extends Component {
  6. render() {
  7. const {
  8. show,
  9. className,
  10. children,
  11. width,
  12. title,
  13. btnAlign = 'right',
  14. cancelText = '取消',
  15. confirmText = '确定',
  16. onCancel,
  17. onConfirm,
  18. onClose,
  19. close = true,
  20. maskClosable = false,
  21. body = true,
  22. center,
  23. height,
  24. getContainer,
  25. } = this.props;
  26. return (
  27. <Modal
  28. wrapClassName={`g-modal ${className || ''}`}
  29. visible={show}
  30. closable={false}
  31. getContainer={getContainer}
  32. maskClosable={maskClosable}
  33. footer={false}
  34. width={width}
  35. onCancel={onClose}
  36. centered={center}
  37. >
  38. <div className="g-modal-wrapper">
  39. {close && onClose && <Icon className="close" type="close-circle" theme="filled" onClick={() => onClose()} />}
  40. <div className="g-modal-title">{title}</div>
  41. {body ? (
  42. <div className="g-modal-body" style={{ maxHeight: height }}>
  43. {children}
  44. </div>
  45. ) : (
  46. children
  47. )}
  48. <div className={`g-modal-btns ${btnAlign}`}>
  49. {onCancel && (
  50. <AnswerButton size="lager" theme="cancel" onClick={() => onCancel()}>
  51. {cancelText}
  52. </AnswerButton>
  53. )}
  54. {onCancel && onConfirm && (
  55. <AnswerButton size="lager" onClick={() => onConfirm()}>
  56. {confirmText}
  57. </AnswerButton>
  58. )}
  59. {!onCancel && onConfirm && (
  60. <AnswerButton size="lager" theme="confirm" radius onClick={() => onConfirm()}>
  61. {confirmText}
  62. </AnswerButton>
  63. )}
  64. </div>
  65. </div>
  66. </Modal>
  67. );
  68. }
  69. }