fix(user): 优化实名认证审核流程并修复权限控制问题

- 重构 onPass 和 onReject 方法,添加异常处理和 Promise 确保操作顺序
- 修复实名认证状态显示问题,当 statusText 为空时显示默认状态文本
- 更新权限检查逻辑,将固定存储检查改为角色权限动态验证
- 修复组织机构筛选逻辑,区分站点角色和商户角色的数据权限范围
- 添加商户角色的多组织机构查询支持,完善数据隔离机制
This commit is contained in:
2026-01-13 15:29:12 +08:00
parent c250f2ae5e
commit 96b75c6cab
2 changed files with 66 additions and 41 deletions

View File

@@ -33,7 +33,7 @@ const List = () => {
const loadList = async (pageNum: number, isRefresh = false) => { const loadList = async (pageNum: number, isRefresh = false) => {
if (loading) return; if (loading) return;
setLoading(true) setLoading(true)
// 搜索条件 // 搜索条件
const where = {status: 1, deleted: 0, keywords, page: pageNum, limit: 10} const where = {status: 1, deleted: 0, keywords, page: pageNum, limit: 10}
@@ -47,7 +47,7 @@ const List = () => {
// @ts-ignore // @ts-ignore
where.driverId = user.userId; where.driverId = user.userId;
} }
if(roleCode == 'zhandian'){ if(roleCode == 'zhandian' && user.merchants == null){
// @ts-ignore // @ts-ignore
where.organizationId = user.organizationId; where.organizationId = user.organizationId;
} }
@@ -59,6 +59,10 @@ const List = () => {
// @ts-ignore // @ts-ignore
where.installerId = user.userId; where.installerId = user.userId;
} }
if(user.merchants != null){
// @ts-ignore
where.organizationIds = user.merchants;
}
if(roleCode == 'user'){ if(roleCode == 'user'){
setLoading(false) setLoading(false)
return false; return false;
@@ -152,4 +156,4 @@ const List = () => {
</> </>
) )
} }
export default List export default List

View File

@@ -98,50 +98,71 @@ const UserVerifyAdmin: React.FC = () => {
// 检查是否有特定角色 // 检查是否有特定角色
const hasRole = (roleCode: string) => { const hasRole = (roleCode: string) => {
if (!user || !user.roles) { 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 onPass = async (item: UserVerify) => {
const role = await listUserRole({roleId: 1701,userId: item.userId}) try {
const userRole = role[0]; const role = await listUserRole({roleId: 1701, userId: item.userId})
// 审核通过 const userRole = role[0]
updateUserVerify({
...item, // 审核通过 - 先更新实名认证状态
status: 1 await updateUserVerify({
}).then(() => { ...item,
if(userRole){ status: 1
updateUserRole({ })
...userRole,
roleId: 1738 // 再更新用户角色(如果存在对应角色)
}) if (userRole) {
} await updateUserRole({
Taro.showToast({ ...userRole,
title: '操作成功', roleId: 1738
icon: 'success'
})
reload().then()
}) })
}
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 onReject = async (item: UserVerify) => {
const role = await listUserRole({roleId: 1738,userId: item.userId}) try {
const userRole = role[0]; const role = await listUserRole({roleId: 1738, userId: item.userId})
if(userRole){ const userRole = role[0]
userRole.roleId = 1701;
updateUserRole(userRole).then(() => { // 审核驳回 - 先恢复用户角色(如果存在)
updateUserVerify({ if (userRole) {
...item, userRole.roleId = 1701
status: 2 await updateUserRole(userRole)
}).then(() => { }
Taro.showToast({
title: '操作成功', await updateUserVerify({
icon: 'success' ...item,
}) status: 2
reload().then() })
})
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' fontSize: '12px'
}} }}
> >
{item.statusText} {item.statusText || statusDisplay.text}
</Tag> </Tag>
</div> </div>
@@ -317,7 +338,7 @@ const UserVerifyAdmin: React.FC = () => {
} }
</div> </div>
)} )}
{Taro.getStorageSync('kuaidi') && ( {(hasRole('admin') || hasRole('kuaidi') || hasRole('zhandian')) && (
<Space className={'pt-4 flex justify-end'}> <Space className={'pt-4 flex justify-end'}>
<Button type="success" onClick={() => onPass(item)}></Button> <Button type="success" onClick={() => onPass(item)}></Button>
<Button type="warning" onClick={() => onReject(item)}></Button> <Button type="warning" onClick={() => onReject(item)}></Button>