```mermaid
---
title: 0.权限设置流程
---
flowchart TD
    Start((开始))
    --> Login[使用超级管理员或有权限的平台账号登录]

    Login --> HasPermission{是否具备角色与权限管理权限?}
    HasPermission -->|否| NoPermission[无权限，流程终止]
    HasPermission -->|是| EnterRolePage[进入角色与权限管理]

    subgraph RoleDesignFlow[角色设计]
        EnterRolePage --> SelectRoleType{选择角色类型}
        SelectRoleType -->|平台角色| FillPlatformRole[填写平台角色信息]
        SelectRoleType -->|代理角色| FillAgentRole[填写代理角色信息]

        FillPlatformRole --> SetPermissionScope[设置角色可用功能范围]
        FillAgentRole --> SetPermissionScope

        SetPermissionScope --> SaveRole[保存角色设置]
        SaveRole --> RoleSaveResult{角色保存是否成功?}
        RoleSaveResult -->|否| FixRoleData[修正角色信息后重试]
        FixRoleData --> SelectRoleType
        RoleSaveResult -->|是| BindRoleStart[进入账号绑定]
    end

    subgraph BindAndVerifyFlow[账号绑定与验收]
        BindRoleStart --> SelectAccount[选择需要生效的账号]
        SelectAccount --> BindRole[为账号绑定角色]
        BindRole --> VerifyLogin[使用该账号登录并核对可见功能]
        VerifyLogin --> VerifyScope[核对权限范围与业务数据范围]
        VerifyScope --> VerifyResult{验收是否通过?}

        VerifyResult -->|否| HandleException[记录异常并返回权限管理处理]
        HandleException --> EnterRolePage
        VerifyResult -->|是| End([流程结束])
    end

    %% ==================== 样式美化 ====================
    style Start fill:#90EE90,stroke:#2E7D32,stroke-width:2px
    style End fill:#FF9999,stroke:#C62828,stroke-width:2px
    style NoPermission fill:#FFCDD2,stroke:#D32F2F
    style FixRoleData fill:#FFCCBC,stroke:#E64A19
    style HandleException fill:#FFCCBC,stroke:#E64A19

    classDef decision fill:#FFF3E0,stroke:#F57C00,stroke-width:2px
    class HasPermission,SelectRoleType,RoleSaveResult,VerifyResult decision
```
