Optimize code
This commit is contained in:
@@ -201,9 +201,9 @@ const Group: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_group_delete_list(tableSelectedItem)
|
void r_sys_group_delete_list(tableSelectedItem)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getGroup()
|
getGroup()
|
||||||
@@ -253,8 +253,8 @@ const Group: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_group_delete(value.id)
|
void r_sys_group_delete(value.id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getGroup()
|
getGroup()
|
||||||
@@ -290,8 +290,8 @@ const Group: React.FC = () => {
|
|||||||
if (isDrawerEdit) {
|
if (isDrawerEdit) {
|
||||||
void r_sys_group_update(formValues)
|
void r_sys_group_update(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_UPDATE_SUCCESS:
|
case DATABASE_UPDATE_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('更新成功')
|
void message.success('更新成功')
|
||||||
@@ -310,8 +310,8 @@ const Group: React.FC = () => {
|
|||||||
} else {
|
} else {
|
||||||
void r_sys_group_add(formValues)
|
void r_sys_group_add(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_INSERT_SUCCESS:
|
case DATABASE_INSERT_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('添加成功')
|
void message.success('添加成功')
|
||||||
@@ -379,8 +379,8 @@ const Group: React.FC = () => {
|
|||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
void r_sys_group_change_status({ id, enable: newStatus })
|
void r_sys_group_change_status({ id, enable: newStatus })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_UPDATE_SUCCESS) {
|
if (response.code === DATABASE_UPDATE_SUCCESS) {
|
||||||
void message.success('更新成功')
|
void message.success('更新成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getGroup()
|
getGroup()
|
||||||
@@ -421,17 +421,17 @@ const Group: React.FC = () => {
|
|||||||
...tableParams.filters
|
...tableParams.filters
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
const records = data.data?.records
|
const records = response.data?.records
|
||||||
|
|
||||||
records && setGroupData(records)
|
records && setGroupData(records)
|
||||||
data.data &&
|
response.data &&
|
||||||
setTableParams({
|
setTableParams({
|
||||||
...tableParams,
|
...tableParams,
|
||||||
pagination: {
|
pagination: {
|
||||||
...tableParams.pagination,
|
...tableParams.pagination,
|
||||||
total: data.data.total
|
total: response.data.total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -452,10 +452,10 @@ const Group: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_role_get_list()
|
void r_sys_role_get_list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
data.data && setRoleData(data.data)
|
response.data && setRoleData(response.data)
|
||||||
} else {
|
} else {
|
||||||
void message.error('获取角色列表失败,请稍后重试')
|
void message.error('获取角色列表失败,请稍后重试')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,15 +237,15 @@ const Log: React.FC = () => {
|
|||||||
...tableParams.filters
|
...tableParams.filters
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
data.data && setLogData(data.data.records)
|
response.data && setLogData(response.data.records)
|
||||||
data.data &&
|
response.data &&
|
||||||
setTableParams({
|
setTableParams({
|
||||||
...tableParams,
|
...tableParams,
|
||||||
pagination: {
|
pagination: {
|
||||||
...tableParams.pagination,
|
...tableParams.pagination,
|
||||||
total: data.data.total
|
total: response.data.total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -193,9 +193,9 @@ const Role: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_role_delete_list(tableSelectedItem)
|
void r_sys_role_delete_list(tableSelectedItem)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRole()
|
getRole()
|
||||||
@@ -245,8 +245,8 @@ const Role: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_role_delete(value.id)
|
void r_sys_role_delete(value.id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRole()
|
getRole()
|
||||||
@@ -279,8 +279,8 @@ const Role: React.FC = () => {
|
|||||||
if (isDrawerEdit) {
|
if (isDrawerEdit) {
|
||||||
void r_sys_role_update(formValues)
|
void r_sys_role_update(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_UPDATE_SUCCESS:
|
case DATABASE_UPDATE_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('更新成功')
|
void message.success('更新成功')
|
||||||
@@ -299,8 +299,8 @@ const Role: React.FC = () => {
|
|||||||
} else {
|
} else {
|
||||||
void r_sys_role_add(formValues)
|
void r_sys_role_add(formValues)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_INSERT_SUCCESS:
|
case DATABASE_INSERT_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('添加成功')
|
void message.success('添加成功')
|
||||||
@@ -368,8 +368,8 @@ const Role: React.FC = () => {
|
|||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
void r_sys_role_change_status({ id, enable: newStatus })
|
void r_sys_role_change_status({ id, enable: newStatus })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_UPDATE_SUCCESS) {
|
if (response.code === DATABASE_UPDATE_SUCCESS) {
|
||||||
void message.success('更新成功')
|
void message.success('更新成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getRole()
|
getRole()
|
||||||
@@ -410,9 +410,9 @@ const Role: React.FC = () => {
|
|||||||
...tableParams.filters
|
...tableParams.filters
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
const records = data.data?.records
|
const records = response.data?.records
|
||||||
|
|
||||||
records?.map((value) => {
|
records?.map((value) => {
|
||||||
value.tree = powerListToPowerTree(
|
value.tree = powerListToPowerTree(
|
||||||
@@ -426,12 +426,12 @@ const Role: React.FC = () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
records && setRoleData(records)
|
records && setRoleData(records)
|
||||||
data.data &&
|
response.data &&
|
||||||
setTableParams({
|
setTableParams({
|
||||||
...tableParams,
|
...tableParams,
|
||||||
pagination: {
|
pagination: {
|
||||||
...tableParams.pagination,
|
...tableParams.pagination,
|
||||||
total: data.data.total
|
total: response.data.total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -452,10 +452,10 @@ const Role: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_power_get_list()
|
void r_sys_power_get_list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
const powerSet = data.data
|
const powerSet = response.data
|
||||||
powerSet &&
|
powerSet &&
|
||||||
setPowerTreeData(
|
setPowerTreeData(
|
||||||
powerListToPowerTree(
|
powerListToPowerTree(
|
||||||
|
|||||||
@@ -290,9 +290,9 @@ const User: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_user_delete_list(tableSelectedItem)
|
void r_sys_user_delete_list(tableSelectedItem)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getUser()
|
getUser()
|
||||||
@@ -469,8 +469,8 @@ const User: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_user_delete(value.id)
|
void r_sys_user_delete(value.id)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_DELETE_SUCCESS) {
|
if (response.code === DATABASE_DELETE_SUCCESS) {
|
||||||
void message.success('删除成功')
|
void message.success('删除成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
getUser()
|
getUser()
|
||||||
@@ -514,8 +514,8 @@ const User: React.FC = () => {
|
|||||||
: undefined
|
: undefined
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_UPDATE_SUCCESS:
|
case DATABASE_UPDATE_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('更新成功')
|
void message.success('更新成功')
|
||||||
@@ -542,8 +542,8 @@ const User: React.FC = () => {
|
|||||||
: undefined
|
: undefined
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
switch (data.code) {
|
switch (response.code) {
|
||||||
case DATABASE_INSERT_SUCCESS:
|
case DATABASE_INSERT_SUCCESS:
|
||||||
setIsDrawerOpen(false)
|
setIsDrawerOpen(false)
|
||||||
void message.success('添加成功')
|
void message.success('添加成功')
|
||||||
@@ -633,17 +633,17 @@ const User: React.FC = () => {
|
|||||||
...tableParams.filters
|
...tableParams.filters
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
const records = data.data?.records
|
const records = response.data?.records
|
||||||
|
|
||||||
records && setUserData(records)
|
records && setUserData(records)
|
||||||
data.data &&
|
response.data &&
|
||||||
setTableParams({
|
setTableParams({
|
||||||
...tableParams,
|
...tableParams,
|
||||||
pagination: {
|
pagination: {
|
||||||
...tableParams.pagination,
|
...tableParams.pagination,
|
||||||
total: data.data.total
|
total: response.data.total
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
@@ -669,10 +669,10 @@ const User: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_role_get_list()
|
void r_sys_role_get_list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
data.data && setRoleData(data.data)
|
response.data && setRoleData(response.data)
|
||||||
} else {
|
} else {
|
||||||
void message.error('获取角色列表失败,请稍后重试')
|
void message.error('获取角色列表失败,请稍后重试')
|
||||||
}
|
}
|
||||||
@@ -691,10 +691,10 @@ const User: React.FC = () => {
|
|||||||
|
|
||||||
void r_sys_group_get_list()
|
void r_sys_group_get_list()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
const data = res.data
|
const response = res.data
|
||||||
|
|
||||||
if (data.code === DATABASE_SELECT_SUCCESS) {
|
if (response.code === DATABASE_SELECT_SUCCESS) {
|
||||||
data.data && setGroupData(data.data)
|
response.data && setGroupData(response.data)
|
||||||
} else {
|
} else {
|
||||||
void message.error('获取用户组列表失败,请稍后重试')
|
void message.error('获取用户组列表失败,请稍后重试')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user