1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
| /*
| * @Company: hugeInfo
| * @Author: ldh
| * @Date: 2022-06-21 10:11:01
| * @LastEditTime: 2023-05-12 20:43:00
| * @LastEditors: lwh
| * @Version: 1.0.0
| * @Description: 我的Modal
| */
| import React from 'react';
| import PropTypes from 'prop-types';
| import { Button, Modal, Space } from 'antd';
| import './index.less';
|
| const MyModal = ({
| title,
| visible,
| onCancel,
| onOk,
| footer = true,
| okText = '确定',
| cancelText = '关闭',
| width,
| zIndex = 1000,
| bodyStyle,
| closable = true, // 是否展示关闭Button
| centered = false,
| children,
| }) => {
| return (
| <Modal
| closable={closable}
| title=""
| footer={null}
| visible={visible}
| bodyStyle={{ padding: '12px 16px 16px', ...bodyStyle }}
| width={width}
| onCancel={onCancel}
| zIndex={zIndex}
| centered={centered}
| >
| {!!title && (
| <div className="myModal-header">
| <span className="myModal-header-title">{title}</span>
| </div>
| )}
| {children}
| {footer && (
| <div className="myModal-footer">
| <Space size="middle">
| {Array.isArray(footer) ? (
| <>
| {footer.map((x, t) => (
| <div key={t}>{x}</div>
| ))}
| </>
| ) : (
| <>
| {!!onOk && (
| <Button type="primary" onClick={onOk}>
| {okText}
| </Button>
| )}
| {!!closable && closable && <Button onClick={onCancel}>{cancelText}</Button>}
| </>
| )}
| </Space>
| </div>
| )}
| </Modal>
| );
| };
|
| MyModal.propTypes = {
| title: PropTypes.any,
| visible: PropTypes.bool,
| onCancel: PropTypes.func,
| onOk: PropTypes.func,
| footer: PropTypes.any,
| onText: PropTypes.string,
| cancelText: PropTypes.string,
| zIndex: PropTypes.number,
| bodyStyle: PropTypes.object,
| closable: PropTypes.bool,
| centered: PropTypes.bool,
| };
|
| export default MyModal;
|
|