fix: align permission navigation and page access

This commit is contained in:
2026-07-11 14:55:49 +08:00
parent 1e1c476bc3
commit b6fca99390
27 changed files with 434 additions and 49 deletions

View File

@@ -21,6 +21,7 @@ import api from '../../api';
import { maskPhone, maskIdNumber } from '../../utils/sensitive';
import PermissionButton from '../../components/PermissionButton';
import { message } from '../../ui/app-message';
import { usePermission } from '../../hooks/usePermission';
const statusMap: Record<string, { text: string; color: string }> = {
paid: { text: '已缴', color: 'green' },
@@ -51,6 +52,7 @@ interface PendingRefund {
}
const DepositsPage: React.FC = () => {
const { hasPermission } = usePermission();
const [data, setData] = useState<any[]>([]);
const [students, setStudents] = useState<any[]>([]);
const [loading, setLoading] = useState(false);
@@ -73,7 +75,10 @@ const DepositsPage: React.FC = () => {
const fetchData = async () => {
setLoading(true);
try {
const [d, s]: any[] = await Promise.all([api.get('/deposits'), api.get('/students')]);
const [d, s]: any[] = await Promise.all([
api.get('/deposits'),
hasPermission('deposit:create') ? api.get('/deposits/student-lookups') : Promise.resolve([]),
]);
setData(d);
setStudents(s);
} catch (e: any) {
@@ -95,7 +100,7 @@ const DepositsPage: React.FC = () => {
useEffect(() => {
fetchData();
}, []);
}, [hasPermission]);
const filteredData = useMemo(() => {
return data.filter((d: any) => {
@@ -444,20 +449,22 @@ const DepositsPage: React.FC = () => {
</>
),
},
{
key: 'pending',
label: '待审批退款',
children: (
<Table
columns={pendingColumns}
dataSource={pendingRefunds}
rowKey="id"
loading={pendingLoading}
scroll={{ x: 1200 }}
pagination={{ pageSize: 15, showTotal: (total) => `${total}` }}
/>
),
},
...(hasPermission('deposit:approve')
? [{
key: 'pending',
label: '待审批退款',
children: (
<Table
columns={pendingColumns}
dataSource={pendingRefunds}
rowKey="id"
loading={pendingLoading}
scroll={{ x: 1200 }}
pagination={{ pageSize: 15, showTotal: (total) => `${total}` }}
/>
),
}]
: []),
]}
/>