1
0

index.js 1.6 KB

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