index.js
1.86 KB
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
import React, { useEffect, useState } from "react";
import { Button, Modal, Space } from "antd";
import RouterComponent from "@/routes/mes/routerComponent";
// 通用方法
import * as commonUtils from "@/utils/utils";
const CommonModalComponent = props => {
const bSmall = props?.sModelsId ==='17211911815017669983448000';
const {
visible,
title,
width = bSmall? "calc(75vw - 110px)" : "calc(100vw - 110px)",
height = bSmall? "calc(80vh - 60px)" : "calc(100vh - 60px)",
onCancel
} = props;
if (!visible) return "";
let { style } = props;
if (commonUtils.isEmptyObject(style)) {
style = {
padding: 0,
margin: 0,
top: 60,
left: bSmall? 216: 110
};
}
const [extraBtns, setExtraBtns] = useState([]);
const titleNew =
props.sModelsId === "12710101117087374661080"
? props.parentProps.btnConfig.showName
: title;
const closable = !window.deviceTargetInfoModalAutoShow;
useEffect(() => {
return () => {
window.deviceTargetInfoModalAutoShow = false;
};
}, []);
return (
<Modal
title={titleNew}
open={visible}
width={width}
height={height}
style={style}
className="mesCommonModal"
closable={closable}
keyboard={closable}
maskClosable={closable}
footer={
<Space>
{extraBtns}
<Button
size="large"
disabled={!closable}
onClick={() => {
props.onCancel && props.onCancel();
}}
>
关闭
</Button>
</Space>
}
onCancel={onCancel}
>
<div
style={{
width: "100%",
height: "100%"
}}
>
<RouterComponent {...props} onCancel={onCancel} setExtraBtns={setExtraBtns} />
</div>
</Modal>
);
};
export default CommonModalComponent;