feat(FlowList): 为删除操作添加确认弹窗并改进错误处理

添加 Popconfirm 组件以防止误删流程,同时优化删除操作的错误提示
This commit is contained in:
2025-09-15 23:22:26 +08:00
parent 7c201f9083
commit 65764a2cbc

View File

@ -1,5 +1,5 @@
import { useEffect, useMemo, useState } from 'react'
import { Button, Modal, Space, Table, message, Typography, Input, Form, Tooltip } from 'antd'
import { Button, Modal, Space, Table, message, Typography, Input, Form, Tooltip, Popconfirm } from 'antd'
import { PlusOutlined, ReloadOutlined, DeleteOutlined, EditOutlined, EyeOutlined } from '@ant-design/icons'
import { useNavigate } from 'react-router-dom'
import api, { type ApiResp } from '../utils/axios'
@ -141,7 +141,12 @@ export default function FlowList() {
<Space>
<Button type="link" icon={<EditOutlined />} onClick={() => openEdit(row)}></Button>
<Button type="link" onClick={() => navigate(`/flows/editor?id=${encodeURIComponent(row.id)}`)}></Button>
<Button type="link" danger icon={<DeleteOutlined />} onClick={() => onDelete(row)}></Button>
<Popconfirm title={`确认删除流程「${row.name}」?`} onConfirm={() => onDelete(row)}>
<a className="action-link action-danger">
<DeleteOutlined />
<span></span>
</a>
</Popconfirm>
<Button type="link" icon={<EyeOutlined />} onClick={() => onView(row)}></Button>
</Space>
)
@ -182,8 +187,10 @@ export default function FlowList() {
try {
const { data } = await api.delete<ApiResp<boolean>>(`/flows/${row.id}`)
if (data?.code === 0) {
message.success('删除')
message.success('删除成功')
fetchList(page, pageSize, keyword)
} else {
throw new Error(data?.message || '删除失败')
}
} catch (e: any) {
message.error(e?.message || '删除失败')