|
|
|
@ -7,11 +7,10 @@ import {
|
|
|
|
|
ProFormText,
|
|
|
|
|
ProFormUploadDragger,
|
|
|
|
|
} from '@ant-design/pro-components';
|
|
|
|
|
import {Button, Form, Image, message, Spin} from 'antd';
|
|
|
|
|
import { Form, Image, Spin, message } 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 [imageUrl, setImageUrl] = useState<string>('');
|
|
|
|
@ -30,8 +29,15 @@ const ShowInfoDemo: React.FC = () => {
|
|
|
|
|
// gender: '男',
|
|
|
|
|
// })
|
|
|
|
|
}
|
|
|
|
|
function doAddField(data) {
|
|
|
|
|
setKeyNameList(data);
|
|
|
|
|
function doAddField(record) {
|
|
|
|
|
console.log('doAddField_data', record);
|
|
|
|
|
setKeyNameList((data) => {
|
|
|
|
|
return record.map((item) => {
|
|
|
|
|
item.valueLabel = item.value;
|
|
|
|
|
item.value = item.key;
|
|
|
|
|
return item
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
@ -61,23 +67,23 @@ const ShowInfoDemo: React.FC = () => {
|
|
|
|
|
showUploadList: false,
|
|
|
|
|
listType: 'picture-card',
|
|
|
|
|
onChange: (info) => {
|
|
|
|
|
if(info.file.status === 'done') {
|
|
|
|
|
if (info.file.status === 'done') {
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
message.success('分析成功').then(r => {});
|
|
|
|
|
message.success('分析成功').then((r) => {});
|
|
|
|
|
console.log(info, 'info');
|
|
|
|
|
doAddField(info.file.response.data)
|
|
|
|
|
doAddField(info.file.response.data);
|
|
|
|
|
}
|
|
|
|
|
if(info.file.status === 'error') {
|
|
|
|
|
if (info.file.status === 'error') {
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
message.error('请求失败').then(r => {});
|
|
|
|
|
message.error('请求失败').then((r) => {});
|
|
|
|
|
console.log(info, 'info');
|
|
|
|
|
doAddField([])
|
|
|
|
|
doAddField([]);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
beforeUpload: (file) => {
|
|
|
|
|
form.resetFields(['name1']);
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
doAddField([])
|
|
|
|
|
doAddField([]);
|
|
|
|
|
const reader = new FileReader();
|
|
|
|
|
reader.onload = (e) => {
|
|
|
|
|
setImageUrl(e.target?.result as string);
|
|
|
|
@ -115,18 +121,18 @@ const ShowInfoDemo: React.FC = () => {
|
|
|
|
|
} // 配置 submitter
|
|
|
|
|
>
|
|
|
|
|
<ProFormSelect
|
|
|
|
|
style={{ width: 300 }}
|
|
|
|
|
fieldProps={{
|
|
|
|
|
labelInValue: true,
|
|
|
|
|
}}
|
|
|
|
|
options={keyNameList}
|
|
|
|
|
name="name1"
|
|
|
|
|
label="展示数据"
|
|
|
|
|
/>
|
|
|
|
|
style={{ width: 300 }}
|
|
|
|
|
fieldProps={{
|
|
|
|
|
labelInValue: true,
|
|
|
|
|
}}
|
|
|
|
|
options={keyNameList}
|
|
|
|
|
name="name1"
|
|
|
|
|
label="展示数据"
|
|
|
|
|
/>
|
|
|
|
|
<ProFormDependency name={['name1']}>
|
|
|
|
|
{({ name1 }) => {
|
|
|
|
|
if (name1) {
|
|
|
|
|
form.setFieldValue('activeKey', name1.value);
|
|
|
|
|
form.setFieldValue('activeKey', name1.valueLabel);
|
|
|
|
|
console.log(name1, 'ProFormDependency_name1');
|
|
|
|
|
return (
|
|
|
|
|
<ProFormText
|
|
|
|
|