Skip to content

Commit 943385d

Browse files
committed
feat: 任务列表页删除和停止操作添加确认对话框
1 parent 6a719b4 commit 943385d

1 file changed

Lines changed: 58 additions & 6 deletions

File tree

src/frontEnd/src/views/TaskList/index.vue

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@
157157
<template #body="{ data }">
158158
<div class="action-buttons">
159159
<Button icon="pi pi-eye" @click="viewTask(data)" text rounded size="small" v-tooltip.top="'查看详情'" />
160-
<Button icon="pi pi-stop" @click="stopTask(data.taskid)" text rounded size="small" severity="warning" v-if="data.status === 1" v-tooltip.top="'停止任务'" />
161-
<Button icon="pi pi-trash" @click="deleteTask(data.taskid)" text rounded size="small" severity="danger" v-tooltip.top="'删除任务'" />
160+
<Button icon="pi pi-stop" @click="confirmStopTask(data.taskid)" text rounded size="small" severity="warning" v-if="data.status === 1" v-tooltip.top="'停止任务'" />
161+
<Button icon="pi pi-trash" @click="confirmDeleteTask(data.taskid)" text rounded size="small" severity="danger" v-tooltip.top="'删除任务'" />
162162
</div>
163163
</template>
164164
</Column>
@@ -379,12 +379,64 @@ function goToTaskHttpInfo(task: any) {
379379
router.push({ path: `/tasks/${task.taskid}`, query: { tab: '1' } })
380380
}
381381
382-
async function stopTask(taskId: string) {
383-
await taskStore.stopTask(taskId)
382+
// 确认停止单个任务
383+
function confirmStopTask(taskId: string) {
384+
confirm.require({
385+
message: '确定要停止这个任务吗?',
386+
header: '确认停止',
387+
icon: 'pi pi-exclamation-triangle',
388+
acceptLabel: '停止',
389+
rejectLabel: '取消',
390+
acceptClass: 'p-button-warning',
391+
accept: async () => {
392+
try {
393+
await taskStore.stopTask(taskId)
394+
toast.add({
395+
severity: 'success',
396+
summary: '成功',
397+
detail: '任务已停止',
398+
life: 3000,
399+
})
400+
} catch (error) {
401+
toast.add({
402+
severity: 'error',
403+
summary: '错误',
404+
detail: '停止任务失败,请重试',
405+
life: 3000,
406+
})
407+
}
408+
},
409+
})
384410
}
385411
386-
async function deleteTask(taskId: string) {
387-
await taskStore.deleteTask(taskId)
412+
// 确认删除单个任务
413+
function confirmDeleteTask(taskId: string) {
414+
confirm.require({
415+
message: '确定要删除这个任务吗?此操作不可恢复。',
416+
header: '确认删除',
417+
icon: 'pi pi-exclamation-triangle',
418+
acceptLabel: '删除',
419+
rejectLabel: '取消',
420+
acceptClass: 'p-button-danger',
421+
accept: async () => {
422+
try {
423+
await taskStore.deleteTask(taskId)
424+
toast.add({
425+
severity: 'success',
426+
summary: '成功',
427+
detail: '任务已删除',
428+
life: 3000,
429+
})
430+
} catch (error) {
431+
toast.add({
432+
severity: 'error',
433+
summary: '错误',
434+
detail: '删除任务失败,请重试',
435+
life: 3000,
436+
})
437+
}
438+
},
439+
})
388440
}
389441
390442
function handleFilterChange(filters: TaskFilters) {

0 commit comments

Comments
 (0)