forked from SmartBench/CMVR-IOT-UI
feat(task): 添加任务重新执行功能
- 在巡检任务页面添加重新执行按钮,支持已完成和失败的任务重新运行 - 在智能测试任务页面添加重新执行功能,允许用户基于历史参数创建新任务 - 在日志页面添加重新执行按钮,方便快速重启历史任务实例 - 实现任务选择高亮显示,改善用户体验 - 添加重新执行API接口,支持按历史参数创建新任务实例 - 实现任务列表滚动定位到选中任务的功能
This commit is contained in:
parent
3d343812a9
commit
7658e29cf2
@ -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) {
|
export function stopRunTask(id) {
|
||||||
return request({
|
return request({
|
||||||
url: `/inspection/taskInstance/stop/${id}`,
|
url: `/inspection/taskInstance/stop/${id}`,
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
import { method } from 'lodash'
|
|
||||||
|
|
||||||
export function addTaskinstance(data) {
|
export function addTaskinstance(data) {
|
||||||
return request({
|
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) {
|
export function pauseTaskinstance(id) {
|
||||||
return request({
|
return request({
|
||||||
url: `/aima/taskinstance/pause/${id}`,
|
url: `/aima/taskinstance/pause/${id}`,
|
||||||
|
|||||||
@ -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) {
|
export function getInst(query) {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -36,7 +36,9 @@
|
|||||||
<div class="context-container">
|
<div class="context-container">
|
||||||
<div v-if="activePanel === 'current'">
|
<div v-if="activePanel === 'current'">
|
||||||
<!-- 当前任务内容 -->
|
<!-- 当前任务内容 -->
|
||||||
<div class="task" v-for="runTask in runingTaskList">
|
<div class="task" v-for="runTask in runingTaskList" :key="runTask.id"
|
||||||
|
:data-task-id="runTask.id" :class="{ 'task--selected': selectedTaskId === runTask.id }"
|
||||||
|
@click="selectedTaskId = runTask.id">
|
||||||
<div class="task-header">
|
<div class="task-header">
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
<div class="task-info">
|
<div class="task-info">
|
||||||
@ -103,6 +105,10 @@
|
|||||||
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
||||||
日志
|
日志
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button v-if="['0', '2'].includes(scope.row.status)" icon="RefreshRight" link
|
||||||
|
type="primary" :loading="rerunningId === scope.row.id" @click="handleRerun(scope.row)">
|
||||||
|
再次执行
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -165,7 +171,7 @@ import taskLog from "./task-log.vue";
|
|||||||
import { useContainerHeight } from "@/hooks/tableHeight";
|
import { useContainerHeight } from "@/hooks/tableHeight";
|
||||||
import { getTaskList, getWaypointByTaskId } from "@/api/inspection/task";
|
import { getTaskList, getWaypointByTaskId } from "@/api/inspection/task";
|
||||||
import { onMounted, onUnmounted } from "vue";
|
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 { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import { formatDate } from "@/utils/index";
|
import { formatDate } from "@/utils/index";
|
||||||
import { debounce } from 'lodash'; // 引入 lodash 的防抖函数
|
import { debounce } from 'lodash'; // 引入 lodash 的防抖函数
|
||||||
@ -190,6 +196,8 @@ const runtimeEditorRef = ref()
|
|||||||
const runtimeMapId = ref('')
|
const runtimeMapId = ref('')
|
||||||
const runtimeParamItems = ref([])
|
const runtimeParamItems = ref([])
|
||||||
const runtimeParamsEditorRef = ref()
|
const runtimeParamsEditorRef = ref()
|
||||||
|
const selectedTaskId = ref('')
|
||||||
|
const rerunningId = ref('')
|
||||||
|
|
||||||
const taskStatusMap = {
|
const taskStatusMap = {
|
||||||
'0': '已完成',
|
'0': '已完成',
|
||||||
@ -260,7 +268,7 @@ const runingTaskList = ref([])
|
|||||||
* 获取任务队列
|
* 获取任务队列
|
||||||
*/
|
*/
|
||||||
const getList = () => {
|
const getList = () => {
|
||||||
getRunTaskList({
|
return getRunTaskList({
|
||||||
statusList: ['1', '3', '5'],
|
statusList: ['1', '3', '5'],
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.code === 200) {
|
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({})
|
const pointList_runningTask = ref({})
|
||||||
/**
|
/**
|
||||||
* 获取正在执行任务的点位列表
|
* 获取正在执行任务的点位列表
|
||||||
@ -639,6 +664,10 @@ onUnmounted(() => {
|
|||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
&--selected {
|
||||||
|
box-shadow: inset 0 0 0 2px var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.task-header {
|
.task-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@ -37,7 +37,9 @@
|
|||||||
<div class="context-container">
|
<div class="context-container">
|
||||||
<div v-if="activePanel === 'current'">
|
<div v-if="activePanel === 'current'">
|
||||||
<!-- 当前任务内容 -->
|
<!-- 当前任务内容 -->
|
||||||
<div class="task" v-for="runTask in runingTaskList">
|
<div class="task" v-for="runTask in runingTaskList" :key="runTask.id"
|
||||||
|
:data-task-id="runTask.id" :class="{ 'task--selected': selectedTaskId === runTask.id }"
|
||||||
|
@click="selectedTaskId = runTask.id">
|
||||||
<div class="task-header">
|
<div class="task-header">
|
||||||
<div class="header-container">
|
<div class="header-container">
|
||||||
<div class="task-info">
|
<div class="task-info">
|
||||||
@ -103,6 +105,10 @@
|
|||||||
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
||||||
日志
|
日志
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button v-if="['0', '2'].includes(scope.row.status)" icon="RefreshRight" link
|
||||||
|
type="primary" :loading="rerunningId === scope.row.id" @click="handleRerun(scope.row)">
|
||||||
|
再次执行
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -179,6 +185,7 @@ import {
|
|||||||
addTaskinstance,
|
addTaskinstance,
|
||||||
getTaskinstanceList,
|
getTaskinstanceList,
|
||||||
startTaskinstance,
|
startTaskinstance,
|
||||||
|
rerunTaskinstance,
|
||||||
pauseTaskinstance,
|
pauseTaskinstance,
|
||||||
stopTaskinstance,
|
stopTaskinstance,
|
||||||
resumeTaskinstance,
|
resumeTaskinstance,
|
||||||
@ -208,6 +215,8 @@ const runtimeAssignments = ref([])
|
|||||||
const runtimeEditorRef = ref()
|
const runtimeEditorRef = ref()
|
||||||
const runtimeParamItems = ref([])
|
const runtimeParamItems = ref([])
|
||||||
const runtimeParamsEditorRef = ref()
|
const runtimeParamsEditorRef = ref()
|
||||||
|
const selectedTaskId = ref('')
|
||||||
|
const rerunningId = ref('')
|
||||||
|
|
||||||
const taskStatusMap = {
|
const taskStatusMap = {
|
||||||
'0': '已完成',
|
'0': '已完成',
|
||||||
@ -302,7 +311,7 @@ const runingTaskList = ref([])
|
|||||||
* 获取任务队列
|
* 获取任务队列
|
||||||
*/
|
*/
|
||||||
const getList = () => {
|
const getList = () => {
|
||||||
getTaskinstanceList({
|
return getTaskinstanceList({
|
||||||
statusList: ['1', '3', '5'],
|
statusList: ['1', '3', '5'],
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.code === 200) {
|
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({})
|
const pointList_runningTask = ref({})
|
||||||
/**
|
/**
|
||||||
* 获取正在执行任务的用例列表
|
* 获取正在执行任务的用例列表
|
||||||
@ -683,6 +709,10 @@ onUnmounted(() => {
|
|||||||
border-radius: 20px;
|
border-radius: 20px;
|
||||||
margin-bottom: 12px;
|
margin-bottom: 12px;
|
||||||
|
|
||||||
|
&--selected {
|
||||||
|
box-shadow: inset 0 0 0 2px var(--el-color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.task-header {
|
.task-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@ -48,9 +48,12 @@
|
|||||||
|
|
||||||
<div :style="containerHeight">
|
<div :style="containerHeight">
|
||||||
<el-table
|
<el-table
|
||||||
|
ref="instTableRef"
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
height="100%"
|
height="100%"
|
||||||
:data="instList"
|
:data="instList"
|
||||||
|
row-key="id"
|
||||||
|
highlight-current-row
|
||||||
@selection-change="handleSelectionChange"
|
@selection-change="handleSelectionChange"
|
||||||
>
|
>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@ -114,7 +117,7 @@
|
|||||||
align="center"
|
align="center"
|
||||||
class-name="small-padding fixed-width"
|
class-name="small-padding fixed-width"
|
||||||
label="操作"
|
label="操作"
|
||||||
width="180"
|
width="300"
|
||||||
>
|
>
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button
|
||||||
@ -131,6 +134,14 @@
|
|||||||
@click="handleOpenDashboard(scope.row)"
|
@click="handleOpenDashboard(scope.row)"
|
||||||
>流程可视化
|
>流程可视化
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="['0', '2'].includes(String(scope.row.status))"
|
||||||
|
icon="RefreshRight"
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
:loading="rerunningId === scope.row.id"
|
||||||
|
@click="handleRerun(scope.row)"
|
||||||
|
>再次执行</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
@ -226,6 +237,7 @@ import {
|
|||||||
getInst,
|
getInst,
|
||||||
getLog,
|
getLog,
|
||||||
listInst,
|
listInst,
|
||||||
|
rerunInst,
|
||||||
updateLog,
|
updateLog,
|
||||||
} from "@/api/test/log";
|
} from "@/api/test/log";
|
||||||
import TableSearch from "@/components/TableSearch/index.vue";
|
import TableSearch from "@/components/TableSearch/index.vue";
|
||||||
@ -243,6 +255,9 @@ const containerHeight = useContainerHeight(topContainerRef);
|
|||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
const instList = ref([]);
|
const instList = ref([]);
|
||||||
|
const instTableRef = ref();
|
||||||
|
const selectedInstId = ref('');
|
||||||
|
const rerunningId = ref('');
|
||||||
const logList = ref([]);
|
const logList = ref([]);
|
||||||
const open = ref(false);
|
const open = ref(false);
|
||||||
const openDashboard = ref(false);
|
const openDashboard = ref(false);
|
||||||
@ -282,15 +297,35 @@ const endOn = computed(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/** 查询任务实例列表 */
|
/** 查询任务实例列表 */
|
||||||
function getInstList() {
|
async function getInstList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
listInst(Object.assign(queryParams.value, { startOn, endOn })).then(
|
try {
|
||||||
(response) => {
|
const response = await listInst(Object.assign(queryParams.value, { startOn, endOn }));
|
||||||
instList.value = response.rows;
|
instList.value = response.rows;
|
||||||
instTotal.value = response.total;
|
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;
|
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 = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user