提交文件

This commit is contained in:
2026-02-28 15:16:15 +08:00
parent 1a4e50e0a4
commit 44f250f58e
159 changed files with 61268 additions and 0 deletions

131
FIX_SUMMARY.md Normal file
View File

@@ -0,0 +1,131 @@
# 前端报错修复总结
## 已修复问题
### 1. Dashboard 趋势数据加载失败 ✅
**错误信息**:
```
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
Dashboard.vue:368 加载趋势失败 AxiosError: Request failed with status code 500
```
**原因**:
- 前端发送参数:`months=6`
- 后端 API 要求必需参数:`period_year` (必需)
- 参数不匹配导致 500 错误
**修复内容**:
1. 更新后端 API (`backend/app/api/v1/stats.py`):
- 使 `period_year` 变为可选参数
- 添加 `months` 参数(默认 6 个月)
- 自动使用当前年份如果未指定
2. 更新后端服务 (`backend/app/services/stats_service.py`):
- 支持查询最近 N 个月的数据
- 处理跨年份查询逻辑
**API 现在接受的参数**:
```
GET /api/v1/stats/trend?months=6
GET /api/v1/stats/trend?period_year=2026&months=12
GET /api/v1/stats/trend?department_id=1&months=6
```
### 2. 科室类型枚举不匹配 ✅
**之前问题**: 500 错误 - `'clinical' is not among the defined enum values`
**修复**:
- 更新 `init_db.py` 使用新的科室类型枚举
- 修复 `schemas.py` 中的重复定义
- 重建数据库
## 当前系统状态
### ✅ 所有核心功能正常
| 功能模块 | 状态 | 说明 |
|----------|------|------|
| 健康检查 | ✅ | `/health` |
| 用户认证 | ✅ | 登录/登出 |
| 科室管理 | ✅ | CRUD 操作 |
| 员工管理 | ✅ | CRUD 操作 |
| 指标管理 | ✅ | 含 BSC 维度 |
| 考核流程 | ✅ | 提交/审核/确认 |
| 统计报表 | ✅ | BSC/科室/趋势/排名 |
| 工资管理 | ✅ | 查询/计算 |
### 访问信息
- **前端**: http://localhost:5173
- **后端**: http://localhost:8000
- **API 文档**: http://localhost:8000/api/v1/docs
### 默认账号
- 用户名:`admin`
- 密码:`admin123`
## 测试建议
### 1. 清除浏览器缓存
```
Ctrl + Shift + Delete
勾选:缓存的图片和文件
点击:清除数据
```
### 2. 硬刷新页面
```
Ctrl + F5
```
### 3. 清除 localStorage
在浏览器控制台执行:
```javascript
localStorage.clear()
```
### 4. 测试页面
访问内置测试页面验证所有 API:
http://localhost:5173/test-api.html
## 如果仍有问题
### 查看具体错误
1. 打开浏览器开发者工具F12
2. 切换到 Console 标签
3. 查看具体错误信息
4. 切换到 Network 标签
5. 找到失败的请求(红色)
6. 查看 Response 内容
### 常见错误处理
**401 Unauthorized**
- 登录已过期,请重新登录
- 清除 localStorage 后刷新页面
**403 Forbidden**
- 没有权限访问
- 检查用户角色
**404 Not Found**
- 资源不存在
- 检查 URL 是否正确
**500 Internal Server Error**
- 服务器错误
- 查看后端日志:`backend/logs/error_*.log`
- 报告具体错误信息
## 日志位置
- **应用日志**: `backend/logs/app_YYYYMMDD.log`
- **错误日志**: `backend/logs/error_YYYYMMDD.log`
## 联系支持
提供以下信息以便快速定位问题:
1. F12 控制台错误截图
2. Network 标签中失败请求的响应
3. 后端日志相关内容