diff --git a/src/pages/ShowInfo.tsx b/src/pages/ShowInfo.tsx index 35299f6..5fa5a36 100644 --- a/src/pages/ShowInfo.tsx +++ b/src/pages/ShowInfo.tsx @@ -7,13 +7,13 @@ import { ProFormText, ProFormUploadDragger, } from '@ant-design/pro-components'; -import { Button, Form, Image, Spin } from 'antd'; +import {Button, Form, Image, message, Spin} from 'antd'; import React, { useEffect, useState } from 'react'; // @ts-ignore import cookie from 'react-cookies'; import { API } from 'types'; const ShowInfoDemo: React.FC = () => { - const [form] = Form.useForm(); + const [form] = Form.useForm(); const [imageUrl, setImageUrl] = useState(''); // 是否需要加载中 const [isLoading, setIsLoading] = useState(false); @@ -30,29 +30,8 @@ const ShowInfoDemo: React.FC = () => { // gender: '男', // }) } - function doAddField() { - setKeyNameList([ - { - label: '证件名称', - value: '居民身份', - }, - { - label: '证件号码', - value: '511028198702325665', - }, - { - label: '姓名', - value: '杨阳阳', - }, - { - label: '性别', - value: '男', - }, - { - label: '出生日期', - value: '1989-10-21', - }, - ]); + function doAddField(data) { + setKeyNameList(data); } useEffect(() => { @@ -62,9 +41,6 @@ const ShowInfoDemo: React.FC = () => { return (
-
@@ -73,11 +49,35 @@ const ShowInfoDemo: React.FC = () => { name="projectFilePath" action="/api/v1/common/upload_file/" max={1} + // onChange={(info) => { + // if(info.file.status === 'done') { + // setIsLoading(false); + // message.success('分析成功').then(r => {}); + // console.log(info, 'info'); + // doAddField(info.file.response.data) + // } + // }} fieldProps={{ showUploadList: false, listType: 'picture-card', + onChange: (info) => { + if(info.file.status === 'done') { + setIsLoading(false); + message.success('分析成功').then(r => {}); + console.log(info, 'info'); + doAddField(info.file.response.data) + } + if(info.file.status === 'error') { + setIsLoading(false); + message.error('请求失败').then(r => {}); + console.log(info, 'info'); + doAddField([]) + } + }, beforeUpload: (file) => { + form.resetFields(['name1']); setIsLoading(true); + doAddField([]) const reader = new FileReader(); reader.onload = (e) => { setImageUrl(e.target?.result as string); @@ -107,7 +107,7 @@ const ShowInfoDemo: React.FC = () => {
{/* 展示信息 */} -
+
{ } // 配置 submitter > { console.log(name1, 'ProFormDependency_name1'); return ( );