index.js 1.8 KB

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