From 2cd15bf1ed04df16b1282913ee46fd8351ccff48 Mon Sep 17 00:00:00 2001 From: zhoux Date: Fri, 22 Dec 2023 09:34:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=A8=E6=80=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ShowInfo.tsx | 63 ++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/src/pages/ShowInfo.tsx b/src/pages/ShowInfo.tsx index f971860..35299f6 100644 --- a/src/pages/ShowInfo.tsx +++ b/src/pages/ShowInfo.tsx @@ -7,7 +7,7 @@ import { ProFormText, ProFormUploadDragger, } from '@ant-design/pro-components'; -import { Button, Form, Image, Spin, SpinProps } from 'antd'; +import { Button, Form, Image, Spin } from 'antd'; import React, { useEffect, useState } from 'react'; // @ts-ignore import cookie from 'react-cookies'; @@ -17,17 +17,54 @@ const ShowInfoDemo: React.FC = () => { const [imageUrl, setImageUrl] = useState(''); // 是否需要加载中 const [isLoading, setIsLoading] = useState(false); + const [keyNameList, setKeyNameList] = useState[]>([]); + const [initialValues, setInitialValues] = useState>({}); - const initialValues = { - cardCode: '200100199508081010', - gender: '男', - }; + function fetchKeyValueList() { + setKeyNameList([ + // { label: '证件号码', value: '200100199508081010' }, + // { label: '性别', value: '男' }, + ]); + // setInitialValues({ + // cardCode: '200100199508081010', + // gender: '男', + // }) + } + function doAddField() { + setKeyNameList([ + { + label: '证件名称', + value: '居民身份', + }, + { + label: '证件号码', + value: '511028198702325665', + }, + { + label: '姓名', + value: '杨阳阳', + }, + { + label: '性别', + value: '男', + }, + { + label: '出生日期', + value: '1989-10-21', + }, + ]); + } + useEffect(() => { + fetchKeyValueList(); + }, []); return (
- +
@@ -40,7 +77,7 @@ const ShowInfoDemo: React.FC = () => { showUploadList: false, listType: 'picture-card', beforeUpload: (file) => { - setIsLoading(true) + setIsLoading(true); const reader = new FileReader(); reader.onload = (e) => { setImageUrl(e.target?.result as string); @@ -52,7 +89,7 @@ const ShowInfoDemo: React.FC = () => { // 返回 Promise 可以异步操作 return true; }, - + maxCount: 1, name: 'file', // beforeUpload: beforeUploadFile, @@ -73,7 +110,6 @@ const ShowInfoDemo: React.FC = () => {
{ fieldProps={{ labelInValue: true, }} - request={async () => [ - // TODO 使用接口数据与 initialValues 值对应 - { label: '证件号码', value: 'cardCode' }, - { label: '性别', value: 'gender' }, - ]} + options={keyNameList} name="name1" label="展示数据" /> {({ name1 }) => { if (name1) { + form.setFieldValue('activeKey', name1.value); console.log(name1, 'ProFormDependency_name1'); return (