fix: 全部页面 confirm() 替换为 ConfirmDialog 组件 — 9个页面统一回调模式
This commit is contained in:
1 parent
41dab3deab
commit
7f6a4bb6df
9 files changed
+153
-62
No files matched your search
@@ -7,6 +7,7 @@ import {
|
||||
import { Card, CardContent } from '@/components/ui/card';
|
||||
import { workflowApi } from '@/api/workflow';
|
||||
import { userApi } from '@/api/user';
|
||||
import { ConfirmDialog } from '@/components/ConfirmDialog';
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Types */
|
||||
@@ -470,6 +471,7 @@ export default function WorkflowPage() {
|
||||
const [expandedId, setExpandedId] = useState<number | null>(null);
|
||||
const [previewWorkflow, setPreviewWorkflow] = useState<WorkflowDetail | null>(null);
|
||||
const [editorWorkflow, setEditorWorkflow] = useState<WorkflowDetail | null | undefined>(undefined);
|
||||
const [deleteConfirm, setDeleteConfirm] = useState<{msg: string; onConfirm: () => void} | null>(null);
|
||||
|
||||
const fetchWorkflows = useCallback(async () => {
|
||||
try {
|
||||
@@ -506,11 +508,13 @@ export default function WorkflowPage() {
|
||||
}, []);
|
||||
|
||||
const handleDelete = useCallback(async (id: number) => {
|
||||
if (!confirm('确认删除该审批流程?')) return;
|
||||
try {
|
||||
await workflowApi.delete(id);
|
||||
setItems((prev) => prev.filter((w) => w.id !== id));
|
||||
} catch {}
|
||||
setDeleteConfirm({msg: '确认删除该审批流程?', onConfirm: async () => {
|
||||
try {
|
||||
await workflowApi.delete(id);
|
||||
setItems((prev) => prev.filter((w) => w.id !== id));
|
||||
} catch {}
|
||||
}});
|
||||
return;
|
||||
}, []);
|
||||
|
||||
const setDefault = useCallback(async (id: number) => {
|
||||
@@ -807,6 +811,14 @@ export default function WorkflowPage() {
|
||||
onSaved={() => { setEditorWorkflow(undefined); fetchWorkflows(); }}
|
||||
/>
|
||||
)}
|
||||
<ConfirmDialog
|
||||
open={!!deleteConfirm}
|
||||
title={deleteConfirm?.msg || '确认操作'}
|
||||
variant="danger"
|
||||
confirmText="确定"
|
||||
onConfirm={() => { deleteConfirm?.onConfirm(); }}
|
||||
onCancel={() => setDeleteConfirm(null)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user