# 系统架构 ## 整体架构 ``` ┌─────────────────────────────────────────────────────────────┐ │ 前端 (Vue 3) │ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │ │ Views │ │Components│ │ Stores │ │ API │ │ │ │ (页面) │ │ (组件) │ │ (状态) │ │ (请求) │ │ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │ │ └───────────┴───────────┴───────────┘ │ │ │ Axios HTTP │ └─────────────────────────┼───────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────┐ │ 后端 (FastAPI) │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ API Layer │ │ │ │ auth │ staff │ departments │ indicators │ ... │ │ │ └─────────────────────┬───────────────────────────────┘ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ Service Layer │ │ │ │ 业务逻辑处理、数据校验、事务管理 │ │ │ └─────────────────────┬───────────────────────────────┘ │ │ ▼ │ │ ┌─────────────────────────────────────────────────────┐ │ │ │ ORM Layer │ │ │ │ SQLAlchemy 2.0 (async) + Pydantic v2 │ │ │ └─────────────────────┬───────────────────────────────┘ │ └────────────────────────┼────────────────────────────────────┘ ▼ ┌─────────────────────────────────────────────────────────────┐ │ 数据库 (PostgreSQL) │ │ departments │ staff │ indicators │ assessments │ ... │ └─────────────────────────────────────────────────────────────┘ ``` ## 目录结构 ``` hospital-performance/ ├── backend/ # 后端服务 │ ├── app/ │ │ ├── api/v1/ # API路由层 │ │ │ ├── auth.py # 认证接口 │ │ │ ├── staff.py # 员工管理 │ │ │ ├── departments.py # 科室管理 │ │ │ ├── indicators.py # 指标管理 │ │ │ ├── assessments.py # 考核管理 │ │ │ ├── salary.py # 工资核算 │ │ │ └── stats.py # 统计报表 │ │ ├── core/ # 核心模块 │ │ │ ├── config.py # 配置管理 │ │ │ ├── database.py # 数据库连接 │ │ │ ├── security.py # 安全认证 │ │ │ └── init_db.py # 数据库初始化 │ │ ├── models/ # ORM模型 │ │ │ └── models.py # 数据表定义 │ │ ├── schemas/ # Pydantic模式 │ │ │ └── schemas.py # 请求/响应模式 │ │ ├── services/ # 业务逻辑层 │ │ │ ├── staff_service.py │ │ │ ├── department_service.py │ │ │ ├── indicator_service.py │ │ │ ├── assessment_service.py │ │ │ ├── salary_service.py │ │ │ └── stats_service.py │ │ ├── utils/ # 工具函数 │ │ └── main.py # 应用入口 │ ├── alembic/ # 数据库迁移 │ └── requirements.txt │ ├── frontend/ # 前端应用 │ ├── src/ │ │ ├── api/ # API请求 │ │ │ ├── request.js # Axios封装 │ │ │ ├── auth.js │ │ │ ├── staff.js │ │ │ ├── department.js │ │ │ ├── indicator.js │ │ │ ├── assessment.js │ │ │ ├── salary.js │ │ │ └── stats.js │ │ ├── stores/ # Pinia状态 │ │ │ ├── user.js # 用户状态 │ │ │ └── app.js # 应用状态 │ │ ├── router/ # 路由配置 │ │ │ └── index.js │ │ ├── views/ # 页面组件 │ │ │ ├── Login.vue # 登录页 │ │ │ ├── Layout.vue # 布局框架 │ │ │ ├── Dashboard.vue # 工作台 │ │ │ ├── basic/ # 基础数据 │ │ │ │ ├── Departments.vue │ │ │ │ ├── Staff.vue │ │ │ │ └── Indicators.vue │ │ │ ├── assessment/ # 考核管理 │ │ │ │ ├── Assessments.vue │ │ │ │ └── AssessmentDetail.vue │ │ │ ├── salary/ # 工资核算 │ │ │ │ └── Salary.vue │ │ │ └── reports/ # 统计报表 │ │ │ └── Reports.vue │ │ ├── components/ # 通用组件 │ │ ├── assets/ # 静态资源 │ │ ├── App.vue │ │ └── main.js │ └── package.json │ ├── docs/ # 项目文档 │ ├── index.md │ ├── architecture.md │ ├── database.md │ ├── api.md │ ├── frontend.md │ ├── backend.md │ └── deployment.md │ ├── AGENTS.md # AI编码助手指南 └── README.md # 项目说明 ``` ## 分层架构 ### API Layer (路由层) - 负责HTTP请求处理 - 参数校验(通过Pydantic) - 调用Service层处理业务 - 返回标准化响应 ### Service Layer (业务层) - 封装业务逻辑 - 数据库CRUD操作 - 事务管理 - 业务规则校验 ### ORM Layer (数据层) - SQLAlchemy模型定义 - 数据库表映射 - 关系定义 ## 认证流程 ``` ┌──────────┐ POST /auth/login ┌──────────┐ │ Client │ ───────────────────────▶ │ Server │ └──────────┘ └──────────┘ │ │ │ 验证用户名密码 │ │ 生成JWT Token │ │ │ │◀───────── { access_token } ─────────│ │ │ │ GET /staff (Authorization: Bearer token) │─────────────────────────────────────▶│ │ │ │ 验证Token │ │ 返回数据 │ │◀───────── { data: [...] } ──────────│ ``` ## 数据流 ### 考核流程 ``` 创建考核 → 填写指标得分 → 提交审核 → 审核通过 → 确认生效 → 生成工资 │ │ │ │ │ DRAFT DRAFT SUBMITTED REVIEWED FINALIZED ``` ### 工资计算 ``` 考核确认(FINALIZED) → 读取绩效得分 → 应用绩效系数 → 计算绩效奖金 → 生成工资记录 ```