Commit 10912935 authored by XieZhiXiong's avatar XieZhiXiong

feat: 添加 loading

parent f7717d7d
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-04 17:26:51 * @Date: 2021-06-04 17:26:51
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-04 18:52:50 * @LastEditTime: 2021-06-07 16:20:40
* @Description: 资质上传组件 * @Description: 资质上传组件
*/ */
import React from 'react'; import React, { useState } from 'react';
import { Upload } from 'antd'; import { Upload } from 'antd';
import { PlusOutlined, FileOutlined } from '@ant-design/icons'; import { PlusOutlined, FileOutlined, LoadingOutlined } from '@ant-design/icons';
import { UploadChangeParam } from 'antd/lib/upload'; import { UploadChangeParam } from 'antd/lib/upload';
import styles from './index.less'; import styles from './index.less';
...@@ -20,12 +20,19 @@ const QualitiesUpload = (props) => { ...@@ -20,12 +20,19 @@ const QualitiesUpload = (props) => {
mutators, mutators,
// schema, // schema,
} = props; } = props;
const [loading, setLoading] = useState(false);
const arrValue = value ? [value] : []; const arrValue = value ? [value] : [];
const handleChange = (info: UploadChangeParam) => { const handleChange = (info: UploadChangeParam) => {
const { file } = info; const { file } = info;
const { response = {}, ...rest } = file; const { response = {}, ...rest } = file;
if (file.status === 'uploading') {
setLoading(true);
}
if (file.status === 'done' || file.status === 'error') {
setLoading(false);
}
mutators.change({ mutators.change({
...rest, ...rest,
...(response.data || {}), ...(response.data || {}),
...@@ -69,7 +76,11 @@ const QualitiesUpload = (props) => { ...@@ -69,7 +76,11 @@ const QualitiesUpload = (props) => {
fileList={arrValue} fileList={arrValue}
onChange={handleChange} onChange={handleChange}
> >
{arrValue.length ? renderFile() : uploadButton} {!loading ? (
arrValue.length ? renderFile() : uploadButton
) : (
<LoadingOutlined />
)}
</Upload> </Upload>
</div> </div>
); );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: XieZhiXiong * @Author: XieZhiXiong
* @Date: 2021-06-01 16:13:35 * @Date: 2021-06-01 16:13:35
* @LastEditors: XieZhiXiong * @LastEditors: XieZhiXiong
* @LastEditTime: 2021-06-07 15:07:45 * @LastEditTime: 2021-06-07 16:18:24
* @Description: 资质证明上传组件 * @Description: 资质证明上传组件
*/ */
import React from 'react'; import React from 'react';
...@@ -35,7 +35,7 @@ const schema = new Schema({ ...@@ -35,7 +35,7 @@ const schema = new Schema({
action: '/api/file/file/upload/prefix', action: '/api/file/file/upload/prefix',
data: { data: {
fileType: UPLOAD_TYPE, fileType: UPLOAD_TYPE,
prefix: 'member_qualifications_', prefix: '',
}, },
accept: '.doc, .docx, .xls, .xlsx, .pot, .pps, .vsd, .wps, .dps, .pdf, .txt, .png, .jpg, .rar, .zip', accept: '.doc, .docx, .xls, .xlsx, .pot, .pps, .vsd, .wps, .dps, .pdf, .txt, .png, .jpg, .rar, .zip',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment