zy-react-library 1.0.57 → 1.0.59
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.
|
@@ -10,6 +10,9 @@ const Upload = (props) => {
|
|
|
10
10
|
value = [],
|
|
11
11
|
onChange,
|
|
12
12
|
onPreview,
|
|
13
|
+
onRemove,
|
|
14
|
+
onGetRemoveFile,
|
|
15
|
+
beforeUpload,
|
|
13
16
|
maxCount: externalMaxCount,
|
|
14
17
|
listType: externalListType,
|
|
15
18
|
accept: externalAccept,
|
|
@@ -127,7 +130,9 @@ const Upload = (props) => {
|
|
|
127
130
|
return `${tips.join(",")}。`;
|
|
128
131
|
};
|
|
129
132
|
|
|
130
|
-
const handleBeforeUpload = () => {
|
|
133
|
+
const handleBeforeUpload = (file, fileList) => {
|
|
134
|
+
if (beforeUpload)
|
|
135
|
+
return beforeUpload(file, fileList)
|
|
131
136
|
return false;
|
|
132
137
|
};
|
|
133
138
|
|
|
@@ -186,6 +191,13 @@ const Upload = (props) => {
|
|
|
186
191
|
}
|
|
187
192
|
};
|
|
188
193
|
|
|
194
|
+
// 删除文件
|
|
195
|
+
const handleRemove = (file) => {
|
|
196
|
+
if (file.originFileObj)
|
|
197
|
+
onGetRemoveFile?.(file);
|
|
198
|
+
return onRemove?.(file);
|
|
199
|
+
}
|
|
200
|
+
|
|
189
201
|
// 预览文件
|
|
190
202
|
const handlePreview = (file) => {
|
|
191
203
|
if (isImageType) {
|
|
@@ -227,6 +239,7 @@ const Upload = (props) => {
|
|
|
227
239
|
accept={accept}
|
|
228
240
|
onChange={handleChange}
|
|
229
241
|
onPreview={handlePreview}
|
|
242
|
+
onRemove={handleRemove}
|
|
230
243
|
beforeUpload={handleBeforeUpload}
|
|
231
244
|
{...restProps}
|
|
232
245
|
>
|
|
@@ -37,7 +37,7 @@ function useGetFile(returnType = "object") {
|
|
|
37
37
|
{ eqType, eqForeignKey },
|
|
38
38
|
)
|
|
39
39
|
.then((res) => {
|
|
40
|
-
resolve(addingPrefixToFile(res.data));
|
|
40
|
+
resolve(addingPrefixToFile(res.data).map(item => ({ ...item, type: item.type.toString() })));
|
|
41
41
|
})
|
|
42
42
|
.catch((err) => {
|
|
43
43
|
reject(err);
|