From 7658e29cf2c4f503ef15532b0739330883b27ffb Mon Sep 17 00:00:00 2001 From: lixiaolong <702156524@qq.com> Date: Thu, 13 Aug 2026 17:54:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(task):=20=E6=B7=BB=E5=8A=A0=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E9=87=8D=E6=96=B0=E6=89=A7=E8=A1=8C=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在巡检任务页面添加重新执行按钮,支持已完成和失败的任务重新运行 - 在智能测试任务页面添加重新执行功能,允许用户基于历史参数创建新任务 - 在日志页面添加重新执行按钮,方便快速重启历史任务实例 - 实现任务选择高亮显示,改善用户体验 - 添加重新执行API接口,支持按历史参数创建新任务实例 - 实现任务列表滚动定位到选中任务的功能 --- src/api/inspection/runTask.js | 7 +++ src/api/intelligenceTest/runningTask.js | 8 ++- src/api/test/log.js | 8 +++ src/views/inspection/runTask/index.vue | 35 +++++++++++-- .../intelligenceTest/runningTask/index.vue | 34 ++++++++++++- src/views/test/log/index.vue | 51 ++++++++++++++++--- 6 files changed, 129 insertions(+), 14 deletions(-) diff --git a/src/api/inspection/runTask.js b/src/api/inspection/runTask.js index 9b106ba..84b2ec6 100644 --- a/src/api/inspection/runTask.js +++ b/src/api/inspection/runTask.js @@ -46,6 +46,13 @@ export function startRunTask(id, data) { }) } +export function rerunRunTask(id) { + return request({ + url: `/inspection/taskInstance/rerun/${id}`, + method: 'post' + }) +} + export function stopRunTask(id) { return request({ url: `/inspection/taskInstance/stop/${id}`, diff --git a/src/api/intelligenceTest/runningTask.js b/src/api/intelligenceTest/runningTask.js index 7424d8a..dddc851 100644 --- a/src/api/intelligenceTest/runningTask.js +++ b/src/api/intelligenceTest/runningTask.js @@ -1,5 +1,4 @@ import request from '@/utils/request' -import { method } from 'lodash' export function addTaskinstance(data) { return request({ @@ -40,6 +39,13 @@ export function startTaskinstance(id, data) { }) } +export function rerunTaskinstance(id) { + return request({ + url: `/aima/taskinstance/rerun/${id}`, + method: 'post' + }) +} + export function pauseTaskinstance(id) { return request({ url: `/aima/taskinstance/pause/${id}`, diff --git a/src/api/test/log.js b/src/api/test/log.js index f1847ba..d84e12b 100644 --- a/src/api/test/log.js +++ b/src/api/test/log.js @@ -52,6 +52,14 @@ export function listInst(query) { }) } +// 使用历史实例保存的执行参数创建新的任务实例 +export function rerunInst(id) { + return request({ + url: `/test/inst/rerun/${id}`, + method: 'post' + }) +} + // 查询任务实例日志 export function getInst(query) { return request({ diff --git a/src/views/inspection/runTask/index.vue b/src/views/inspection/runTask/index.vue index cc47d30..f121dc6 100644 --- a/src/views/inspection/runTask/index.vue +++ b/src/views/inspection/runTask/index.vue @@ -36,7 +36,9 @@
-
+
@@ -103,6 +105,10 @@ 日志 + + 再次执行 + @@ -165,7 +171,7 @@ import taskLog from "./task-log.vue"; import { useContainerHeight } from "@/hooks/tableHeight"; import { getTaskList, getWaypointByTaskId } from "@/api/inspection/task"; import { onMounted, onUnmounted } from "vue"; -import { addRunTask, getRunTaskList, startRunTask, pauseRunTask, stopRunTask, resumeRunTask, deleteRunTask, getTaskLogListApi } from "@/api/inspection/runTask"; +import { addRunTask, getRunTaskList, startRunTask, rerunRunTask, pauseRunTask, stopRunTask, resumeRunTask, deleteRunTask, getTaskLogListApi } from "@/api/inspection/runTask"; import { ElMessage, ElMessageBox } from "element-plus"; import { formatDate } from "@/utils/index"; import { debounce } from 'lodash'; // 引入 lodash 的防抖函数 @@ -190,6 +196,8 @@ const runtimeEditorRef = ref() const runtimeMapId = ref('') const runtimeParamItems = ref([]) const runtimeParamsEditorRef = ref() +const selectedTaskId = ref('') +const rerunningId = ref('') const taskStatusMap = { '0': '已完成', @@ -260,7 +268,7 @@ const runingTaskList = ref([]) * 获取任务队列 */ const getList = () => { - getRunTaskList({ + return getRunTaskList({ statusList: ['1', '3', '5'], }).then((res) => { if (res.code === 200) { @@ -275,6 +283,23 @@ const getList = () => { }) } +const handleRerun = async (task) => { + rerunningId.value = task.id + try { + const res = await rerunRunTask(task.id) + if (res.code === 200) { + selectedTaskId.value = String(res.data || '') + activePanel.value = 'current' + await getList() + await nextTick() + document.querySelector(`[data-task-id="${selectedTaskId.value}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + ElMessage.success('已按上次参数创建并启动新任务') + } + } finally { + rerunningId.value = '' + } +} + const pointList_runningTask = ref({}) /** * 获取正在执行任务的点位列表 @@ -639,6 +664,10 @@ onUnmounted(() => { border-radius: 20px; margin-bottom: 12px; + &--selected { + box-shadow: inset 0 0 0 2px var(--el-color-primary); + } + .task-header { display: flex; justify-content: space-between; diff --git a/src/views/intelligenceTest/runningTask/index.vue b/src/views/intelligenceTest/runningTask/index.vue index 00ef52a..c03cc54 100644 --- a/src/views/intelligenceTest/runningTask/index.vue +++ b/src/views/intelligenceTest/runningTask/index.vue @@ -37,7 +37,9 @@
-
+
@@ -103,6 +105,10 @@ 日志 + + 再次执行 + @@ -179,6 +185,7 @@ import { addTaskinstance, getTaskinstanceList, startTaskinstance, + rerunTaskinstance, pauseTaskinstance, stopTaskinstance, resumeTaskinstance, @@ -208,6 +215,8 @@ const runtimeAssignments = ref([]) const runtimeEditorRef = ref() const runtimeParamItems = ref([]) const runtimeParamsEditorRef = ref() +const selectedTaskId = ref('') +const rerunningId = ref('') const taskStatusMap = { '0': '已完成', @@ -302,7 +311,7 @@ const runingTaskList = ref([]) * 获取任务队列 */ const getList = () => { - getTaskinstanceList({ + return getTaskinstanceList({ statusList: ['1', '3', '5'], }).then((res) => { if (res.code === 200) { @@ -317,6 +326,23 @@ const getList = () => { }) } +const handleRerun = async (task) => { + rerunningId.value = task.id + try { + const res = await rerunTaskinstance(task.id) + if (res.code === 200) { + selectedTaskId.value = String(res.data || '') + activePanel.value = 'current' + await getList() + await nextTick() + document.querySelector(`[data-task-id="${selectedTaskId.value}"]`)?.scrollIntoView({ behavior: 'smooth', block: 'center' }) + ElMessage.success('已按上次参数创建并启动新任务') + } + } finally { + rerunningId.value = '' + } +} + const pointList_runningTask = ref({}) /** * 获取正在执行任务的用例列表 @@ -683,6 +709,10 @@ onUnmounted(() => { border-radius: 20px; margin-bottom: 12px; + &--selected { + box-shadow: inset 0 0 0 2px var(--el-color-primary); + } + .task-header { display: flex; justify-content: space-between; diff --git a/src/views/test/log/index.vue b/src/views/test/log/index.vue index d2a4255..c6fdcb3 100644 --- a/src/views/test/log/index.vue +++ b/src/views/test/log/index.vue @@ -48,9 +48,12 @@
@@ -226,6 +237,7 @@ import { getInst, getLog, listInst, + rerunInst, updateLog, } from "@/api/test/log"; import TableSearch from "@/components/TableSearch/index.vue"; @@ -243,6 +255,9 @@ const containerHeight = useContainerHeight(topContainerRef); const { proxy } = getCurrentInstance(); const instList = ref([]); +const instTableRef = ref(); +const selectedInstId = ref(''); +const rerunningId = ref(''); const logList = ref([]); const open = ref(false); const openDashboard = ref(false); @@ -282,15 +297,35 @@ const endOn = computed( ); /** 查询任务实例列表 */ -function getInstList() { +async function getInstList() { loading.value = true; - listInst(Object.assign(queryParams.value, { startOn, endOn })).then( - (response) => { - instList.value = response.rows; - instTotal.value = response.total; - loading.value = false; + try { + const response = await listInst(Object.assign(queryParams.value, { startOn, endOn })); + instList.value = response.rows; + instTotal.value = response.total; + if (selectedInstId.value) { + await nextTick(); + const selected = instList.value.find((item) => item.id === selectedInstId.value); + if (selected) instTableRef.value?.setCurrentRow(selected); } - ); + } finally { + loading.value = false; + } +} + +async function handleRerun(row) { + rerunningId.value = row.id; + try { + const response = await rerunInst(row.id); + if (response.code === 200) { + selectedInstId.value = String(response.data || ''); + queryParams.value.pageNum = 1; + await getInstList(); + proxy.$modal.msgSuccess('已按上次参数创建并启动新任务'); + } + } finally { + rerunningId.value = ''; + } } // 取消按钮