diff --git a/src/pages/user-info/index.tsx b/src/pages/user-info/index.tsx new file mode 100644 index 0000000..15c49d4 --- /dev/null +++ b/src/pages/user-info/index.tsx @@ -0,0 +1,415 @@ +import React, { useState } from 'react'; +import { + Card, + Form, + Input, + Button, + Avatar, + Upload, + Space, + Typography, + Divider, + Grid, + Message, + Select, + DatePicker, + Radio, + Descriptions, + Tag, + Statistic, +} from '@arco-design/web-react'; +import { + IconUser, + IconEmail, + IconPhone, + IconLocation, + IconEdit, + IconCamera, + IconCheck, + IconClose, +} from '@arco-design/web-react/icon'; +import styles from './style/index.module.less'; + +const { Title, Paragraph, Text } = Typography; +const { Row, Col } = Grid; +const FormItem = Form.Item; +const Option = Select.Option; +const RadioGroup = Radio.Group; + +/** + * 个人信息页面 + */ +function UserInfo() { + const [form] = Form.useForm(); + const [isEditing, setIsEditing] = useState(false); + const [loading, setLoading] = useState(false); + + // 模拟用户数据 + const [userInfo, setUserInfo] = useState({ + avatar: + 'https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp', + name: '张三', + username: 'zhangsan', + email: 'zhangsan@example.com', + phone: '138****8888', + gender: 'male', + birthday: '1990-01-01', + department: '技术部', + position: '高级工程师', + location: '北京市朝阳区', + introduction: + '热爱技术,专注于前端开发领域,有丰富的 React 和 TypeScript 开发经验。', + joinDate: '2020-01-15', + employeeId: 'EMP001', + }); + + // 统计数据 + const statistics = { + projectCount: 28, + taskCompleted: 156, + contribution: 892, + teamSize: 12, + }; + + // 初始化表单值 + React.useEffect(() => { + form.setFieldsValue(userInfo); + }, [userInfo, form]); + + // 保存用户信息 + const handleSave = async () => { + try { + const values = await form.validate(); + setLoading(true); + + // 模拟保存 + await new Promise((resolve) => setTimeout(resolve, 1000)); + + setUserInfo({ ...userInfo, ...values }); + setIsEditing(false); + Message.success('保存成功'); + } catch (error) { + console.error('表单验证失败:', error); + } finally { + setLoading(false); + } + }; + + // 取消编辑 + const handleCancel = () => { + form.setFieldsValue(userInfo); + setIsEditing(false); + }; + + // 上传头像 + const handleAvatarChange = (fileList) => { + if (fileList && fileList.length > 0) { + const file = fileList[0]; + if (file.originFile) { + const reader = new FileReader(); + reader.onload = (e) => { + setUserInfo({ ...userInfo, avatar: e.target?.result as string }); + Message.success('头像上传成功'); + }; + reader.readAsDataURL(file.originFile); + } + } + }; + + return ( +