fix: 修复仪表盘用户数统计和岗位筛选问题
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
1. 后端 admin.py: - 用户总数统计添加 is_deleted=False, is_active=True 过滤 - 现在只统计有效的活跃用户数 2. 前端 user-management.vue: - 岗位筛选从硬编码改为动态加载 positionOptions - 岗位列表从API获取,而不是写死的4个选项
This commit is contained in:
@@ -34,8 +34,11 @@ async def get_dashboard_stats(
|
|||||||
message="权限不足,需要管理员权限"
|
message="权限不足,需要管理员权限"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 用户统计
|
# 用户统计 - 只统计未删除且活跃的用户
|
||||||
total_users = await db.scalar(select(func.count(User.id)))
|
total_users = await db.scalar(
|
||||||
|
select(func.count(User.id))
|
||||||
|
.where(User.is_deleted == False, User.is_active == True)
|
||||||
|
)
|
||||||
|
|
||||||
# 计算最近30天的新增用户
|
# 计算最近30天的新增用户
|
||||||
thirty_days_ago = datetime.now() - timedelta(days=30)
|
thirty_days_ago = datetime.now() - timedelta(days=30)
|
||||||
|
|||||||
@@ -63,12 +63,14 @@
|
|||||||
placeholder="全部岗位"
|
placeholder="全部岗位"
|
||||||
clearable
|
clearable
|
||||||
@change="handleRealTimeSearch"
|
@change="handleRealTimeSearch"
|
||||||
style="width: 120px"
|
style="width: 150px"
|
||||||
>
|
>
|
||||||
<el-option label="销售专员" value="sales" />
|
<el-option
|
||||||
<el-option label="销售主管" value="sales_manager" />
|
v-for="p in positionOptions"
|
||||||
<el-option label="客服专员" value="service" />
|
:key="p.id"
|
||||||
<el-option label="技术支持" value="tech" />
|
:label="p.name"
|
||||||
|
:value="p.id"
|
||||||
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
|
|||||||
Reference in New Issue
Block a user