|
|
@@ -1,217 +1,56 @@
|
|
|
<template>
|
|
|
<SplitterCollapse>
|
|
|
<SplitterCollapseItem title="屏幕页面">
|
|
|
+ <!-- 屏幕层 -->
|
|
|
<el-tree
|
|
|
ref="treeRef"
|
|
|
style="max-width: 600px"
|
|
|
- :data="screenData"
|
|
|
default-expand-all
|
|
|
node-key="id"
|
|
|
highlight-current
|
|
|
+ check-on-click-node
|
|
|
+ :default-checked-keys="projectStore.activePageId ? [projectStore.activePageId] : []"
|
|
|
+ :data="projectStore.project?.screens"
|
|
|
:props="{ label: 'name', children: 'pages' }"
|
|
|
- :render-content="renderScreen"
|
|
|
- />
|
|
|
+ @node-click="handleNodeClick"
|
|
|
+ >
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <ScreenTreeItem :node="node" :data="data" />
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
</SplitterCollapseItem>
|
|
|
<SplitterCollapseItem title="图层">
|
|
|
+ <!-- 页面层 -->
|
|
|
<el-tree
|
|
|
ref="treeRef"
|
|
|
style="max-width: 600px"
|
|
|
- :data="widgetData"
|
|
|
+ :data="projectStore.activePage?.children"
|
|
|
default-expand-all
|
|
|
node-key="id"
|
|
|
highlight-current
|
|
|
+ check-on-click-node
|
|
|
:props="{ label: 'name' }"
|
|
|
- :render-content="renderPage"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <template #default="{ node, data }">
|
|
|
+ <PageTreeItem :node="node" :data="data" />
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
</SplitterCollapseItem>
|
|
|
</SplitterCollapse>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { SplitterCollapse, SplitterCollapseItem } from '@/components/SplitterCollapse'
|
|
|
-import {
|
|
|
- LuTrash2,
|
|
|
- LuLock,
|
|
|
- LuUnlock,
|
|
|
- LuEye,
|
|
|
- LuEyeOff,
|
|
|
- LuMonitor,
|
|
|
- LuPanelsTopLeft,
|
|
|
- LuBox
|
|
|
-} from 'vue-icons-plus/lu'
|
|
|
-import type { RenderContentFunction } from 'element-plus'
|
|
|
-// 屏幕页面数据
|
|
|
-const screenData = [
|
|
|
- {
|
|
|
- id: 'screen_1',
|
|
|
- name: '主屏',
|
|
|
- type: 'screen',
|
|
|
- backgroundColor: '#ffffff',
|
|
|
- width: 0,
|
|
|
- height: 0,
|
|
|
- hidden: false,
|
|
|
- locked: false,
|
|
|
- pages: [
|
|
|
- {
|
|
|
- id: 'page_1',
|
|
|
- name: '启动页',
|
|
|
- type: 'page',
|
|
|
- hidden: false,
|
|
|
- locked: false,
|
|
|
- referenceLine: [
|
|
|
- {
|
|
|
- id: 'r_1',
|
|
|
- layout: 'horizontal',
|
|
|
- position: 0,
|
|
|
- visible: true
|
|
|
- }
|
|
|
- ],
|
|
|
- props: {},
|
|
|
- style: {},
|
|
|
- events: [],
|
|
|
- variable: [],
|
|
|
- method: [],
|
|
|
- children: []
|
|
|
- },
|
|
|
- {
|
|
|
- id: 'page_2',
|
|
|
- name: '详情页',
|
|
|
- type: 'page',
|
|
|
- hidden: false,
|
|
|
- locked: false,
|
|
|
- referenceLine: [
|
|
|
- {
|
|
|
- id: 'r_1',
|
|
|
- layout: 'horizontal',
|
|
|
- position: 0,
|
|
|
- visible: true
|
|
|
- }
|
|
|
- ],
|
|
|
- props: {},
|
|
|
- style: {},
|
|
|
- events: [],
|
|
|
- variable: [],
|
|
|
- method: [],
|
|
|
- children: []
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
-]
|
|
|
+import ScreenTreeItem from './components/ScreenTreeItem.vue'
|
|
|
+import PageTreeItem from './components/PageTreeItem.vue'
|
|
|
+import { useProjectStore } from '@/store/modules/project'
|
|
|
|
|
|
-// 图层数据
|
|
|
-const widgetData = [
|
|
|
- {
|
|
|
- id: 'widget_1',
|
|
|
- name: '按钮',
|
|
|
- type: 'widget',
|
|
|
- hidden: false,
|
|
|
- locked: false,
|
|
|
- props: {},
|
|
|
- style: {},
|
|
|
- events: [],
|
|
|
- variable: [],
|
|
|
- method: []
|
|
|
- }
|
|
|
-]
|
|
|
+const projectStore = useProjectStore()
|
|
|
|
|
|
-const renderScreen: RenderContentFunction = (h, { node, data }) => {
|
|
|
- return h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- width: '100%',
|
|
|
- display: 'flex',
|
|
|
- 'justify-content': 'space-between',
|
|
|
- 'align-items': 'center'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- display: 'flex',
|
|
|
- 'align-items': 'center',
|
|
|
- gap: '8px',
|
|
|
- paddingRight: '8px'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(data.type === 'screen' ? LuMonitor : LuPanelsTopLeft, {
|
|
|
- style: { color: 'var(--text-secondary)' },
|
|
|
- size: 14
|
|
|
- }),
|
|
|
- h('span', null, node.label)
|
|
|
- ]
|
|
|
- ),
|
|
|
- h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- display: 'flex',
|
|
|
- 'align-items': 'center',
|
|
|
- gap: '8px',
|
|
|
- paddingRight: '8px'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(LuTrash2, { style: { color: 'var(--text-secondary)' }, size: 14 }),
|
|
|
- h(LuEye, { style: { color: 'var(--text-secondary)' }, size: 14 }),
|
|
|
- h(LuLock, { style: { color: 'var(--text-secondary)' }, size: 14 })
|
|
|
- ]
|
|
|
- )
|
|
|
- ]
|
|
|
- )
|
|
|
-}
|
|
|
-
|
|
|
-const renderPage: RenderContentFunction = (h, { node, data }) => {
|
|
|
- return h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- width: '100%',
|
|
|
- display: 'flex',
|
|
|
- 'justify-content': 'space-between',
|
|
|
- 'align-items': 'center'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- display: 'flex',
|
|
|
- 'align-items': 'center',
|
|
|
- gap: '8px',
|
|
|
- paddingRight: '8px'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(data.type === 'page' ? LuPanelsTopLeft : LuBox, {
|
|
|
- style: { color: 'var(--text-secondary)' },
|
|
|
- size: 14
|
|
|
- }),
|
|
|
- h('span', null, node.label)
|
|
|
- ]
|
|
|
- ),
|
|
|
- h(
|
|
|
- 'div',
|
|
|
- {
|
|
|
- style: {
|
|
|
- display: 'flex',
|
|
|
- 'align-items': 'center',
|
|
|
- gap: '8px',
|
|
|
- paddingRight: '8px'
|
|
|
- }
|
|
|
- },
|
|
|
- [
|
|
|
- h(LuTrash2, { style: { color: 'var(--text-secondary)' }, size: 14 }),
|
|
|
- h(LuEye, { style: { color: 'var(--text-secondary)' }, size: 14 }),
|
|
|
- h(LuLock, { style: { color: 'var(--text-secondary)' }, size: 14 })
|
|
|
- ]
|
|
|
- )
|
|
|
- ]
|
|
|
- )
|
|
|
+const handleNodeClick = (node: any) => {
|
|
|
+ if (node.type === 'page') {
|
|
|
+ projectStore.activePageId = node.id
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|