index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, { Component } from 'react';
  2. import './index.less';
  3. import { Modal, Icon } from 'antd';
  4. import Button from '../Button';
  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. btnType,
  23. center,
  24. height,
  25. } = this.props;
  26. return (
  27. <Modal
  28. wrapClassName={`g-modal ${className || ''}`}
  29. visible={show}
  30. closable={false}
  31. maskClosable={maskClosable}
  32. footer={false}
  33. width={width}
  34. onCancel={onClose}
  35. centered={center}
  36. >
  37. <div className="g-modal-wrapper">
  38. {close && onClose && <Icon className="close" type="close-circle" theme="filled" onClick={() => onClose()} />}
  39. <div className="g-modal-title">{title}</div>
  40. {body ? (
  41. <div className="g-modal-body" style={{ maxHeight: height }}>
  42. {children}
  43. </div>
  44. ) : (
  45. children
  46. )}
  47. <div className={`g-modal-btns ${btnAlign}`}>
  48. {onCancel && (
  49. <Button size="lager" theme={btnType === 'link' ? 'link t-6' : 'link'} onClick={() => onCancel()}>
  50. {cancelText}
  51. </Button>
  52. )}
  53. {onConfirm && (
  54. <Button size="lager" theme={btnType === 'link' ? 'link' : 'theme'} radius onClick={() => onConfirm()}>
  55. {confirmText}
  56. </Button>
  57. )}
  58. </div>
  59. </div>
  60. </Modal>
  61. );
  62. }
  63. }