Merge pull request #691 from SuanmoSuanyangTechnology/feature/memory_zy
feat(web): user info api update
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 18:33:30
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-11 14:51:00
|
||||
* @Last Modified time: 2026-03-24 17:55:02
|
||||
*/
|
||||
/**
|
||||
* End User Profile Component
|
||||
@@ -18,7 +18,7 @@ import clsx from 'clsx'
|
||||
|
||||
import RbCard from '@/components/RbCard/Card'
|
||||
import {
|
||||
getEndUserProfile,
|
||||
getEndUserInfo,
|
||||
} from '@/api/memory'
|
||||
import EndUserProfileModal from './EndUserProfileModal'
|
||||
import type { EndUser, EndUserProfileModalRef, EndUserProfileRef } from '../types'
|
||||
@@ -31,7 +31,7 @@ interface EndUserProfileProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onDataLoaded, className }, ref) => {
|
||||
const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ className }, ref) => {
|
||||
const { t } = useTranslation()
|
||||
const { id } = useParams()
|
||||
const endUserProfileModalRef = useRef<EndUserProfileModalRef>(null)
|
||||
@@ -47,13 +47,9 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
const getData = () => {
|
||||
if (!id) return
|
||||
setLoading(true)
|
||||
getEndUserProfile(id).then((res) => {
|
||||
getEndUserInfo(id).then((res) => {
|
||||
const userData = res as EndUser
|
||||
setData(userData)
|
||||
onDataLoaded?.({
|
||||
other_name: userData.other_name,
|
||||
id: userData.id
|
||||
})
|
||||
setLoading(false)
|
||||
})
|
||||
.finally(() => {
|
||||
@@ -62,10 +58,10 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
}
|
||||
/** Format profile items for display */
|
||||
const formatItems = useCallback(() => {
|
||||
return ['other_name', 'position', 'department', 'contact', 'phone', 'hire_date'].map(key => ({
|
||||
return ['other_name'].map(key => ({
|
||||
key,
|
||||
label: t(`userMemory.${key}`),
|
||||
children: key === 'hire_date' && data?.[key] ? dayjs(data[key as keyof EndUser]).format('YYYY-MM-DD') : String(data?.[key as keyof EndUser] || '-'),
|
||||
children: String(data?.[key as keyof EndUser] || '-'),
|
||||
}))
|
||||
}, [data])
|
||||
/** Open edit modal */
|
||||
@@ -102,7 +98,7 @@ const EndUserProfile = forwardRef<EndUserProfileRef, EndUserProfileProps>(({ onD
|
||||
))}
|
||||
|
||||
<div className="rb:text-[#7B8085] rb:text-[12px] rb:leading-4.5">
|
||||
{t('userMemory.updated_at')}: {data?.updatetime_profile ? dayjs(data?.updatetime_profile).format('YYYY/MM/DD HH:mm:ss') : ''}
|
||||
{t('userMemory.updated_at')}: {data?.updated_at ? dayjs(data?.updated_at).format('YYYY/MM/DD HH:mm:ss') : ''}
|
||||
</div>
|
||||
</Flex>
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-03 18:33:21
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-03 18:33:21
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-03-24 17:58:43
|
||||
*/
|
||||
/**
|
||||
* End User Profile Modal
|
||||
@@ -10,13 +10,12 @@
|
||||
*/
|
||||
|
||||
import { forwardRef, useImperativeHandle, useState } from 'react';
|
||||
import { Form, Input, App, DatePicker } from 'antd';
|
||||
import { Form, Input, App } from 'antd';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import type { EndUser, EndUserProfileModalRef } from '../types'
|
||||
import RbModal from '@/components/RbModal'
|
||||
import { updatedEndUserProfile, } from '@/api/memory'
|
||||
import { updatedEndUserInfo } from '@/api/memory'
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
@@ -35,6 +34,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
const [visible, setVisible] = useState(false);
|
||||
const [form] = Form.useForm<EndUser>();
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [editVo, setEditVo] = useState<EndUser | null>(null)
|
||||
|
||||
const values = Form.useWatch([], form);
|
||||
|
||||
@@ -47,11 +47,8 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
|
||||
/** Open modal with user data */
|
||||
const handleOpen = (user: EndUser) => {
|
||||
form.setFieldsValue({
|
||||
...user,
|
||||
end_user_id: user.id,
|
||||
hire_date: user.hire_date ? dayjs(user.hire_date) : undefined
|
||||
});
|
||||
setEditVo(user)
|
||||
form.setFieldsValue(user);
|
||||
setVisible(true);
|
||||
};
|
||||
/** Save profile changes */
|
||||
@@ -60,9 +57,10 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
.validateFields()
|
||||
.then(() => {
|
||||
setLoading(true)
|
||||
updatedEndUserProfile({
|
||||
updatedEndUserInfo({
|
||||
...editVo,
|
||||
...values,
|
||||
hire_date: values.hire_date?.valueOf() || null
|
||||
// hire_date: values.hire_date?.valueOf() || null
|
||||
})
|
||||
.then(() => {
|
||||
setLoading(false)
|
||||
@@ -105,7 +103,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
>
|
||||
<Input placeholder={t('common.enter')} />
|
||||
</FormItem>
|
||||
<FormItem
|
||||
{/* <FormItem
|
||||
name="position"
|
||||
label={t('userMemory.position')}
|
||||
>
|
||||
@@ -134,7 +132,7 @@ const EndUserProfileModal = forwardRef<EndUserProfileModalRef, EndUserProfileMod
|
||||
label={t('userMemory.hire_date')}
|
||||
>
|
||||
<DatePicker className="rb:w-full" allowClear />
|
||||
</FormItem>
|
||||
</FormItem> */}
|
||||
</Form>
|
||||
</RbModal>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user