This commit is contained in:
dhr
2025-09-29 17:17:42 +08:00
parent db9e2e55ea
commit f58efb0e08
15 changed files with 411 additions and 364 deletions

View File

@ -24,6 +24,9 @@
<!-- 筛选栏 -->
<div class="filter-bar">
<div class="filter-container">
<div class="filter-item">
<el-input v-model="keyword" placeholder="关键字(任务名/测试对象/执行人)" clearable @keyup.enter="handleSearch" />
</div>
<div class="filter-item">
<el-select v-model="taskStatus" placeholder="任务状态">
<el-option label="待执行" value="1"></el-option>
@ -50,6 +53,7 @@
</div>
<div class="filter-actions">
<el-button type="primary" icon="Search" class="search-btn" @click="handleSearch"> 搜索 </el-button>
<el-button icon="Refresh" class="create-btn" @click="resetFilters"> 重置 </el-button>
<el-button type="primary" icon="Plus" class="create-btn" @click="handleCreateTask"> 手动创建任务 </el-button>
</div>
</div>
@ -479,6 +483,7 @@ const loading = ref(false);
// 筛选条件(与接口参数对应)
const taskStatus = ref(''); // 任务状态1=待执行2=暂停已延期3=失败4=执行中5=已完成
const planType = ref(''); // 关联计划ID1=每日2=每周3=每月
const keyword = ref(''); // 关键词
/**
* 将节点数据按模块分组
@ -716,8 +721,18 @@ const getTaskList = async () => {
if (response.code === 200) {
// 3. 接口数据映射为页面展示格式
tasks.value = (response.rows || []).map((item) => mapApiToView(item));
total.value = response.total || 0; // 同步总条数
const mapped = (response.rows || []).map((item) => mapApiToView(item));
// 4. 前端关键词过滤
const kw = keyword.value.trim();
const filtered = kw
? mapped.filter((t) =>
[t.title, t.target, t.executor, t.relatedPlan, t.statusText]
.filter(Boolean)
.some((v) => String(v).toLowerCase().includes(kw.toLowerCase()))
)
: mapped;
tasks.value = filtered;
total.value = kw ? filtered.length : response.total || filtered.length; // 同步总条数
} else {
ElMessage.error('获取任务列表失败:' + (response.msg || '未知错误'));
tasks.value = [];
@ -833,6 +848,18 @@ const mapApiToView = (apiData) => {
try {
// 优先查找nodes数组中处于执行中或失败的节点来确定当前试验阶段
if (apiData && apiData.nodes && Array.isArray(apiData.nodes)) {
// 优先查找失败状态的节点根据需求优先显示status为3的数据
const failedNode = apiData.nodes.find((node) => {
if (!node || node.status === undefined) return false;
return node.status === '3' || node.status === 3;
});
// 如果有失败的节点根据code判断阶段
if (failedNode && failedNode.code !== undefined) {
const stepName = failedNode.name || '未命名步骤';
return `${failedNode.code}步(${stepName})`;
}
// 查找执行中状态的节点
const executingNode = apiData.nodes.find((node) => {
if (!node || node.status === undefined) return false;
@ -845,18 +872,6 @@ const mapApiToView = (apiData) => {
return `${executingNode.code}步(${stepName})`;
}
// 查找失败状态的节点
const failedNode = apiData.nodes.find((node) => {
if (!node || node.status === undefined) return false;
return node.status === '3' || node.status === 3;
});
// 如果有失败的节点根据code判断阶段
if (failedNode && failedNode.code !== undefined) {
const stepName = failedNode.name || '未命名步骤';
return `${failedNode.code}步(${stepName})`;
}
// 查找已完成的节点,确定最后完成的阶段
const completedNodes = apiData.nodes.filter((node) => {
if (!node || node.status === undefined) return false;
@ -921,6 +936,16 @@ const handleSearch = () => {
getTaskList();
};
// 重置筛选条件
const resetFilters = () => {
taskStatus.value = '';
planType.value = '';
executor.value = 'all';
keyword.value = '';
currentPage.value = 1;
getTaskList();
};
/**
* 每页条数变化
* @param {number} val - 新的每页条数