|
|
@@ -15,7 +15,7 @@ const ProfileEditPage: React.FC = () => {
|
|
|
const [form] = Form.useForm();
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
const [profile, setProfile] = useState<any>(null);
|
|
|
- const [avatarUrl, setAvatarUrl] = useState<string>('');
|
|
|
+ const [avatarFileId, setAvatarFileId] = useState<number | null>(null);
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (user) {
|
|
|
@@ -25,7 +25,7 @@ const ProfileEditPage: React.FC = () => {
|
|
|
|
|
|
const loadProfile = async () => {
|
|
|
try {
|
|
|
- const response = await (silverUsersClient as any)['profiles'].$get({
|
|
|
+ const response = await silverUsersClient['profiles'].$get({
|
|
|
query: { filters: JSON.stringify({ userId: user.id }) }
|
|
|
});
|
|
|
|
|
|
@@ -34,7 +34,7 @@ const ProfileEditPage: React.FC = () => {
|
|
|
if (data.data && data.data.length > 0) {
|
|
|
const profileData = data.data[0];
|
|
|
setProfile(profileData);
|
|
|
- setAvatarUrl(profileData.avatar || '');
|
|
|
+ setAvatarFileId(profileData.avatarFileId || null);
|
|
|
|
|
|
form.setFieldsValue({
|
|
|
...profileData,
|
|
|
@@ -59,8 +59,8 @@ const ProfileEditPage: React.FC = () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- const handleAvatarChange = (newAvatarUrl: string) => {
|
|
|
- setAvatarUrl(newAvatarUrl);
|
|
|
+ const handleAvatarChange = (fileId: number) => {
|
|
|
+ setAvatarFileId(fileId);
|
|
|
};
|
|
|
|
|
|
const handleSubmit = async (values: any) => {
|
|
|
@@ -81,7 +81,7 @@ const ProfileEditPage: React.FC = () => {
|
|
|
// 更新银龄档案
|
|
|
const profileData = {
|
|
|
...values,
|
|
|
- avatar: avatarUrl,
|
|
|
+ avatarFileId: avatarFileId,
|
|
|
birthDate: values.birthDate?.format('YYYY-MM-DD'),
|
|
|
workStartDate: values.workStartDate?.format('YYYY-MM-DD'),
|
|
|
userId: user.id
|
|
|
@@ -141,9 +141,10 @@ const ProfileEditPage: React.FC = () => {
|
|
|
<Form.Item label="头像">
|
|
|
<div className="flex items-center space-x-4">
|
|
|
<SimpleAvatarUpload
|
|
|
- currentAvatar={avatarUrl}
|
|
|
+ currentAvatar={avatarFileId ? (silverUsersClient as any)['profiles'].$get({ query: { id: avatarFileId } }) : ''}
|
|
|
size={80}
|
|
|
onUploadSuccess={handleAvatarChange}
|
|
|
+ fileId={avatarFileId}
|
|
|
/>
|
|
|
<span className="text-sm text-gray-500">点击头像上传新照片</span>
|
|
|
</div>
|