feat(全局概览): 人员操作统计改为快捷入口内入口+抽屉弹窗展示

- 位置调整:快捷入口面板内新增「人员操作统计」入口按钮(替代整行区域)
- 点击打开抽屉,展示全部人员操作次数
- 支持人员下拉选择:默认全部,可选某一人查看
- 跟随顶部时间筛选联动
This commit is contained in:
2026-08-28 13:19:45 +08:00
parent 72fbb8b501
commit 9471c1b7c5

View File

@ -4,7 +4,7 @@ import {
RefreshCw, Loader2, AlertCircle, ArrowRight, Clock, MessageCircle, CheckCircle2, Users,
} from "lucide-react";
import { useNavigate } from "react-router-dom";
import { Radio, DatePicker, Drawer, Input } from "antd";
import { Radio, DatePicker, Drawer, Input, Select } from "antd";
import dayjs, { type Dayjs } from "dayjs";
import {
fetchDashboardStats, fetchWipTasks, fetchDashboardMessages, fetchCompletedTasks, fetchRejectedTasks, fetchUserOperations,
@ -269,9 +269,11 @@ export default function AdminDashboard() {
const [rejectedTasks, setRejectedTasks] = useState<RejectedTask[]>([]);
const [rejectedLoading, setRejectedLoading] = useState(false);
// 人员操作统计
// 人员操作统计(抽屉)
const [opsDrawerOpen, setOpsDrawerOpen] = useState(false);
const [opStats, setOpStats] = useState<UserOperation[]>([]);
const [opLoading, setOpLoading] = useState(false);
const [opFilterUser, setOpFilterUser] = useState<string>(""); // 人员选择,'' = 全部
const navigate = useNavigate();
@ -327,7 +329,7 @@ export default function AdminDashboard() {
.finally(() => setRejectedLoading(false));
};
// 人员操作统计 — 跟随顶部时间筛选
// 人员操作统计 — 跟随顶部时间筛选(打开抽屉时加载)
const loadUserOperations = useCallback(() => {
setOpLoading(true);
const { since, until } = rangeToParams(dateKey, customRange);
@ -337,7 +339,11 @@ export default function AdminDashboard() {
.finally(() => setOpLoading(false));
}, [dateKey, customRange]);
useEffect(() => { loadUserOperations(); }, [loadUserOperations]);
const openOpsDrawer = () => {
setOpsDrawerOpen(true);
setOpFilterUser("");
loadUserOperations();
};
const onMsgSearch = (value: string) => {
setMsgKeyword(value);
@ -540,54 +546,15 @@ export default function AdminDashboard() {
className="flex w-full items-center justify-between rounded-lg bg-purple-50 px-4 py-3 text-left text-sm font-medium text-purple-700 hover:bg-purple-100 transition-colors">
<span>💬 </span><ArrowRight className="h-4 w-4" />
</button>
{/* 👥 人员操作统计入口 */}
<button onClick={openOpsDrawer}
className="flex w-full items-center justify-between rounded-lg bg-indigo-50 px-4 py-3 text-left text-sm font-medium text-indigo-700 hover:bg-indigo-100 transition-colors">
<span className="flex items-center gap-1.5"><Users className="h-4 w-4" /></span><ArrowRight className="h-4 w-4" />
</button>
</div>
</div>
</div>
{/* ═══ 人员操作统计 ═══ */}
<div className="rounded-xl bg-white p-5 shadow-sm">
<div className="mb-3 flex items-center justify-between">
<h3 className="flex items-center gap-2 text-sm font-semibold text-gray-700">
<Users className="h-4 w-4 text-blue-500" /> 👥
</h3>
<span className="text-[11px] text-gray-400"> / / · </span>
</div>
{opLoading ? (
<div className="flex items-center justify-center py-12">
<Loader2 className="h-6 w-6 animate-spin text-blue-500" />
</div>
) : opStats.length === 0 ? (
<div className="py-12 text-center text-sm text-gray-400"></div>
) : (
<div className="overflow-x-auto">
<table className="w-full text-left text-sm">
<thead>
<tr className="border-b border-gray-100 text-xs text-gray-400">
<th className="py-2 pr-3 font-medium">#</th>
<th className="py-2 pr-3 font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 text-right font-medium"></th>
</tr>
</thead>
<tbody>
{opStats.map((u, idx) => (
<tr key={u.user_id} className="border-b border-gray-50 last:border-0 hover:bg-gray-50/50">
<td className="py-2 pr-3 text-xs text-gray-400">{idx + 1}</td>
<td className="py-2 pr-3 font-medium text-gray-800">{u.user_name}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.receive_count}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.transfer_count}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.record_count}</td>
<td className="py-2 text-right font-bold text-blue-600">{u.total}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
{/* ═══ 留言抽屉 ═══ */}
<Drawer
title={<span className="text-base font-bold">💬 <span className="font-normal text-gray-400"> · {msgTotal} </span></span>}
@ -707,6 +674,65 @@ export default function AdminDashboard() {
</div>
)}
</Drawer>
{/* ═══ 人员操作统计抽屉 ═══ */}
<Drawer
title={<span className="text-base font-bold">👥 <span className="font-normal text-gray-400">{opStats.length} </span></span>}
open={opsDrawerOpen}
onClose={() => setOpsDrawerOpen(false)}
size="large"
styles={{ body: { padding: 16, background: "#f8fafc" } }}
>
{/* 人员选择 */}
<div className="mb-4 flex items-center gap-2">
<Select
style={{ width: 200 }}
placeholder="选择人员(默认全部)"
value={opFilterUser || undefined}
onChange={setOpFilterUser}
allowClear
options={opStats.map(u => ({ value: u.user_id, label: u.user_name }))}
showSearch
optionFilterProp="label"
/>
<span className="text-xs text-gray-400"> / / · </span>
</div>
{opLoading ? (
<div className="flex items-center justify-center py-20">
<Loader2 className="h-6 w-6 animate-spin text-blue-500" />
</div>
) : opStats.length === 0 ? (
<div className="py-16 text-center text-sm text-gray-400"></div>
) : (
<div className="overflow-x-auto">
<table className="w-full text-left text-sm">
<thead>
<tr className="border-b border-gray-100 text-xs text-gray-400">
<th className="py-2 pr-3 font-medium">#</th>
<th className="py-2 pr-3 font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 pr-3 text-right font-medium"></th>
<th className="py-2 text-right font-medium"></th>
</tr>
</thead>
<tbody>
{(opFilterUser ? opStats.filter(u => u.user_id === opFilterUser) : opStats).map((u, idx) => (
<tr key={u.user_id} className="border-b border-gray-50 last:border-0 hover:bg-gray-50/50">
<td className="py-2 pr-3 text-xs text-gray-400">{idx + 1}</td>
<td className="py-2 pr-3 font-medium text-gray-800">{u.user_name}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.receive_count}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.transfer_count}</td>
<td className="py-2 pr-3 text-right text-gray-600">{u.record_count}</td>
<td className="py-2 text-right font-bold text-blue-600">{u.total}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</Drawer>
</div>
);
}