Optimize load data

This commit is contained in:
2023-11-30 12:05:27 +08:00
parent 99d2a73b6c
commit bf8f915b15
5 changed files with 48 additions and 16 deletions

View File

@@ -12,6 +12,7 @@ import {
DATABASE_UPDATE_SUCCESS
} from '@/constants/common.constants'
import { utcToLocalTime, isPastTime, localTimeToUtc, dayjsToUtc, getNowUtc } from '@/utils/common'
import { useUpdatedEffect } from '@/utils/hooks'
import {
r_sys_group_get_list,
r_sys_role_get_list,
@@ -259,6 +260,12 @@ const User: React.FC = () => {
form.setFieldValue('roleIds', newFormValues?.roleIds)
form.setFieldValue('groupIds', newFormValues?.groupIds)
if (!roleData || !roleData.length) {
getRoleData()
}
if (!groupData || !groupData.length) {
getGroupData()
}
getAvatar()
}
@@ -429,6 +436,12 @@ const User: React.FC = () => {
'groupIds',
value.groups.map((group) => group.id)
)
if (!roleData || !roleData.length) {
getRoleData()
}
if (!groupData || !groupData.length) {
getGroupData()
}
void form.validateFields()
}
}
@@ -718,11 +731,7 @@ const User: React.FC = () => {
}
}, [formValues])
useEffect(() => {
handleOnDrawerRefresh()
}, [])
useEffect(() => {
useUpdatedEffect(() => {
getUser()
}, [
JSON.stringify(tableParams.filters),