Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
Z
zxn-adputin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lijin
zxn-adputin
Commits
944a7e39
Commit
944a7e39
authored
Sep 26, 2025
by
hzl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 一键执行
parent
75ea1aff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
0 deletions
+103
-0
CampaignTaskManage.vue
src/views/campaignTask/CampaignTaskManage.vue
+103
-0
No files found.
src/views/campaignTask/CampaignTaskManage.vue
View file @
944a7e39
...
...
@@ -42,6 +42,15 @@
<!-- Table Header actions -->
<div
class=
"header-actions"
>
<el-button
type=
"primary"
@
click=
"showAddDialog"
>
创建任务
</el-button>
<el-button
type=
"success"
icon=
"el-icon-video-play"
class=
"batch-execute-btn"
@
click=
"batchExecuteTasks"
:loading=
"batchExecuteLoading"
:disabled=
"!hasExecutableTasks"
>
一键执行
</el-button>
<div
class=
"header-right"
>
<el-button
icon=
"el-icon-refresh"
@
click=
"fetchData"
>
刷新
</el-button>
</div>
...
...
@@ -861,6 +870,7 @@ export default {
return
{
loading
:
false
,
startLoading
:
false
,
// 新增:任务启动loading状态
batchExecuteLoading
:
false
,
// 新增:批量执行loading状态
condition
:
{
templateId
:
null
,
status
:
null
,
...
...
@@ -1099,6 +1109,16 @@ export default {
campaignLocationGroups
:
[],
}
},
computed
:
{
// 计算是否有可执行的任务(只包括状态为1未执行的任务)
hasExecutableTasks
()
{
return
this
.
tableData
.
some
(
row
=>
row
.
status
===
1
);
},
// 获取当前页可执行的任务列表(只包括状态为1未执行的任务)
executableTasks
()
{
return
this
.
tableData
.
filter
(
row
=>
row
.
status
===
1
);
}
},
created
()
{
this
.
fetchData
()
this
.
initGroupOptions
()
...
...
@@ -1367,6 +1387,69 @@ export default {
}
},
// 批量执行任务
async
batchExecuteTasks
()
{
if
(
!
this
.
hasExecutableTasks
)
{
this
.
$message
.
warning
(
'当前页没有可执行的任务'
);
return
;
}
const
executableTasks
=
this
.
executableTasks
;
const
taskCount
=
executableTasks
.
length
;
// 确认对话框
const
confirmResult
=
await
this
.
$confirm
(
`确定要执行当前页的
${
taskCount
}
个任务吗?`
,
'批量执行确认'
,
{
confirmButtonText
:
'确定执行'
,
cancelButtonText
:
'取消'
,
type
:
'warning'
}
).
catch
(()
=>
false
);
if
(
!
confirmResult
)
{
return
;
}
this
.
batchExecuteLoading
=
true
;
try
{
// 调用批量执行接口
const
response
=
await
axios
.
post
(
process
.
env
.
PUTIN_API
+
'/campaign-tasks/batch-start'
,
{
taskIds
:
executableTasks
.
map
(
task
=>
task
.
id
)
});
if
(
response
.
status
===
200
)
{
const
result
=
response
.
data
;
if
(
result
.
status
===
200
)
{
const
successCount
=
(
result
.
result
&&
result
.
result
.
successCount
)
||
0
;
const
failCount
=
(
result
.
result
&&
result
.
result
.
failCount
)
||
0
;
if
(
successCount
>
0
)
{
this
.
$message
.
success
(
`批量执行完成:成功
${
successCount
}
个,失败
${
failCount
}
个`
);
}
else
{
this
.
$message
.
error
(
'所有任务执行失败'
);
}
// 刷新数据
this
.
fetchData
();
}
else
{
this
.
$message
.
error
(
result
.
msg
||
'批量执行失败'
);
}
}
else
{
this
.
$message
.
error
(
'批量执行失败'
);
}
}
catch
(
error
)
{
console
.
error
(
'批量执行失败:'
,
error
);
const
errorMessage
=
error
.
response
&&
error
.
response
.
data
&&
error
.
response
.
data
.
message
?
error
.
response
.
data
.
message
:
error
.
message
;
this
.
$message
.
error
(
'批量执行失败:'
+
errorMessage
);
}
finally
{
this
.
batchExecuteLoading
=
false
;
}
},
submitForm
()
{
this
.
$refs
.
form
.
validate
(
async
valid
=>
{
if
(
valid
)
{
...
...
@@ -2368,6 +2451,8 @@ export default {
margin
:
20px
0
;
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
gap
:
10px
;
}
.header-right
{
...
...
@@ -2375,6 +2460,24 @@ export default {
gap
:
10px
;
}
.batch-execute-btn
{
background
:
linear-gradient
(
135deg
,
#67c23a
0%
,
#85ce61
100%
);
border
:
none
;
box-shadow
:
0
2px
8px
rgba
(
103
,
194
,
58
,
0
.3
);
transition
:
all
0
.3s
ease
;
}
.batch-execute-btn
:hover
{
transform
:
translateY
(
-1px
);
box-shadow
:
0
4px
12px
rgba
(
103
,
194
,
58
,
0
.4
);
}
.batch-execute-btn
:disabled
{
background
:
#c0c4cc
;
box-shadow
:
none
;
transform
:
none
;
}
.el-tag
{
margin-right
:
5px
;
margin-bottom
:
5px
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment