Commit ec521995 authored by huangzhenglong's avatar huangzhenglong

feat: 增加loading效果防止重复提交

parent 1e2e1de6
......@@ -79,8 +79,8 @@
<template slot-scope="scope">
<el-tag
:type="getStatusType(scope.row.status)"
:class="{'clickable-tag': scope.row.status === 4}"
@click="scope.row.status === 4 && showErrorMessage(scope.row)">
:class="{'clickable-tag': scope.row.status === 3 || scope.row.status === 4}"
@click="(scope.row.status === 3 || scope.row.status === 4) && showErrorMessage(scope.row)">
{{ getStatusText(scope.row.status) }}
</el-tag>
</template>
......@@ -109,6 +109,7 @@
icon="el-icon-video-play"
circle
title="开始"
:loading="startLoading"
@click="handleStart(scope.row)"></el-button>
<el-button
v-else
......@@ -564,6 +565,7 @@ export default {
const start = end.clone().subtract(7, 'day')
return {
loading: false,
startLoading: false, // 新增:任务启动loading状态
condition: {
templateId: null,
status: null,
......@@ -862,6 +864,10 @@ export default {
},
async handleStart(row) {
if (this.startLoading) {
return;
}
this.startLoading = true;
try {
const response = await axios.post(process.env.PUTIN_API + `/campaign-tasks/start?campaignTaskId=${row.id}`)
if (response.status == 200) {
......@@ -873,9 +879,11 @@ export default {
}
} catch (error) {
console.error('Failed to start task:', error)
const errorMessage = error.response && error.response.data && error.response.data.message ?
const errorMessage = error.response && error.response.data && error.response.data.message ?
error.response.data.message : error.message
this.$message.error('任务开始失败:' + errorMessage)
} finally {
this.startLoading = false;
}
},
......
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