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
| /*
| * @Company: hugeInfo
| * @Author: ldh
| * @Date: 2022-06-22 11:14:43
| * @LastEditTime: 2022-10-28 11:07:04
| * @LastEditors: ldh
| * @Version: 1.0.0
| * @Description: 我的抽屉组件
| */
| import React from 'react';
| import PropTypes from 'prop-types';
| import { Drawer, Space } from 'antd';
| import { CloseOutlined } from '@ant-design/icons';
| import './index.less';
|
| const MyDrawer = ({
| children,
| visible,
| onClose,
| width = 508,
| title,
| footer = [],
| style = {},
| bodyStyle = {},
| mainStyle = {},
| zIndex = 1000,
| container = false,
| }) => {
| return (
| <Drawer
| title=""
| closable={false}
| placement="right"
| visible={!!visible}
| getContainer={container ? 'body' : () => document.getElementById('layoutMain')}
| width={width}
| onClose={onClose}
| style={Object.assign({ position: 'absolute' }, style)}
| bodyStyle={{ padding: 0 }}
| destroyOnClose={true}
| zIndex={zIndex}
| >
| <div className="myDrawer" style={bodyStyle}>
| <div className="myDrawer-header">
| <div className="myDrawer-header-title">{title}</div>
| <CloseOutlined className="myDrawer-header-close" onClick={onClose} />
| </div>
| <div className="myDrawer-main" style={mainStyle}>
| {children}
| </div>
| {footer.length !== 0 && (
| <div className="myDrawer-footer">
| <Space size="large">{footer.map((x) => x)}</Space>
| </div>
| )}
| </div>
| </Drawer>
| );
| };
|
| MyDrawer.propTypes = {
| visible: PropTypes.any,
| onClose: PropTypes.func,
| width: PropTypes.any,
| title: PropTypes.any,
| style: PropTypes.object,
| bodyStyle: PropTypes.object,
| mainStyle: PropTypes.object,
| zIndex: PropTypes.number,
| };
|
| export default MyDrawer;
|
|