fix: 全局权限优化 — 7 项问题修复

1. 菜单权限修复:补充 10 个菜单的 permission 字段 + 修复 menu_service
   回退逻辑(admin 直接跳过过滤,非 admin 无关联则不显示)+ 收紧前端过滤
2. 管理员重置密码:新增 POST /users/{id}/reset-password 端点 + 前端按钮
3. 告警处理人姓名:AlertResponse 添加 acknowledged_by_name 字段
4. Tab 权限过滤:PatientDetail 6 个 Tab 按权限过滤 + 状态字段 Tooltip
5. 消息中心 UI:添加 Popconfirm/AuthButton,移除 inline isDark
This commit is contained in:
iven
2026-05-15 19:00:48 +08:00
parent 9319203e09
commit 8763e10d6e
17 changed files with 451 additions and 69 deletions

View File

@@ -1,9 +1,9 @@
import { useEffect, useState, useCallback } from 'react';
import { Table, Button, Modal, Form, Input, Select, message, Tag } from 'antd';
import { Table, Button, Modal, Form, Input, Select, message, Tag, Card } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import { listTemplates, createTemplate, type MessageTemplateInfo } from '../../api/messageTemplates';
import { useThemeMode } from '../../hooks/useThemeMode';
import { AuthButton } from '../../components/AuthButton';
const channelMap: Record<string, { label: string; color: string }> = {
in_app: { label: '站内', color: '#2563eb' },
@@ -19,7 +19,6 @@ export default function MessageTemplates() {
const [loading, setLoading] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const [form] = Form.useForm();
const isDark = useThemeMode();
const fetchData = useCallback(async (p = page) => {
setLoading(true);
@@ -64,9 +63,9 @@ export default function MessageTemplates() {
key: 'code',
render: (v: string) => (
<Tag style={{
background: isDark ? '#0f172a' : '#f8fafc',
background: 'var(--ant-color-fill-quaternary)',
border: 'none',
color: isDark ? '#94a3b8' : '#475569',
color: 'var(--ant-color-text-secondary)',
fontFamily: 'monospace',
fontSize: 12,
}}>
@@ -111,7 +110,7 @@ export default function MessageTemplates() {
key: 'created_at',
width: 180,
render: (v: string) => (
<span style={{ color: isDark ? '#475569' : '#94a3b8', fontSize: 13 }}>{v}</span>
<span style={{ color: 'var(--ant-color-text-secondary)', fontSize: 13 }}>{v}</span>
),
},
];
@@ -124,20 +123,17 @@ export default function MessageTemplates() {
alignItems: 'center',
marginBottom: 16,
}}>
<span style={{ fontSize: 13, color: isDark ? '#475569' : '#94a3b8' }}>
<span style={{ fontSize: 13, color: 'var(--ant-color-text-secondary)' }}>
{total}
</span>
<Button type="primary" icon={<PlusOutlined />} onClick={() => setModalOpen(true)}>
</Button>
<AuthButton code="message.manage">
<Button type="primary" icon={<PlusOutlined />} onClick={() => setModalOpen(true)}>
</Button>
</AuthButton>
</div>
<div style={{
background: isDark ? '#111827' : '#FFFFFF',
borderRadius: 12,
border: `1px solid ${isDark ? '#0f172a' : '#f8fafc'}`,
overflow: 'hidden',
}}>
<Card styles={{ body: { padding: 0 } }}>
<Table
columns={columns}
dataSource={data}
@@ -151,7 +147,7 @@ export default function MessageTemplates() {
showTotal: (t) => `${t} 条记录`,
}}
/>
</div>
</Card>
<Modal
title="新建消息模板"

View File

@@ -1,9 +1,9 @@
import { useEffect, useState, useMemo, useCallback, useRef } from 'react';
import { Table, Button, Tag, Space, Modal, Typography, message } from 'antd';
import { Table, Button, Tag, Space, Modal, Typography, Popconfirm, Card, message } from 'antd';
import { CheckOutlined, DeleteOutlined, EyeOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import { listMessages, markRead, markAllRead, deleteMessage, type MessageInfo, type MessageQuery } from '../../api/messages';
import { useThemeMode } from '../../hooks/useThemeMode';
import { AuthButton } from '../../components/AuthButton';
const { Paragraph } = Typography;
@@ -32,7 +32,6 @@ export default function NotificationList({ queryFilter }: Props) {
const [total, setTotal] = useState(0);
const [page, setPage] = useState(1);
const [loading, setLoading] = useState(false);
const isDark = useThemeMode();
const fetchData = useCallback(async (p = page, filter?: MessageQuery) => {
setLoading(true);
@@ -93,7 +92,7 @@ export default function NotificationList({ queryFilter }: Props) {
content: (
<div>
<Paragraph>{record.body}</Paragraph>
<div style={{ marginTop: 8, color: isDark ? '#475569' : '#94a3b8', fontSize: 12 }}>
<div style={{ marginTop: 8, color: 'var(--ant-color-text-secondary)', fontSize: 12 }}>
{formatDateTime(record.created_at)}
</div>
</div>
@@ -114,7 +113,7 @@ export default function NotificationList({ queryFilter }: Props) {
style={{
fontWeight: record.is_read ? 400 : 600,
cursor: 'pointer',
color: record.is_read ? (isDark ? '#94a3b8' : '#475569') : 'inherit',
color: record.is_read ? 'var(--ant-color-text-secondary)' : 'inherit',
}}
onClick={() => showDetail(record)}
>
@@ -156,7 +155,7 @@ export default function NotificationList({ queryFilter }: Props) {
dataIndex: 'sender_type',
key: 'sender_type',
width: 80,
render: (s: string) => <span style={{ color: isDark ? '#475569' : '#94a3b8' }}>{s === 'system' ? '系统' : '用户'}</span>,
render: (s: string) => <span style={{ color: 'var(--ant-color-text-secondary)' }}>{s === 'system' ? '系统' : '用户'}</span>,
},
{
title: '状态',
@@ -165,9 +164,9 @@ export default function NotificationList({ queryFilter }: Props) {
width: 80,
render: (r: boolean) => (
<Tag style={{
background: r ? (isDark ? '#0f172a' : '#f8fafc') : '#eff6ff',
background: r ? 'var(--ant-color-fill-quaternary)' : '#eff6ff',
border: 'none',
color: r ? (isDark ? '#475569' : '#94a3b8') : '#2563eb',
color: r ? 'var(--ant-color-text-secondary)' : '#2563eb',
fontWeight: 500,
}}>
{r ? '已读' : '未读'}
@@ -180,7 +179,7 @@ export default function NotificationList({ queryFilter }: Props) {
key: 'created_at',
width: 180,
render: (v: string) => (
<span style={{ color: isDark ? '#475569' : '#94a3b8', fontSize: 13 }}>{formatDateTime(v)}</span>
<span style={{ color: 'var(--ant-color-text-secondary)', fontSize: 13 }}>{formatDateTime(v)}</span>
),
},
{
@@ -203,15 +202,21 @@ export default function NotificationList({ queryFilter }: Props) {
size="small"
icon={<EyeOutlined />}
onClick={() => showDetail(record)}
style={{ color: isDark ? '#475569' : '#94a3b8' }}
/>
<Button
type="text"
size="small"
danger
icon={<DeleteOutlined />}
onClick={() => handleDelete(record.id)}
style={{ color: 'var(--ant-color-text-secondary)' }}
/>
<AuthButton code="message.manage">
<Popconfirm
title="确定删除此消息?"
onConfirm={() => handleDelete(record.id)}
>
<Button
type="text"
size="small"
danger
icon={<DeleteOutlined />}
/>
</Popconfirm>
</AuthButton>
</Space>
),
},
@@ -225,20 +230,17 @@ export default function NotificationList({ queryFilter }: Props) {
alignItems: 'center',
marginBottom: 16,
}}>
<span style={{ fontSize: 13, color: isDark ? '#475569' : '#94a3b8' }}>
<span style={{ fontSize: 13, color: 'var(--ant-color-text-secondary)' }}>
{total}
</span>
<Button icon={<CheckOutlined />} onClick={handleMarkAllRead}>
</Button>
<AuthButton code="message.manage">
<Button icon={<CheckOutlined />} onClick={handleMarkAllRead}>
</Button>
</AuthButton>
</div>
<div style={{
background: isDark ? '#111827' : '#FFFFFF',
borderRadius: 12,
border: `1px solid ${isDark ? '#0f172a' : '#f8fafc'}`,
overflow: 'hidden',
}}>
<Card styles={{ body: { padding: 0 } }}>
<Table
columns={columns}
dataSource={data}
@@ -252,7 +254,7 @@ export default function NotificationList({ queryFilter }: Props) {
showTotal: (t) => `${t} 条记录`,
}}
/>
</div>
</Card>
</div>
);
}