@hzab/form-render 1.4.0 → 1.4.1
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.
- package/CHANGELOG.md +5 -1
- package/package.json +2 -2
- package/src/components/Upload/index.tsx +2 -23
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -4,35 +4,14 @@ import { useGlobalPropsContext } from "../../common/global-props-context";
|
|
4
4
|
export const Upload = (props) => {
|
5
5
|
// 组件外部传入的 props
|
6
6
|
const globalProps = useGlobalPropsContext() || {};
|
7
|
-
const { field = {}, onChange, value } = props;
|
8
|
-
const { name, mode, componentProps = {} } = field;
|
9
|
-
const { multiple } = componentProps;
|
10
|
-
|
11
|
-
async function onUploadChange(files) {
|
12
|
-
let _files = files;
|
13
|
-
if (field?.autoUpload && props.fieldsConf[name]?.onUpload) {
|
14
|
-
_files = await props.fieldsConf[name]?.onUpload(files);
|
15
|
-
if (!_files) {
|
16
|
-
return;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
// 若单选模式,默认只返回对应数据,而非嵌套一层数组
|
20
|
-
if (!multiple && _files && _files.length === 1) {
|
21
|
-
_files = _files[0];
|
22
|
-
}
|
23
|
-
onChange && onChange(_files);
|
24
|
-
}
|
25
7
|
|
26
8
|
const _props = {
|
27
|
-
mode: mode,
|
28
|
-
...props,
|
29
|
-
value: typeof value === "string" ? [value] : value,
|
30
9
|
axios: globalProps?.axios,
|
31
10
|
axiosConf: globalProps?.axiosConf,
|
32
|
-
...
|
11
|
+
...props,
|
33
12
|
};
|
34
13
|
|
35
|
-
return <UploaderCom {..._props}
|
14
|
+
return <UploaderCom {..._props} />;
|
36
15
|
};
|
37
16
|
|
38
17
|
export default Upload;
|