增加启动和停止按钮逻辑

This commit is contained in:
2025-09-22 15:21:06 +08:00
parent 69cbcf5ff6
commit fe0409fe4e

View File

@@ -63,7 +63,10 @@
<el-table-column label="操作" width="200">
<template #default="scope">
<el-button size="small" @click="editPlan(scope.row)">编辑</el-button>
<el-button size="small" @click="startPlan(scope.row)" :loading="startingPlanId === scope.row.id">
<el-button v-if="scope.row.status === 1" size="small" type="warning" @click="stopPlan(scope.row)" :loading="stoppingPlanId === scope.row.id">
停止
</el-button>
<el-button v-else size="small" @click="startPlan(scope.row)" :loading="startingPlanId === scope.row.id">
启动
</el-button>
<el-button size="small" type="danger" @click="deletePlan(scope.row)">删除</el-button>
@@ -111,7 +114,8 @@ export default {
execute_num: 0,
cron_expression: ''
},
startingPlanId: null
startingPlanId: null,
stoppingPlanId: null
};
},
async mounted() {
@@ -201,6 +205,19 @@ export default {
this.startingPlanId = null;
}
},
async stopPlan(plan) {
try {
this.stoppingPlanId = plan.id;
await apiClient.plans.stop(plan.id);
this.$message.success('计划停止成功');
await this.loadPlans();
} catch (err) {
this.$message.error('停止失败: ' + (err.message || '未知错误'));
} finally {
this.stoppingPlanId = null;
}
},
// 处理计划表单提交成功
async handlePlanSuccess(planData) {