@ecoding/components.antd 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IModalProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
open?: boolean;
|
|
5
|
+
bodyStyle?: React.CSSProperties;
|
|
6
|
+
width?: string;
|
|
7
|
+
zIndex?: number;
|
|
8
|
+
mask?: boolean;
|
|
9
|
+
title?: React.ReactNode;
|
|
10
|
+
okType?: "text" | "link" | "ghost" | "default" | "primary" | "dashed" | undefined;
|
|
11
|
+
okText?: string;
|
|
12
|
+
cancelText?: string;
|
|
13
|
+
closable?: boolean;
|
|
14
|
+
footer?: React.ReactNode;
|
|
15
|
+
onOk?: () => Promise<any>;
|
|
16
|
+
onOkAfter?: (args: any) => void | Promise<any>;
|
|
17
|
+
onCancel?: () => Promise<any>;
|
|
18
|
+
component?: React.ReactNode;
|
|
19
|
+
addonBefore?: React.ReactNode;
|
|
20
|
+
addonAfter?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: {
|
|
23
|
+
show(props?: IModalProps): void;
|
|
24
|
+
hide(props?: IModalProps): void;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from 'antd';
|
|
3
|
+
import Notification from '../../helpers/notification';
|
|
4
|
+
const notification = Notification.newInstance();
|
|
5
|
+
class Modals extends React.Component {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.state = {
|
|
9
|
+
loading: false,
|
|
10
|
+
open: true
|
|
11
|
+
};
|
|
12
|
+
this.cancel = () => {
|
|
13
|
+
if (this.state.loading) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
this.props.onCancel &&
|
|
17
|
+
this.props.onCancel().then(() => {
|
|
18
|
+
this.setState({
|
|
19
|
+
open: false
|
|
20
|
+
});
|
|
21
|
+
// hideModal();
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
this.ok = () => {
|
|
25
|
+
this.setState({
|
|
26
|
+
loading: true
|
|
27
|
+
});
|
|
28
|
+
this.props.onOk &&
|
|
29
|
+
this.props
|
|
30
|
+
.onOk()
|
|
31
|
+
.then((res) => {
|
|
32
|
+
this.setState({
|
|
33
|
+
loading: false,
|
|
34
|
+
open: false
|
|
35
|
+
});
|
|
36
|
+
// hideModal();
|
|
37
|
+
this.props.onOkAfter && this.props.onOkAfter(res);
|
|
38
|
+
})
|
|
39
|
+
.catch(() => {
|
|
40
|
+
this.setState({
|
|
41
|
+
loading: false
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
// if (!this.props.visible) return null;
|
|
48
|
+
return (React.createElement(Modal, { className: this.props.className, open: this.state.open, bodyStyle: this.props.bodyStyle, width: this.props.width, zIndex: this.props.zIndex, mask: this.props.mask, title: this.props.title, closable: this.props.closable, onCancel: this.cancel, footer: this.props.footer === null ? null : this.props.footer ? (this.props.footer) : (React.createElement(React.Fragment, null,
|
|
49
|
+
this.props.addonBefore ? this.props.addonBefore : null,
|
|
50
|
+
React.createElement(Button, { key: "back", onClick: this.cancel }, this.props.cancelText),
|
|
51
|
+
React.createElement(Button, { key: "submit", type: this.props.okType, loading: this.state.loading, onClick: this.ok }, this.props.okText),
|
|
52
|
+
this.props.addonAfter ? this.props.addonAfter : null)), centered: true, destroyOnClose: true, keyboard: false }, this.props.component ? this.props.component : null));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
Modals.defaultProps = {
|
|
56
|
+
tip: ''
|
|
57
|
+
};
|
|
58
|
+
export default {
|
|
59
|
+
show(props = {}) {
|
|
60
|
+
if (notification) {
|
|
61
|
+
notification.removeNotice('modals');
|
|
62
|
+
}
|
|
63
|
+
notification.notice(React.createElement(Modals, Object.assign({}, props, { key: "modals" })));
|
|
64
|
+
},
|
|
65
|
+
hide(props = {}) {
|
|
66
|
+
notification.removeNotice('modals');
|
|
67
|
+
}
|
|
68
|
+
};
|
|
@@ -25,24 +25,20 @@ const SingleFileUpload = (props) => {
|
|
|
25
25
|
break;
|
|
26
26
|
case "done":
|
|
27
27
|
const response = info.file.response;
|
|
28
|
-
if (response &&
|
|
28
|
+
if ((response && response.code === 200) || response.success) {
|
|
29
29
|
props.onDone && props.onDone(info.file, info.file.response.data);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
Toast.error({
|
|
33
33
|
mask: true,
|
|
34
|
-
title: info.file.response
|
|
35
|
-
? info.file.response.retDesc || info.file.response.desc || info.file.response.message
|
|
36
|
-
: "服务出错,文件上传失败"
|
|
34
|
+
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,文件上传失败"
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
break;
|
|
40
38
|
case "error":
|
|
41
39
|
Toast.error({
|
|
42
40
|
mask: true,
|
|
43
|
-
title: info.file.response
|
|
44
|
-
? info.file.response.retDesc || info.file.response.desc || info.file.response.message
|
|
45
|
-
: "服务出错,文件上传失败"
|
|
41
|
+
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,文件上传失败"
|
|
46
42
|
});
|
|
47
43
|
props.onError && props.onError(info.file);
|
|
48
44
|
break;
|
|
@@ -51,8 +51,8 @@ const ImgUpload = (props) => {
|
|
|
51
51
|
case "done":
|
|
52
52
|
setLoading(false);
|
|
53
53
|
const response = info.file.response;
|
|
54
|
-
if (response &&
|
|
55
|
-
const url =
|
|
54
|
+
if ((response && response.code === 200) || response.success) {
|
|
55
|
+
const url = response.data && response.data.url;
|
|
56
56
|
setImageUrl(url);
|
|
57
57
|
// Form.item 值注入关键
|
|
58
58
|
props.onChange && props.onChange(url);
|
|
@@ -60,18 +60,14 @@ const ImgUpload = (props) => {
|
|
|
60
60
|
else {
|
|
61
61
|
Toast.error({
|
|
62
62
|
mask: true,
|
|
63
|
-
title: info.file.response
|
|
64
|
-
? info.file.response.retDesc || info.file.response.desc || info.file.response.message
|
|
65
|
-
: "服务出错,图片上传失败"
|
|
63
|
+
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,图片上传失败"
|
|
66
64
|
});
|
|
67
65
|
}
|
|
68
66
|
break;
|
|
69
67
|
case "error":
|
|
70
68
|
Toast.error({
|
|
71
69
|
mask: true,
|
|
72
|
-
title: info.file.response
|
|
73
|
-
? info.file.response.retDesc || info.file.response.desc || info.file.response.message
|
|
74
|
-
: "服务出错,图片上传失败"
|
|
70
|
+
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,图片上传失败"
|
|
75
71
|
});
|
|
76
72
|
setLoading(false);
|
|
77
73
|
break;
|
|
@@ -154,7 +150,7 @@ const ImgUpload = (props) => {
|
|
|
154
150
|
props.gif ? "、gif" : ""))));
|
|
155
151
|
};
|
|
156
152
|
ImgUpload.defaultProps = {
|
|
157
|
-
action: "/upload/img",
|
|
153
|
+
action: "/api/upload/img",
|
|
158
154
|
name: "file",
|
|
159
155
|
value: "",
|
|
160
156
|
gif: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"react-quill": "^2.0.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "75b04307c2ea7d447bcad3a75418bf8083c2c6f4"
|
|
44
44
|
}
|