Compare commits

...

3 Commits

Author SHA1 Message Date
chunquansang 53435bdb39 feat: 1 year ago
chunquansang 6a5cb58124 Merge branch 'main' of http://192.168.10.28:3000/Yaxin/InfoDetectFront 1 year ago
chunquansang 1fd0276aab feat 1 year ago

@ -7,13 +7,13 @@ import {
ProFormText, ProFormText,
ProFormUploadDragger, ProFormUploadDragger,
} from '@ant-design/pro-components'; } 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'; import React, { useEffect, useState } from 'react';
// @ts-ignore // @ts-ignore
import cookie from 'react-cookies'; import cookie from 'react-cookies';
import { API } from 'types'; import { API } from 'types';
const ShowInfoDemo: React.FC = () => { const ShowInfoDemo: React.FC = () => {
const [form] = Form.useForm<API.ModelImage>(); const [form] = Form.useForm();
const [imageUrl, setImageUrl] = useState<string>(''); const [imageUrl, setImageUrl] = useState<string>('');
// 是否需要加载中 // 是否需要加载中
const [isLoading, setIsLoading] = useState<boolean>(false); const [isLoading, setIsLoading] = useState<boolean>(false);
@ -30,29 +30,8 @@ const ShowInfoDemo: React.FC = () => {
// gender: '男', // gender: '男',
// }) // })
} }
function doAddField() { function doAddField(data) {
setKeyNameList([ setKeyNameList(data);
{
label: '证件名称',
value: '居民身份',
},
{
label: '证件号码',
value: '511028198702325665',
},
{
label: '姓名',
value: '杨阳阳',
},
{
label: '性别',
value: '男',
},
{
label: '出生日期',
value: '1989-10-21',
},
]);
} }
useEffect(() => { useEffect(() => {
@ -62,9 +41,6 @@ const ShowInfoDemo: React.FC = () => {
return ( return (
<div className="showInfoDemo_wrap"> <div className="showInfoDemo_wrap">
<Spin tip="正在分析中,请稍候..." fullscreen={true} spinning={isLoading}></Spin> <Spin tip="正在分析中,请稍候..." fullscreen={true} spinning={isLoading}></Spin>
<Button type="primary" onClick={doAddField}>
addField
</Button>
<PageContainer> <PageContainer>
<ProCard wrap title={'选择图片'} bodyStyle={{ display: 'flex' }}> <ProCard wrap title={'选择图片'} bodyStyle={{ display: 'flex' }}>
<div> <div>
@ -73,11 +49,35 @@ const ShowInfoDemo: React.FC = () => {
name="projectFilePath" name="projectFilePath"
action="/api/v1/common/upload_file/" action="/api/v1/common/upload_file/"
max={1} 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={{ fieldProps={{
showUploadList: false, showUploadList: false,
listType: 'picture-card', 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) => { beforeUpload: (file) => {
form.resetFields(['name1']);
setIsLoading(true); setIsLoading(true);
doAddField([])
const reader = new FileReader(); const reader = new FileReader();
reader.onload = (e) => { reader.onload = (e) => {
setImageUrl(e.target?.result as string); setImageUrl(e.target?.result as string);
@ -107,7 +107,7 @@ const ShowInfoDemo: React.FC = () => {
</div> </div>
{/* 展示信息 */} {/* 展示信息 */}
<div style={{ flex: 1, padding: 20 }}> <div style={{ flex: 1, padding: 40 }}>
<ProForm <ProForm
form={form} form={form}
submitter={ submitter={
@ -115,7 +115,7 @@ const ShowInfoDemo: React.FC = () => {
} // 配置 submitter } // 配置 submitter
> >
<ProFormSelect <ProFormSelect
style={{ width: 160 }} style={{ width: 300 }}
fieldProps={{ fieldProps={{
labelInValue: true, labelInValue: true,
}} }}
@ -130,10 +130,10 @@ const ShowInfoDemo: React.FC = () => {
console.log(name1, 'ProFormDependency_name1'); console.log(name1, 'ProFormDependency_name1');
return ( return (
<ProFormText <ProFormText
width={160} width={300}
label={name1.label} label={name1.label}
name={'activeKey'} name={'activeKey'}
disabled readonly={true}
required={false} required={false}
/> />
); );

Loading…
Cancel
Save