优化展示
This commit is contained in:
@@ -114,6 +114,8 @@ export default {
|
||||
|
||||
try {
|
||||
const data = await deviceService.getDevices();
|
||||
// Default sort by ID ascending
|
||||
data.sort((a, b) => a.id - b.id);
|
||||
this.allDevices = data;
|
||||
this.tableData = this.buildTreeData(data);
|
||||
this.originalTableData = [...this.tableData]; // 保存原始顺序
|
||||
|
||||
@@ -52,8 +52,9 @@
|
||||
<el-table-column prop="execute_count" label="已执行次数" min-width="120" sortable="custom" />
|
||||
<el-table-column prop="status" label="状态" min-width="100" sortable="custom">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.status === 0" type="danger">禁用</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 1" type="success">启用</el-tag>
|
||||
<el-tag v-if="scope.row.status === 0" type="danger">禁用计划</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 1" type="success">启用计划</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 3" type="danger">执行失败</el-tag>
|
||||
<el-tag v-else type="info">执行完毕</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -66,11 +67,13 @@
|
||||
<template #default="scope">
|
||||
<el-button size="small" @click="editPlan(scope.row)">编辑</el-button>
|
||||
<el-button size="small" @click="showDetails(scope.row)">详情</el-button>
|
||||
<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
|
||||
size="small"
|
||||
:type="scope.row.status === 1 ? 'warning' : 'primary'"
|
||||
@click="scope.row.status === 1 ? stopPlan(scope.row) : startPlan(scope.row)"
|
||||
:loading="stoppingPlanId === scope.row.id || startingPlanId === scope.row.id"
|
||||
>
|
||||
{{ scope.row.status === 1 ? '停止' : '启动' }}
|
||||
</el-button>
|
||||
<el-button size="small" type="danger" @click="deletePlan(scope.row)">删除</el-button>
|
||||
</template>
|
||||
@@ -156,7 +159,10 @@ export default {
|
||||
|
||||
try {
|
||||
const response = await apiClient.plans.list();
|
||||
this.plans = response.data?.plans || [];
|
||||
let fetchedPlans = response.data?.plans || [];
|
||||
// Default sort by ID ascending
|
||||
fetchedPlans.sort((a, b) => a.id - b.id);
|
||||
this.plans = fetchedPlans;
|
||||
this.originalPlans = [...this.plans]; // Keep a copy of the original order
|
||||
} catch (err) {
|
||||
this.error = err.message || '未知错误';
|
||||
|
||||
Reference in New Issue
Block a user