index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. center,
  23. } = this.props;
  24. return (
  25. <Modal
  26. wrapClassName={`g-modal ${className || ''}`}
  27. visible={show}
  28. closable={false}
  29. maskClosable={maskClosable}
  30. footer={false}
  31. width={width}
  32. onCancel={onClose}
  33. centered={center}
  34. >
  35. <div className="g-modal-wrapper">
  36. {close && onClose && <Icon className="close" type="close-circle" theme="filled" onClick={() => onClose()} />}
  37. <div className="g-modal-title">{title}</div>
  38. {body ? <div className="g-modal-body">{children}</div> : children}
  39. <div className={`g-modal-btns ${btnAlign}`}>
  40. {onCancel && (
  41. <Button size="lager" theme="link" onClick={() => onCancel()}>
  42. {cancelText}
  43. </Button>
  44. )}
  45. {onConfirm && (
  46. <Button size="lager" radius onClick={() => onConfirm()}>
  47. {confirmText}
  48. </Button>
  49. )}
  50. </div>
  51. </div>
  52. </Modal>
  53. );
  54. }
  55. }