更新接口和调用方

This commit is contained in:
2025-10-29 19:42:48 +08:00
parent fff309f56b
commit 0ff82657ab
5 changed files with 180 additions and 38 deletions

View File

@@ -20,9 +20,9 @@
<span>{{ plan.name }} - 内容</span>
<div>
<template v-if="!isSubPlan">
<el-button class="button" type="primary" @click="savePlanContent" v-if="isEditingContent">保存</el-button>
<el-button class="button" type="danger" @click="cancelEdit" v-if="isEditingContent">取消</el-button>
<el-button class="button" @click="enterEditMode" v-else>编辑内容</el-button>
<el-button class="button" type="primary" @click="savePlanContent" v-if="isEditingContent" :disabled="plan.plan_type === '系统任务'">保存</el-button>
<el-button class="button" type="danger" @click="cancelEdit" v-if="isEditingContent" :disabled="plan.plan_type === '系统任务'">取消</el-button>
<el-button class="button" @click="enterEditMode" v-else :disabled="plan.plan_type === '系统任务'">编辑内容</el-button>
</template>
<!-- Dynamic Add Buttons -->
@@ -32,12 +32,14 @@
type="primary"
size="small"
@click="showAddSubPlanDialog"
:disabled="plan.plan_type === '系统任务'"
>增加子计划</el-button>
<el-button
v-if="plan.content_type === 'tasks' || !plan.content_type"
type="primary"
size="small"
@click="showTaskEditorDialog()"
:disabled="plan.plan_type === '系统任务'"
>增加子任务</el-button>
</template>
</div>
@@ -61,8 +63,8 @@
延时: {{ task.parameters.delay_duration }}
</p>
<el-button-group v-if="isEditingContent">
<el-button type="primary" size="small" @click="editTask(task)">编辑</el-button>
<el-button type="danger" size="small" @click="deleteTask(task)">删除</el-button>
<el-button type="primary" size="small" @click="editTask(task)" :disabled="plan.plan_type === '系统任务'">编辑</el-button>
<el-button type="danger" size="small" @click="deleteTask(task)" :disabled="plan.plan_type === '系统任务'">删除</el-button>
</el-button-group>
</el-card>
</el-timeline-item>
@@ -80,7 +82,7 @@
<!-- Pass child_plan_id to recursive PlanDetail -->
<plan-detail :plan-id="subPlan.child_plan_id" :is-sub-plan="true" />
<el-button-group v-if="isEditingContent" class="sub-plan-actions">
<el-button type="danger" size="small" @click="deleteSubPlan(subPlan)">删除</el-button>
<el-button type="danger" size="small" @click="deleteSubPlan(subPlan)" :disabled="plan.plan_type === '系统任务'">删除</el-button>
</el-button-group>
</div>
</el-card>
@@ -135,16 +137,16 @@
>
<el-form :model="currentTaskForm" ref="taskFormRef" :rules="taskFormRules" label-width="100px">
<el-form-item label="任务类型" prop="type">
<el-select v-model="currentTaskForm.type" placeholder="请选择任务类型" style="width: 100%;" :disabled="isEditingTask">
<el-select v-model="currentTaskForm.type" placeholder="请选择任务类型" style="width: 100%;" :disabled="isEditingTask || plan.plan_type === '系统任务'">
<!-- Only Delay Task for now -->
<el-option label="延时任务" value="delay_task"></el-option>
</el-select>
</el-form-item>
<el-form-item label="任务名称" prop="name">
<el-input v-model="currentTaskForm.name" placeholder="请输入任务名称"></el-input>
<el-input v-model="currentTaskForm.name" placeholder="请输入任务名称" :disabled="plan.plan_type === '系统任务'"></el-input>
</el-form-item>
<el-form-item label="任务描述" prop="description">
<el-input type="textarea" v-model="currentTaskForm.description" placeholder="请输入任务描述"></el-input>
<el-input type="textarea" v-model="currentTaskForm.description" placeholder="请输入任务描述" :disabled="plan.plan_type === '系统任务'"></el-input>
</el-form-item>
<!-- Dynamic task component for specific parameters -->
<template v-if="currentTaskForm.type === 'delay_task'">
@@ -153,6 +155,7 @@
@update:parameters="val => currentTaskForm.parameters = val"
prop-path="parameters.delay_duration"
:is-editing="true"
:disabled="plan.plan_type === '系统任务'"
/>
</template>
<!-- More task types can be rendered here -->
@@ -160,7 +163,7 @@
<template #footer>
<span class="dialog-footer">
<el-button @click="taskEditorDialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirmTaskEdit">确定</el-button>
<el-button type="primary" @click="confirmTaskEdit" :disabled="plan.plan_type === '系统任务'">确定</el-button>
</span>
</template>
</el-dialog>
@@ -355,7 +358,7 @@ export default {
},
async fetchAvailablePlans() {
try {
const response = await apiClient.plans.getPlans(); // 更正此处
const response = await apiClient.plans.getPlans({ planType: '自定义任务' });
this.availablePlans = response.data.plans.filter(p =>
p.id !== this.planId
);
@@ -483,7 +486,8 @@ export default {
} else {
ElMessage.error('未找到要编辑的任务');
}
} else {
}
else {
// Add a new task
const newTask = {
id: Date.now(),