@ecoding/components.antd 0.3.15 → 0.3.17
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.
|
@@ -113,7 +113,6 @@ const AsyncSlect = memo((props) => {
|
|
|
113
113
|
const res = searchIface.format2 ? jsonFormatNewKey2(resOrigin, searchIface.format2) : searchIface.format ? jsonFormatNewKey(resOrigin, searchIface.format) : resOrigin;
|
|
114
114
|
setOptions(res);
|
|
115
115
|
}
|
|
116
|
-
return Promise.reject("没有searchIface");
|
|
117
116
|
});
|
|
118
117
|
timeout = setTimeout(innerEx, 300);
|
|
119
118
|
});
|
|
@@ -54,7 +54,6 @@ const SingleFileUpload = (props) => {
|
|
|
54
54
|
Loading.show();
|
|
55
55
|
break;
|
|
56
56
|
case 'done':
|
|
57
|
-
Loading.hide();
|
|
58
57
|
const response = info.file.response || {};
|
|
59
58
|
const file = info.file;
|
|
60
59
|
const data = response.data || response.model;
|
|
@@ -62,6 +61,7 @@ const SingleFileUpload = (props) => {
|
|
|
62
61
|
response.code === 0 ||
|
|
63
62
|
response.success ||
|
|
64
63
|
response.successed) {
|
|
64
|
+
Loading.hide();
|
|
65
65
|
const tempObj = Object.assign({ name: file.name, url: data.url }, props.extraData);
|
|
66
66
|
const tempRes = infos.concat([]);
|
|
67
67
|
tempRes.push(tempObj);
|
|
@@ -74,6 +74,7 @@ const SingleFileUpload = (props) => {
|
|
|
74
74
|
props.onChange && props.onChange(tempRes);
|
|
75
75
|
}
|
|
76
76
|
else {
|
|
77
|
+
Loading.hide();
|
|
77
78
|
Toast.error({
|
|
78
79
|
mask: true,
|
|
79
80
|
title: response
|
|
@@ -83,6 +84,7 @@ const SingleFileUpload = (props) => {
|
|
|
83
84
|
}
|
|
84
85
|
break;
|
|
85
86
|
case 'error':
|
|
87
|
+
Loading.hide();
|
|
86
88
|
Toast.error({
|
|
87
89
|
mask: true,
|
|
88
90
|
title: info.file.response
|
|
@@ -92,6 +94,7 @@ const SingleFileUpload = (props) => {
|
|
|
92
94
|
props.onError && props.onError(info.file);
|
|
93
95
|
break;
|
|
94
96
|
default:
|
|
97
|
+
Loading.hide();
|
|
95
98
|
break;
|
|
96
99
|
}
|
|
97
100
|
};
|
|
@@ -14,6 +14,7 @@ import { buildURL } from "@ecoding/helper.url";
|
|
|
14
14
|
import Toast from "../../core/toast";
|
|
15
15
|
const SingleFileUpload = (props) => {
|
|
16
16
|
const [fileUrl, setFileUrl] = useState('');
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
17
18
|
const action = useMemo(() => {
|
|
18
19
|
if (typeof props.action === "string") {
|
|
19
20
|
return buildURL(props.action, props.actionParams);
|
|
@@ -24,6 +25,7 @@ const SingleFileUpload = (props) => {
|
|
|
24
25
|
// props.onChange && props.onChange(info.file);
|
|
25
26
|
switch (info.file.status) {
|
|
26
27
|
case "uploading":
|
|
28
|
+
setLoading(true);
|
|
27
29
|
break;
|
|
28
30
|
case "done":
|
|
29
31
|
const response = info.file.response || {};
|
|
@@ -32,12 +34,14 @@ const SingleFileUpload = (props) => {
|
|
|
32
34
|
response.code === 0 ||
|
|
33
35
|
response.success ||
|
|
34
36
|
response.successed) {
|
|
37
|
+
setLoading(false);
|
|
35
38
|
const url = data && data.url;
|
|
36
39
|
setFileUrl(url);
|
|
37
40
|
props.onChange && props.onChange(url);
|
|
38
41
|
props.onDone && props.onDone(info.file, data);
|
|
39
42
|
}
|
|
40
43
|
else {
|
|
44
|
+
setLoading(false);
|
|
41
45
|
Toast.error({
|
|
42
46
|
mask: true,
|
|
43
47
|
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,文件上传失败"
|
|
@@ -45,6 +49,7 @@ const SingleFileUpload = (props) => {
|
|
|
45
49
|
}
|
|
46
50
|
break;
|
|
47
51
|
case "error":
|
|
52
|
+
setLoading(false);
|
|
48
53
|
Toast.error({
|
|
49
54
|
mask: true,
|
|
50
55
|
title: info.file.response ? info.file.response.msg || info.file.response.message : "服务出错,文件上传失败"
|
|
@@ -52,6 +57,7 @@ const SingleFileUpload = (props) => {
|
|
|
52
57
|
props.onError && props.onError(info.file);
|
|
53
58
|
break;
|
|
54
59
|
default:
|
|
60
|
+
setLoading(false);
|
|
55
61
|
break;
|
|
56
62
|
}
|
|
57
63
|
};
|
|
@@ -87,7 +93,7 @@ const SingleFileUpload = (props) => {
|
|
|
87
93
|
console.log(e);
|
|
88
94
|
props.onRemove && props.onRemove(e);
|
|
89
95
|
}, maxCount: 1 },
|
|
90
|
-
React.createElement(Button, { disabled: props.disabled, icon: props.icon ? React.createElement(UploadOutlined, null) : null }, props.buttonText))));
|
|
96
|
+
React.createElement(Button, { loading: loading, disabled: props.disabled, icon: props.icon ? React.createElement(UploadOutlined, null) : null }, props.buttonText))));
|
|
91
97
|
};
|
|
92
98
|
SingleFileUpload.defaultProps = {
|
|
93
99
|
name: "file",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecoding/components.antd",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"author": "cxc",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"antd": "^5.8.4",
|
|
44
44
|
"axios": "^1.1.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b9aa1f40fdf63fae954546b7b2ed6dc12b9960f2"
|
|
47
47
|
}
|