Commit 582335c1 authored by hzl's avatar hzl

feat: 运行执行成功的任务再执行

parent 8be65610
......@@ -48,8 +48,8 @@
class="batch-execute-btn"
@click="batchExecuteTasks"
:loading="batchExecuteLoading"
:disabled="!hasExecutableTasks">
一键执行
:disabled="selectedTasks.length === 0">
执行选中任务 ({{ selectedTasks.length }})
</el-button>
<div class="header-right">
<el-button icon="el-icon-refresh" @click="fetchData">刷新</el-button>
......@@ -61,7 +61,13 @@
:data="tableData"
border
style="width: 100%"
v-loading="loading">
v-loading="loading"
@selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55"
:selectable="isTaskSelectable">
</el-table-column>
<el-table-column prop="id" label="ID" width="80"></el-table-column>
<el-table-column prop="campaignTemplateId" label="计划模板" width="250">
<template slot-scope="scope">
......@@ -132,7 +138,7 @@
title="详情"
@click="handleDetail(scope.row)"></el-button>
<el-button
v-if="scope.row.status === 1 || scope.row.status === 4"
v-if="scope.row.status === 1 || scope.row.status === 3 || scope.row.status === 4"
size="mini"
type="success"
icon="el-icon-video-play"
......@@ -1216,17 +1222,11 @@ export default {
newCampaignLocationGroups: [],
// 新建计划修改状态跟踪
newCampaignModifiedStatus: [],
// 选中的任务列表
selectedTasks: [],
}
},
computed: {
// 计算是否有可执行的任务(只包括状态为1未执行的任务)
hasExecutableTasks() {
return this.tableData.some(row => row.status === 1);
},
// 获取当前页可执行的任务列表(只包括状态为1未执行的任务)
executableTasks() {
return this.tableData.filter(row => row.status === 1);
},
// 计算是否有独立配置(已有计划或新建计划)
hasMultiCampaignConfig() {
if (this.form.platform !== 2) return false;
......@@ -1266,6 +1266,8 @@ export default {
if (response.status === 200) {
this.tableData = response.result.data.value
this.total = response.result.data.count
// 清空选择
this.selectedTasks = []
} else {
this.$message.error(response.msg || '获取数据失败')
}
......@@ -1521,19 +1523,28 @@ export default {
}
},
// 判断任务是否可选(未执行、执行成功、执行失败的任务都可以选择)
isTaskSelectable(row) {
return row.status === 1 || row.status === 3 || row.status === 4;
},
// 处理选择变化
handleSelectionChange(selection) {
this.selectedTasks = selection;
},
// 批量执行任务
async batchExecuteTasks() {
if (!this.hasExecutableTasks) {
this.$message.warning('当前页没有可执行的任务');
if (this.selectedTasks.length === 0) {
this.$message.warning('请先选择要执行的任务');
return;
}
const executableTasks = this.executableTasks;
const taskCount = executableTasks.length;
const taskCount = this.selectedTasks.length;
// 确认对话框
const confirmResult = await this.$confirm(
`确定要执行当前页${taskCount} 个任务吗?`,
`确定要执行选中${taskCount} 个任务吗?`,
'批量执行确认',
{
confirmButtonText: '确定执行',
......@@ -1551,7 +1562,7 @@ export default {
try {
// 调用批量执行接口
const response = await axios.post(process.env.PUTIN_API + '/campaign-tasks/batch-start', {
taskIds: executableTasks.map(task => task.id)
taskIds: this.selectedTasks.map(task => task.id)
});
if (response.status === 200) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment