增加启动和停止按钮逻辑
This commit is contained in:
@@ -63,7 +63,10 @@
|
|||||||
<el-table-column label="操作" width="200">
|
<el-table-column label="操作" width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button size="small" @click="editPlan(scope.row)">编辑</el-button>
|
<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>
|
||||||
<el-button size="small" type="danger" @click="deletePlan(scope.row)">删除</el-button>
|
<el-button size="small" type="danger" @click="deletePlan(scope.row)">删除</el-button>
|
||||||
@@ -111,7 +114,8 @@ export default {
|
|||||||
execute_num: 0,
|
execute_num: 0,
|
||||||
cron_expression: ''
|
cron_expression: ''
|
||||||
},
|
},
|
||||||
startingPlanId: null
|
startingPlanId: null,
|
||||||
|
stoppingPlanId: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
@@ -201,6 +205,19 @@ export default {
|
|||||||
this.startingPlanId = null;
|
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) {
|
async handlePlanSuccess(planData) {
|
||||||
|
|||||||
Reference in New Issue
Block a user