fix(user): 优化实名认证审核流程并修复权限控制问题
- 重构 onPass 和 onReject 方法,添加异常处理和 Promise 确保操作顺序 - 修复实名认证状态显示问题,当 statusText 为空时显示默认状态文本 - 更新权限检查逻辑,将固定存储检查改为角色权限动态验证 - 修复组织机构筛选逻辑,区分站点角色和商户角色的数据权限范围 - 添加商户角色的多组织机构查询支持,完善数据隔离机制
This commit is contained in:
@@ -47,7 +47,7 @@ const List = () => {
|
||||
// @ts-ignore
|
||||
where.driverId = user.userId;
|
||||
}
|
||||
if(roleCode == 'zhandian'){
|
||||
if(roleCode == 'zhandian' && user.merchants == null){
|
||||
// @ts-ignore
|
||||
where.organizationId = user.organizationId;
|
||||
}
|
||||
@@ -59,6 +59,10 @@ const List = () => {
|
||||
// @ts-ignore
|
||||
where.installerId = user.userId;
|
||||
}
|
||||
if(user.merchants != null){
|
||||
// @ts-ignore
|
||||
where.organizationIds = user.merchants;
|
||||
}
|
||||
if(roleCode == 'user'){
|
||||
setLoading(false)
|
||||
return false;
|
||||
|
||||
@@ -98,50 +98,71 @@ const UserVerifyAdmin: React.FC = () => {
|
||||
// 检查是否有特定角色
|
||||
const hasRole = (roleCode: string) => {
|
||||
if (!user || !user.roles) {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
return user.roles.some(role => role.roleCode === roleCode);
|
||||
};
|
||||
return user.roles.some(role => role.roleCode === roleCode)
|
||||
}
|
||||
|
||||
|
||||
const onPass = async (item: UserVerify) => {
|
||||
const role = await listUserRole({roleId: 1701,userId: item.userId})
|
||||
const userRole = role[0];
|
||||
// 审核通过
|
||||
updateUserVerify({
|
||||
...item,
|
||||
status: 1
|
||||
}).then(() => {
|
||||
if(userRole){
|
||||
updateUserRole({
|
||||
...userRole,
|
||||
roleId: 1738
|
||||
})
|
||||
}
|
||||
Taro.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success'
|
||||
})
|
||||
reload().then()
|
||||
try {
|
||||
const role = await listUserRole({roleId: 1701, userId: item.userId})
|
||||
const userRole = role[0]
|
||||
|
||||
// 审核通过 - 先更新实名认证状态
|
||||
await updateUserVerify({
|
||||
...item,
|
||||
status: 1
|
||||
})
|
||||
|
||||
// 再更新用户角色(如果存在对应角色)
|
||||
if (userRole) {
|
||||
await updateUserRole({
|
||||
...userRole,
|
||||
roleId: 1738
|
||||
})
|
||||
}
|
||||
|
||||
Taro.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success'
|
||||
})
|
||||
await reload(false)
|
||||
} catch (error: any) {
|
||||
console.error('审核通过失败:', error)
|
||||
Taro.showToast({
|
||||
title: error?.message || '操作失败',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onReject = async (item: UserVerify) => {
|
||||
const role = await listUserRole({roleId: 1738,userId: item.userId})
|
||||
const userRole = role[0];
|
||||
if(userRole){
|
||||
userRole.roleId = 1701;
|
||||
updateUserRole(userRole).then(() => {
|
||||
updateUserVerify({
|
||||
...item,
|
||||
status: 2
|
||||
}).then(() => {
|
||||
Taro.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success'
|
||||
})
|
||||
reload().then()
|
||||
})
|
||||
try {
|
||||
const role = await listUserRole({roleId: 1738, userId: item.userId})
|
||||
const userRole = role[0]
|
||||
|
||||
// 审核驳回 - 先恢复用户角色(如果存在)
|
||||
if (userRole) {
|
||||
userRole.roleId = 1701
|
||||
await updateUserRole(userRole)
|
||||
}
|
||||
|
||||
await updateUserVerify({
|
||||
...item,
|
||||
status: 2
|
||||
})
|
||||
|
||||
Taro.showToast({
|
||||
title: '操作成功',
|
||||
icon: 'success'
|
||||
})
|
||||
await reload(false)
|
||||
} catch (error: any) {
|
||||
console.error('审核驳回失败:', error)
|
||||
Taro.showToast({
|
||||
title: error?.message || '操作失败',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -297,7 +318,7 @@ const UserVerifyAdmin: React.FC = () => {
|
||||
fontSize: '12px'
|
||||
}}
|
||||
>
|
||||
{item.statusText}
|
||||
{item.statusText || statusDisplay.text}
|
||||
</Tag>
|
||||
</div>
|
||||
|
||||
@@ -317,7 +338,7 @@ const UserVerifyAdmin: React.FC = () => {
|
||||
}
|
||||
</div>
|
||||
)}
|
||||
{Taro.getStorageSync('kuaidi') && (
|
||||
{(hasRole('admin') || hasRole('kuaidi') || hasRole('zhandian')) && (
|
||||
<Space className={'pt-4 flex justify-end'}>
|
||||
<Button type="success" onClick={() => onPass(item)}>通过</Button>
|
||||
<Button type="warning" onClick={() => onReject(item)}>驳回</Button>
|
||||
|
||||
Reference in New Issue
Block a user