feat:新增设备管理、点位字典页面-数据mock

master
黄伟杰 2 months ago
parent fa8cf761fd
commit 585bb26971

File diff suppressed because it is too large Load Diff

@ -0,0 +1,683 @@
<template>
<ContentWrap>
<div class="point-dict">
<!-- 左侧设备树 -->
<div class="point-dict__left">
<el-card shadow="never" class="point-dict__panel left-panel">
<div class="left-panel__search">
<el-input
v-model="searchKeyword"
placeholder="搜索设备..."
clearable
:prefix-icon="Search"
/>
</div>
<div class="left-panel__stats">
<div class="stat-item">
<el-icon><OfficeBuilding /></el-icon> : 3
</div>
<div class="stat-item">
<el-icon><Monitor /></el-icon> : 8
</div>
</div>
<el-tree
ref="treeRef"
:data="treeData"
node-key="id"
default-expand-all
:props="treeProps"
highlight-current
:filter-node-method="filterNode"
@node-click="handleNodeClick"
class="left-panel__tree"
>
<template #default="{ node, data }">
<div class="custom-tree-node">
<div class="node-left">
<el-icon v-if="data.type !== 'device'" class="node-icon folder-icon">
<FolderOpened v-if="node.expanded" />
<Folder v-else />
</el-icon>
<span
v-if="data.type === 'device'"
class="node-status-dot"
:class="{ 'is-online': data.online }"
></span>
<span class="node-label" :class="{ 'is-device': data.type === 'device' }">{{
data.name
}}</span>
</div>
<div v-if="data.type === 'device'" class="node-right">
<span class="node-code-tag">{{ data.code }}</span>
</div>
</div>
</template>
</el-tree>
</el-card>
</div>
<!-- 右侧点位配置 -->
<div class="point-dict__right">
<template v-if="currentDevice">
<!-- 顶部设备信息卡片 -->
<div class="right-header">
<div class="header-left">
<div class="header-title-row">
<span class="header-dot" :class="{ 'is-online': currentDevice.online }"></span>
<span class="header-title">{{ currentDevice.name }}</span>
</div>
<div class="header-code-row">
<span class="header-code">{{ currentDevice.code }}</span>
</div>
</div>
<div class="header-right">
<el-button class="header-add-btn">
<el-icon class="mr-4px"><Plus /></el-icon>
</el-button>
<div class="header-count-box">
<div class="count-label">点位数量</div>
<div class="count-value">{{ totalPoints }}</div>
</div>
</div>
</div>
<!-- 点位分组列表 -->
<div class="right-content">
<div v-for="group in pointGroups" :key="group.name" class="point-group">
<div class="group-header">
<div class="group-title">
<el-icon class="group-icon"><Folder /></el-icon>
<span>{{ group.name }}</span>
</div>
<div class="group-count">{{ group.points.length }} 个点位</div>
</div>
<div class="group-list">
<div v-for="point in group.points" :key="point.id" class="point-card">
<div class="point-card__main">
<span class="point-code">{{ point.code }}</span>
<span class="point-name">{{ point.name }}</span>
<div class="point-value-wrap">
<span class="point-value">{{ point.value }}</span>
<span class="point-unit">{{ point.unit }}</span>
</div>
<el-tag size="small" class="point-type-tag" round>{{ point.type }}</el-tag>
</div>
<div class="point-card__actions">
<el-checkbox v-model="point.history" size="small" class="action-checkbox"></el-checkbox>
<el-button link type="warning" size="small" class="action-btn">编辑</el-button>
<el-button link type="danger" size="small" class="action-btn">删除</el-button>
</div>
<div class="point-card__meta">
<span class="meta-item">更新: {{ point.updatedAt }}</span>
<span class="meta-item">{{ point.desc }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<div v-else class="empty-wrap">
<el-empty description="请在左侧选择设备" />
</div>
</div>
</div>
</ContentWrap>
</template>
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { Search, OfficeBuilding, Monitor, Folder, FolderOpened, Plus } from '@element-plus/icons-vue'
defineOptions({ name: 'IoTDevicePointDict' })
const searchKeyword = ref('')
const treeRef = ref()
const treeProps = {
children: 'children',
label: 'name'
}
// Mock Tree Data
const treeData = ref([
{
id: 'c1',
type: 'company',
name: '北京科技有限公司',
children: [
{
id: 'c1-l1',
type: 'line',
name: 'SMT产线A',
children: [
{
id: 'd-1001',
type: 'device',
name: '贴片机#1',
code: 'BJ-PL01-DEV01',
online: true
},
{
id: 'd-1002',
type: 'device',
name: '贴片机#2',
code: 'BJ-PL01-DEV02',
online: true
}
]
},
{
id: 'c1-l2',
type: 'line',
name: 'SMT产线B',
children: []
}
]
},
{
id: 'c2',
type: 'company',
name: '上海智能科技股份公司',
children: []
},
{
id: 'c3',
type: 'company',
name: '广州数据服务有限公司',
children: []
}
])
const currentDeviceId = ref('d-1001')
const flattenDevices = (nodes: any[]) => {
let list: any[] = []
nodes.forEach(node => {
if (node.type === 'device') {
list.push(node)
}
if (node.children) {
list = list.concat(flattenDevices(node.children))
}
})
return list
}
const allDevices = computed(() => flattenDevices(treeData.value))
const currentDevice = computed(() => allDevices.value.find(d => d.id === currentDeviceId.value))
const filterNode = (value: string, data: any) => {
if (!value) return true
return data.name.includes(value) || (data.code && data.code.includes(value))
}
watch(searchKeyword, (val) => {
treeRef.value?.filter(val)
})
const handleNodeClick = (data: any) => {
if (data.type === 'device') {
currentDeviceId.value = data.id
}
}
// Mock Point Groups Data
const pointGroups = ref([
{
name: '环境参数',
points: [
{
id: 'p1',
code: 'temperature',
name: '温度',
value: 45.2,
unit: '℃',
type: '数值',
history: true,
updatedAt: '2026-03-10 10:30:00',
desc: '设备环境温度'
},
{
id: 'p2',
code: 'humidity',
name: '湿度',
value: 65.8,
unit: '%',
type: '数值',
history: true,
updatedAt: '2026-03-10 10:30:00',
desc: '设备环境湿度'
},
{
id: 'p3',
code: 'pressure',
name: '压力',
value: 0.85,
unit: 'MPa',
type: '数值',
history: true,
updatedAt: '2026-03-10 10:30:00',
desc: '系统压力'
}
]
},
{
name: '运行参数',
points: [
{
id: 'p4',
code: 'speed',
name: '运行速度',
value: 120,
unit: 'm/min',
type: '数值',
history: true,
updatedAt: '2026-03-10 10:30:00',
desc: '设备运行速度'
},
{
id: 'p5',
code: 'power',
name: '功率',
value: 8.5,
unit: 'kW',
type: '数值',
history: true,
updatedAt: '2026-03-10 10:30:00',
desc: '设备功率'
}
]
}
])
const totalPoints = computed(() => {
return pointGroups.value.reduce((sum, group) => sum + group.points.length, 0)
})
</script>
<style scoped lang="scss">
.point-dict {
display: flex;
gap: 16px;
height: calc(100vh - 120px);
min-height: 500px;
}
.point-dict__left {
flex: 0 0 280px;
display: flex;
flex-direction: column;
}
.left-panel {
flex: 1;
display: flex;
flex-direction: column;
border-radius: 8px;
overflow: hidden;
:deep(.el-card__body) {
padding: 16px;
display: flex;
flex-direction: column;
height: 100%;
box-sizing: border-box;
}
}
.left-panel__search {
margin-bottom: 16px;
}
.left-panel__stats {
display: flex;
gap: 12px;
margin-bottom: 16px;
.stat-item {
background-color: var(--el-fill-color-light);
padding: 6px 12px;
border-radius: 6px;
font-size: 12px;
color: var(--el-text-color-secondary);
display: flex;
align-items: center;
gap: 6px;
}
}
.left-panel__tree {
flex: 1;
overflow-y: auto;
margin-right: -8px;
padding-right: 8px;
:deep(.el-tree-node__content) {
height: 36px;
border-radius: 6px;
margin-bottom: 2px;
}
:deep(.el-tree-node.is-current > .el-tree-node__content) {
background-color: var(--el-color-primary-light-9);
color: var(--el-color-primary);
.node-code-tag {
background-color: #fff;
color: var(--el-color-primary);
border-color: var(--el-color-primary-light-5);
}
}
}
.custom-tree-node {
display: flex;
flex: 1;
align-items: center;
justify-content: space-between;
padding-right: 8px;
min-width: 0;
}
.node-left {
display: flex;
align-items: center;
gap: 8px;
overflow: hidden;
}
.folder-icon {
color: var(--el-text-color-secondary);
font-size: 14px;
}
.node-status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: var(--el-text-color-disabled);
&.is-online {
background-color: var(--el-color-success);
}
}
.node-label {
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&.is-device {
font-size: 13px;
}
}
.node-right {
flex-shrink: 0;
}
.node-code-tag {
font-size: 11px;
background-color: var(--el-fill-color);
color: var(--el-text-color-secondary);
padding: 2px 6px;
border-radius: 4px;
border: 1px solid var(--el-border-color-lighter);
}
.point-dict__right {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
background-color: var(--el-bg-color);
border-radius: 8px;
overflow: hidden;
}
.empty-wrap {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
/* Header */
.right-header {
height: 88px;
background: linear-gradient(135deg, #705df2 0%, #5145c2 100%);
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 32px;
flex-shrink: 0;
border-radius: 8px 8px 0 0;
}
.header-left {
display: flex;
flex-direction: column;
gap: 8px;
}
.header-title-row {
display: flex;
align-items: center;
gap: 12px;
}
.header-dot {
width: 14px;
height: 14px;
border-radius: 50%;
background-color: var(--el-text-color-disabled);
border: 2px solid rgba(255, 255, 255, 0.2);
&.is-online {
background-color: #67c23a;
box-shadow: 0 0 0 2px rgba(103, 194, 58, 0.2);
}
}
.header-title {
color: #fff;
font-size: 22px;
font-weight: 600;
letter-spacing: 0.5px;
}
.header-code {
background-color: rgba(255, 255, 255, 0.15);
color: #fff;
font-size: 12px;
padding: 3px 10px;
border-radius: 4px;
font-family: monospace;
}
.header-right {
display: flex;
align-items: center;
gap: 32px;
}
.header-add-btn {
background-color: rgba(255, 255, 255, 0.15);
border: 1px solid rgba(255, 255, 255, 0.3);
color: #fff;
&:hover {
background-color: rgba(255, 255, 255, 0.25);
color: #fff;
border-color: rgba(255, 255, 255, 0.4);
}
}
.header-count-box {
display: flex;
flex-direction: column;
align-items: flex-end;
color: #fff;
}
.count-label {
font-size: 12px;
opacity: 0.8;
margin-bottom: 2px;
}
.count-value {
font-size: 28px;
font-weight: bold;
line-height: 1;
}
/* Content */
.right-content {
flex: 1;
overflow-y: auto;
padding: 24px 32px;
background-color: var(--el-fill-color-blank);
}
.point-group {
margin-bottom: 32px;
}
.group-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid var(--el-border-color-lighter);
}
.group-title {
display: flex;
align-items: center;
gap: 8px;
font-size: 16px;
font-weight: bold;
color: var(--el-text-color-primary);
.group-icon {
color: #e6a23c;
font-size: 18px;
}
}
.group-count {
font-size: 13px;
color: var(--el-text-color-secondary);
}
.group-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.point-card {
background-color: var(--el-bg-color);
border: 1px solid var(--el-border-color-light);
border-left: 4px solid #f5c05c;
border-radius: 8px;
padding: 16px 20px;
transition: all 0.3s;
&:hover {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
border-color: var(--el-border-color);
border-left-color: #f5c05c;
}
}
.point-card__main {
display: flex;
align-items: center;
margin-bottom: 16px;
}
.point-code {
background-color: var(--el-fill-color);
color: var(--el-text-color-secondary);
font-family: monospace;
font-size: 13px;
padding: 4px 10px;
border-radius: 4px;
}
.point-name {
font-size: 16px;
font-weight: bold;
color: var(--el-text-color-primary);
margin-left: 16px;
min-width: 80px;
}
.point-value-wrap {
margin-left: 40px;
display: flex;
align-items: baseline;
gap: 4px;
}
.point-value {
font-size: 22px;
font-weight: bold;
color: var(--el-color-primary);
}
.point-unit {
font-size: 13px;
color: var(--el-text-color-secondary);
}
.point-type-tag {
margin-left: 24px;
background-color: var(--el-color-primary-light-9);
color: var(--el-color-primary);
border: none;
}
.point-card__actions {
display: flex;
align-items: center;
gap: 16px;
margin-bottom: 8px;
}
.action-checkbox {
:deep(.el-checkbox__label) {
color: var(--el-color-primary);
font-size: 13px;
}
}
.action-btn {
font-size: 13px;
padding: 0;
height: auto;
}
.point-card__meta {
display: flex;
gap: 16px;
font-size: 12px;
color: var(--el-text-color-secondary);
}
@media (max-width: 1200px) {
.point-dict {
flex-direction: column;
height: auto;
}
.point-dict__left {
width: 100%;
flex: none;
height: 400px;
}
.right-header {
padding: 0 20px;
}
}
</style>
Loading…
Cancel
Save