lxl-dev #3
@ -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}`,
|
||||
|
||||
@ -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}`,
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -36,7 +36,9 @@
|
||||
<div class="context-container">
|
||||
<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="header-container">
|
||||
<div class="task-info">
|
||||
@ -103,6 +105,10 @@
|
||||
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
||||
日志
|
||||
</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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -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;
|
||||
|
||||
@ -37,7 +37,9 @@
|
||||
<div class="context-container">
|
||||
<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="header-container">
|
||||
<div class="task-info">
|
||||
@ -103,6 +105,10 @@
|
||||
<el-button icon="Edit" link type="primary" @click="handleOpenLog(scope.row)">
|
||||
日志
|
||||
</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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -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;
|
||||
|
||||
@ -48,9 +48,12 @@
|
||||
|
||||
<div :style="containerHeight">
|
||||
<el-table
|
||||
ref="instTableRef"
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="instList"
|
||||
row-key="id"
|
||||
highlight-current-row
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column
|
||||
@ -114,7 +117,7 @@
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
label="操作"
|
||||
width="180"
|
||||
width="300"
|
||||
>
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
@ -131,6 +134,14 @@
|
||||
@click="handleOpenDashboard(scope.row)"
|
||||
>流程可视化
|
||||
</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>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -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) => {
|
||||
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 = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 取消按钮
|
||||
|
||||
Loading…
Reference in New Issue
Block a user