1. 调整计划列表展示项
2. 调整设备列表展示项
This commit is contained in:
@@ -3,7 +3,12 @@
|
|||||||
<el-card>
|
<el-card>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="page-title">设备管理</h2>
|
<div class="title-container">
|
||||||
|
<h2 class="page-title">设备管理</h2>
|
||||||
|
<el-button type="text" @click="loadDevices" class="refresh-btn" title="刷新设备列表">
|
||||||
|
<el-icon :size="20"><Refresh /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
<el-button type="primary" @click="addDevice">添加设备</el-button>
|
<el-button type="primary" @click="addDevice">添加设备</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -37,7 +42,8 @@
|
|||||||
default-expand-all
|
default-expand-all
|
||||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||||
:row-class-name="tableRowClassName"
|
:row-class-name="tableRowClassName"
|
||||||
:highlight-current-row="false">
|
:highlight-current-row="false"
|
||||||
|
:scrollbar-always-on="true">
|
||||||
<el-table-column width="40"></el-table-column>
|
<el-table-column width="40"></el-table-column>
|
||||||
<el-table-column prop="name" label="设备名称" min-width="120" />
|
<el-table-column prop="name" label="设备名称" min-width="120" />
|
||||||
<el-table-column prop="type" label="设备类型" min-width="100">
|
<el-table-column prop="type" label="设备类型" min-width="100">
|
||||||
@@ -72,13 +78,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { Refresh } from '@element-plus/icons-vue';
|
||||||
import deviceService from '../services/deviceService.js';
|
import deviceService from '../services/deviceService.js';
|
||||||
import DeviceForm from './DeviceForm.vue';
|
import DeviceForm from './DeviceForm.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'DeviceList',
|
name: 'DeviceList',
|
||||||
components: {
|
components: {
|
||||||
DeviceForm
|
DeviceForm,
|
||||||
|
Refresh // 导入刷新图标组件
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -234,10 +242,29 @@ export default {
|
|||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.refresh-btn {
|
||||||
|
color: black;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-footer {
|
.dialog-footer {
|
||||||
@@ -266,7 +293,6 @@ export default {
|
|||||||
.device-list {
|
.device-list {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
|
|||||||
@@ -3,30 +3,58 @@
|
|||||||
<el-card>
|
<el-card>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="page-title">计划管理</h2>
|
<div class="title-container">
|
||||||
|
<h2 class="page-title">计划管理</h2>
|
||||||
|
<el-button type="text" @click="loadPlans" class="refresh-btn" title="刷新计划列表">
|
||||||
|
<el-icon :size="20"><Refresh /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
<el-button type="primary" @click="addPlan">添加计划</el-button>
|
<el-button type="primary" @click="addPlan">添加计划</el-button>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-table :data="plans" style="width: 100%" table-layout="auto" fit>
|
<!-- 加载状态 -->
|
||||||
<el-table-column prop="name" label="计划名称" />
|
<div v-if="loading" class="loading">
|
||||||
<el-table-column prop="description" label="计划描述" />
|
<el-skeleton animated />
|
||||||
<el-table-column prop="execution_type" label="执行类型">
|
</div>
|
||||||
|
|
||||||
|
<!-- 错误状态 -->
|
||||||
|
<div v-else-if="error" class="error">
|
||||||
|
<el-alert
|
||||||
|
title="获取计划数据失败"
|
||||||
|
:description="error"
|
||||||
|
type="error"
|
||||||
|
show-icon
|
||||||
|
closable
|
||||||
|
@close="error = null"
|
||||||
|
/>
|
||||||
|
<el-button type="primary" @click="loadPlans" class="retry-btn">重新加载</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table
|
||||||
|
v-else
|
||||||
|
:data="plans"
|
||||||
|
style="width: 100%"
|
||||||
|
:fit="true"
|
||||||
|
:scrollbar-always-on="true">
|
||||||
|
<el-table-column prop="name" label="计划名称" min-width="120" />
|
||||||
|
<el-table-column prop="description" label="计划描述" min-width="150" />
|
||||||
|
<el-table-column prop="execution_type" label="执行类型" min-width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag v-if="scope.row.execution_type === 'manual'">手动</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-if="scope.row.execute_num === 0" type="success">自动(无限执行)</el-tag>
|
||||||
<el-tag v-else type="warning">自动({{ scope.row.execute_num }}次)</el-tag>
|
<el-tag v-else type="warning">自动({{ scope.row.execute_num }}次)</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="execute_count" label="已执行次数" />
|
<el-table-column prop="execute_count" label="已执行次数" min-width="100" />
|
||||||
<el-table-column prop="status" label="状态">
|
<el-table-column prop="status" label="状态" min-width="100">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-tag v-if="scope.row.status === 0" type="danger">禁用</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 === 1" type="success">启用</el-tag>
|
||||||
<el-tag v-else type="info">执行完毕</el-tag>
|
<el-tag v-else type="info">执行完毕</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="cron_expression" label="下次执行时间">
|
<el-table-column prop="cron_expression" label="下次执行时间" min-width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
{{ formatNextExecutionTime(scope.row.cron_expression) }}
|
{{ formatNextExecutionTime(scope.row.cron_expression) }}
|
||||||
</template>
|
</template>
|
||||||
@@ -41,6 +69,7 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
<!-- 使用新的计划表单组件 -->
|
<!-- 使用新的计划表单组件 -->
|
||||||
@@ -55,6 +84,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { Refresh } from '@element-plus/icons-vue';
|
||||||
import apiClient from '../api/index.js';
|
import apiClient from '../api/index.js';
|
||||||
import PlanForm from './PlanForm.vue';
|
import PlanForm from './PlanForm.vue';
|
||||||
import cronParser from 'cron-parser';
|
import cronParser from 'cron-parser';
|
||||||
@@ -62,13 +92,16 @@ import cronParser from 'cron-parser';
|
|||||||
export default {
|
export default {
|
||||||
name: 'PlanList',
|
name: 'PlanList',
|
||||||
components: {
|
components: {
|
||||||
PlanForm
|
PlanForm,
|
||||||
|
Refresh
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
plans: [],
|
plans: [],
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
|
loading: false,
|
||||||
|
error: null,
|
||||||
currentPlan: {
|
currentPlan: {
|
||||||
id: null,
|
id: null,
|
||||||
name: '',
|
name: '',
|
||||||
@@ -86,12 +119,17 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
// 加载计划列表
|
// 加载计划列表
|
||||||
async loadPlans() {
|
async loadPlans() {
|
||||||
|
this.loading = true;
|
||||||
|
this.error = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await apiClient.plans.list();
|
const response = await apiClient.plans.list();
|
||||||
this.plans = response.data?.plans || [];
|
this.plans = response.data?.plans || [];
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.$message.error('加载计划列表失败: ' + (err.message || '未知错误'));
|
this.error = err.message || '未知错误';
|
||||||
console.error('加载计划列表失败:', err);
|
console.error('加载计划列表失败:', err);
|
||||||
|
} finally {
|
||||||
|
this.loading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -209,21 +247,48 @@ export default {
|
|||||||
padding: 15px 0;
|
padding: 15px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.page-title {
|
.page-title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1.5rem;
|
font-size: 1.5rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-footer {
|
.refresh-btn {
|
||||||
text-align: right;
|
color: black;
|
||||||
|
background-color: transparent;
|
||||||
|
padding: 0;
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
padding: 20px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
padding: 20px 0;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.retry-btn {
|
||||||
|
margin-top: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
@media (max-width: 768px) {
|
||||||
.plan-list {
|
.plan-list {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
|
|||||||
39
src/views/plan/PlanList.vue
Normal file
39
src/views/plan/PlanList.vue
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<el-table :data="planList">
|
||||||
|
<el-table-column prop="executeType" label="执行类型">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag
|
||||||
|
v-if="row.executeType === 'manual'"
|
||||||
|
type=""
|
||||||
|
class="full-width-tag"
|
||||||
|
>
|
||||||
|
手动
|
||||||
|
</el-tag>
|
||||||
|
<el-tag
|
||||||
|
v-else-if="row.executeType === 'auto-infinite'"
|
||||||
|
type="success"
|
||||||
|
class="full-width-tag"
|
||||||
|
>
|
||||||
|
自动(无限执行)
|
||||||
|
</el-tag>
|
||||||
|
<el-tag
|
||||||
|
v-else-if="row.executeType === 'auto-limited'"
|
||||||
|
type="warning"
|
||||||
|
class="full-width-tag"
|
||||||
|
>
|
||||||
|
自动({{ row.executeTimes }}次)
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.full-width-tag {
|
||||||
|
/* 移除默认的宽度限制和文本溢出处理 */
|
||||||
|
max-width: none !important;
|
||||||
|
overflow: visible !important;
|
||||||
|
white-space: normal !important;
|
||||||
|
word-wrap: break-word !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user