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

@@ -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;

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) => {
try {
const role = await listUserRole({roleId: 1701, userId: item.userId}) const role = await listUserRole({roleId: 1701, userId: item.userId})
const userRole = role[0]; const userRole = role[0]
// 审核通过
updateUserVerify({ // 审核通过 - 先更新实名认证状态
await updateUserVerify({
...item, ...item,
status: 1 status: 1
}).then(() => { })
// 再更新用户角色(如果存在对应角色)
if (userRole) { if (userRole) {
updateUserRole({ await updateUserRole({
...userRole, ...userRole,
roleId: 1738 roleId: 1738
}) })
} }
Taro.showToast({ Taro.showToast({
title: '操作成功', title: '操作成功',
icon: 'success' icon: 'success'
}) })
reload().then() 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) => {
try {
const role = await listUserRole({roleId: 1738, userId: item.userId}) const role = await listUserRole({roleId: 1738, userId: item.userId})
const userRole = role[0]; const userRole = role[0]
// 审核驳回 - 先恢复用户角色(如果存在)
if (userRole) { if (userRole) {
userRole.roleId = 1701; userRole.roleId = 1701
updateUserRole(userRole).then(() => { await updateUserRole(userRole)
updateUserVerify({ }
await updateUserVerify({
...item, ...item,
status: 2 status: 2
}).then(() => { })
Taro.showToast({ Taro.showToast({
title: '操作成功', title: '操作成功',
icon: 'success' icon: 'success'
}) })
reload().then() 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>