fix: 审批流程三个bug修复
1. 点通过不再重复创建审批记录(后端无NULL记录时返回400而非自动创建) 2. 非提交人不再显示撤销按钮(列表页增加applicant_id校验) 3. 已审批工单不再显示通过/拒绝按钮(is_approver只计算pending记录) 4. 前端审批失败时弹出错误提示而非静默忽略
This commit is contained in:
1 parent
3a6dd99633
commit
74748e4914
2 files changed
+19
-21
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
ArrowUpDown, Ban, ChevronLeft, AlertTriangle,
|
||||
} from 'lucide-react';
|
||||
import { statusMap, statusColorMap, dbTypeColorMap } from '@/lib/constants';
|
||||
import { useActionPermission } from '@/hooks/useAuth';
|
||||
import { useActionPermission, useAuth } from '@/hooks/useAuth';
|
||||
import PageHeader from '@/components/PageHeader';
|
||||
import EmptyState from '@/components/EmptyState';
|
||||
import { ticketApi } from '@/api/ticket';
|
||||
@@ -190,6 +190,7 @@ function TableRowSkeleton() {
|
||||
/* ------------------------------------------------------------------ */
|
||||
export default function TicketsPage() {
|
||||
const navigate = useNavigate();
|
||||
const { user: currentUser } = useAuth();
|
||||
const canCreate = useActionPermission('ticket.create');
|
||||
const canApprove = useActionPermission('ticket.approve');
|
||||
const canExecute = useActionPermission('ticket.execute');
|
||||
@@ -455,7 +456,10 @@ export default function TicketsPage() {
|
||||
try {
|
||||
await ticketApi.review(ticket.id, { action: 'approve', comment: '通过' });
|
||||
fetchTickets(); fetchStats();
|
||||
} catch { /* ignore */ }
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.detail || e?.message || '审批失败';
|
||||
alert(msg);
|
||||
}
|
||||
}}
|
||||
className="dg-btn dg-btn-sm dg-btn-ghost text-green-400 hover:text-green-300"
|
||||
>
|
||||
@@ -470,7 +474,10 @@ export default function TicketsPage() {
|
||||
try {
|
||||
await ticketApi.review(ticket.id, { action: 'reject', comment: '拒绝' });
|
||||
fetchTickets(); fetchStats();
|
||||
} catch { /* ignore */ }
|
||||
} catch (e: any) {
|
||||
const msg = e?.response?.data?.detail || e?.message || '操作失败';
|
||||
alert(msg);
|
||||
}
|
||||
}}
|
||||
className="dg-btn dg-btn-sm dg-btn-ghost text-red-400 hover:text-red-300"
|
||||
>
|
||||
@@ -494,7 +501,7 @@ export default function TicketsPage() {
|
||||
</button>
|
||||
)}
|
||||
|
||||
{(ticket.status === 'pending' || ticket.status === 'reviewing' || ticket.status === 'approved') && (
|
||||
{currentUser?.id === ticket.applicant_id && (ticket.status === 'pending' || ticket.status === 'reviewing' || ticket.status === 'approved') && (
|
||||
<button
|
||||
onClick={async () => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user