feat(FlowList): 为删除操作添加确认弹窗并改进错误处理
添加 Popconfirm 组件以防止误删流程,同时优化删除操作的错误提示
This commit is contained in:
@ -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 || '删除失败')
|
||||
|
||||
Reference in New Issue
Block a user