1. 调整计划列表展示项
2. 调整设备列表展示项
This commit is contained in:
@@ -8,21 +8,27 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table :data="plans" style="width: 100%">
|
||||
<el-table-column prop="id" label="计划ID" width="80" />
|
||||
<el-table-column prop="name" label="计划名称" width="180" />
|
||||
<el-table-column prop="description" label="描述" />
|
||||
<el-table-column prop="execution_type" label="执行类型" width="120">
|
||||
<el-table :data="plans" style="width: 100%" table-layout="auto" fit>
|
||||
<el-table-column prop="name" label="计划名称" />
|
||||
<el-table-column prop="description" label="计划描述" />
|
||||
<el-table-column prop="execution_type" label="执行类型">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.execution_type === 'automatic'">自动</el-tag>
|
||||
<el-tag v-else>手动</el-tag>
|
||||
<el-tag v-if="scope.row.execution_type === 'manual'">手动</el-tag>
|
||||
<el-tag v-else-if="scope.row.execute_num === 0" type="success">自动(无限执行)</el-tag>
|
||||
<el-tag v-else type="warning">自动({{ scope.row.execute_num }}次)</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<el-table-column prop="execute_count" label="已执行次数" />
|
||||
<el-table-column prop="status" label="状态">
|
||||
<template #default="scope">
|
||||
<el-tag v-if="scope.row.status === 0" type="success">启用</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 1" type="warning">禁用</el-tag>
|
||||
<el-tag v-else type="info">已完成</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 type="info">执行完毕</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="cron_expression" label="下次执行时间">
|
||||
<template #default="scope">
|
||||
{{ formatNextExecutionTime(scope.row.cron_expression) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200">
|
||||
@@ -51,6 +57,7 @@
|
||||
<script>
|
||||
import apiClient from '../api/index.js';
|
||||
import PlanForm from './PlanForm.vue';
|
||||
import cronParser from 'cron-parser';
|
||||
|
||||
export default {
|
||||
name: 'PlanList',
|
||||
@@ -88,6 +95,24 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化下次执行时间
|
||||
formatNextExecutionTime(cronExpression) {
|
||||
if (!cronExpression) {
|
||||
return '-';
|
||||
}
|
||||
|
||||
try {
|
||||
// 正确使用cron-parser库
|
||||
const parser = cronParser.default || cronParser;
|
||||
const interval = parser.parse(cronExpression);
|
||||
const next = interval.next().toDate();
|
||||
return next.toLocaleString('zh-CN');
|
||||
} catch (err) {
|
||||
console.error('解析cron表达式失败:', err);
|
||||
return '无效的表达式';
|
||||
}
|
||||
},
|
||||
|
||||
addPlan() {
|
||||
this.currentPlan = {
|
||||
id: null,
|
||||
|
||||
Reference in New Issue
Block a user