| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <template>
- <div class="model-management">
- <!-- 页面头部 -->
- <PageHeader />
- <!-- 主要内容区域 -->
- <main class="main-content">
- <!-- 左侧垂直菜单 -->
- <aside class="left-sidebar">
- <el-menu :model-value="activeMenu" class="el-menu-vertical-demo" background-color="#f8f9fa" text-color="#303133" active-text-color="#409eff" style="height: 100%; margin: 0;" @open="handleOpen" @close="handleClose" @select="(key) => handleMenuSelect(key)">
- <el-menu-item-group>
- <template #title><span style="font-size: 1.45rem; font-weight: 600; color: #303133;">项目分类</span></template>
-
- <!-- 数字孪生分类 -->
- <el-sub-menu index="1">
- <template #title>
- <el-icon><Menu /></el-icon>
- <span>数字孪生</span>
- </template>
- <el-menu-item index="1-1">数字孪生太浦河</el-menu-item>
- <el-menu-item index="1-2">数字孪生水文站</el-menu-item>
- <el-menu-item index="1-3">数字孪生灌区</el-menu-item>
- </el-sub-menu>
-
- <!-- 水利信息化分类 -->
- <el-sub-menu index="2">
- <template #title>
- <el-icon><Menu /></el-icon>
- <span>水利信息化</span>
- </template>
- <el-menu-item index="2-1">流域数据采集</el-menu-item>
- </el-sub-menu>
- </el-menu-item-group>
- </el-menu>
- </aside>
- <!-- 右侧内容区域 -->
- <section class="right-content">
- <!-- 面包屑导航已移除 -->
- <component :is="activeComponent" ref="shuiliGongchengRef" />
- </section>
- </main>
-
- </div>
- </template>
- <script setup>
- import PageHeader from './PageHeader.vue'
- import { ref, shallowRef, markRaw } from 'vue'
- import { Menu, Setting, House } from '@element-plus/icons-vue'
- import ShuiliGongcheng from './content/ShuiliGongcheng.vue'
- import JidianShebei from './content/JidianShebei.vue'
- import ShuiliSheshi from './content/ShuiliSheshi.vue'
- // 创建一个可响应的引用,用于访问ShuiliGongcheng组件的实例
- const shuiliGongchengRef = ref(null)
- // 使用markRaw标记组件,避免Vue将其转换为响应式对象
- const ShuiliGongchengRaw = markRaw(ShuiliGongcheng)
- const JidianShebeiRaw = markRaw(JidianShebei)
- const ShuiliSheshiRaw = markRaw(ShuiliSheshi)
- const activeMenu = ref('1')
- const activeMenuName = ref('数字孪生')
- const activeComponent = ref(ShuiliGongchengRaw)
- const handleOpen = (key, keyPath) => {
- console.log('Menu opened:', key, keyPath)
- if (key === '1') {
- activeMenu.value = key
- activeMenuName.value = '数字孪生'
- activeComponent.value = ShuiliGongchengRaw
- console.log('Set active component to ShuiliGongcheng')
-
- // 当打开数字孪生大类时,显示所有数字孪生项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生')
- }
- } else if (key === '2') {
- activeMenu.value = key
- activeMenuName.value = '水利信息化'
- activeComponent.value = ShuiliGongchengRaw
- console.log('Set active component to ShuiliGongcheng')
-
- // 当打开水利信息化大类时,显示所有水利信息化项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('水利信息化')
- }
- }
- }
- const handleClose = (key, keyPath) => {
- console.log(key, keyPath)
- }
- const handleMenuSelect = (key) => {
- console.log('Menu selected:', key)
- activeMenu.value = key
-
- // 根据选择的菜单项更新活动菜单名称和组件
- if (key === '1') {
- activeMenuName.value = '数字孪生'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择数字孪生大类时,显示所有数字孪生项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生')
- }
- } else if (key === '1-1') {
- activeMenuName.value = '数字孪生太浦河'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择数字孪生太浦河子类时,显示对应的项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生太浦河')
- }
- } else if (key === '1-2') {
- activeMenuName.value = '数字孪生水文站'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择数字孪生水文站子类时,显示对应的项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生水文站')
- }
- } else if (key === '1-3') {
- activeMenuName.value = '数字孪生灌区'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择数字孪生灌区子类时,显示对应的项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生灌区')
- }
- } else if (key === '2') {
- activeMenuName.value = '水利信息化'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择水利信息化大类时,显示所有水利信息化项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('水利信息化')
- }
- } else if (key === '2-1') {
- activeMenuName.value = '流域数据采集'
- activeComponent.value = ShuiliGongchengRaw
-
- // 当选择流域数据采集子类时,显示对应的项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('流域数据采集')
- }
- } else {
- activeMenuName.value = '数字孪生'
- activeComponent.value = ShuiliGongchengRaw
-
- // 默认显示所有数字孪生项目
- if (shuiliGongchengRef.value) {
- shuiliGongchengRef.value.selectCategory('数字孪生')
- }
- }
-
- console.log('Active component:', activeComponent.value)
- }
- </script>
- <style scoped>
- .model-management {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- overflow: hidden;
- background: #f8f9fa;
- }
- /* 主要内容区域 */
- .main-content {
- flex: 1;
- width: 100%;
- padding: 0;
- overflow-y: auto;
- height: 100%;
- display: flex;
- }
- /* 左侧垂直菜单 */
- .left-sidebar {
- width: 280px;
- background: #f8f9fa;
- box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
- height: 100%;
- border-radius: 0;
- margin: 0;
- overflow: hidden;
- }
- .el-menu-vertical-demo {
- border-right: none;
- font-size: 1rem !important;
- }
- .el-menu-vertical-demo .el-menu-item-group__title {
- font-weight: 600;
- color: #303133 !important;
- line-height: 1.5;
- }
- .el-menu-vertical-demo .el-sub-menu .el-menu-item {
- color: #909399 !important;
- font-size: 0.875rem !important;
- line-height: 1.5;
- }
- /* 选中状态的样式 */
- .el-menu-vertical-demo .el-menu-item.is-active,
- .el-menu-vertical-demo .el-sub-menu.is-active > .el-sub-menu__title {
- color: #409eff !important;
- font-weight: 600 !important;
- }
- /* 大类选中时的样式增强 - 匹配所有可能的激活状态 */
- .el-menu-vertical-demo .el-sub-menu.is-active > .el-sub-menu__title,
- .el-menu-vertical-demo .el-sub-menu.is-opened > .el-sub-menu__title,
- .el-menu-vertical-demo .el-sub-menu[class*="is-active"] > .el-sub-menu__title,
- .el-menu-vertical-demo .el-sub-menu[class*="is-opened"] > .el-sub-menu__title,
- .el-menu-vertical-demo .el-sub-menu:has(.is-active) > .el-sub-menu__title,
- .el-menu-vertical-demo .el-sub-menu:has(.is-opened) > .el-sub-menu__title {
- background-color: rgba(64, 158, 255, 0.25) !important;
- border-left: 4px solid #409eff !important;
- box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2) !important;
- color: #409eff !important;
- font-weight: 600 !important;
- padding-left: 19px !important;
- transition: all 0.3s ease !important;
- }
- /* 确保激活状态样式优先级更高 */
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu.is-active > .el-sub-menu__title,
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu.is-opened > .el-sub-menu__title,
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu:has(.is-active) > .el-sub-menu__title,
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu:has(.is-opened) > .el-sub-menu__title {
- background-color: rgba(64, 158, 255, 0.3) !important;
- border-left: 4px solid #409eff !important;
- box-shadow: 0 4px 16px rgba(64, 158, 255, 0.25) !important;
- font-weight: 700 !important;
- }
- /* 直接点击大类标题时的样式 */
- .el-menu-vertical-demo .el-sub-menu > .el-sub-menu__title:hover,
- .el-menu-vertical-demo .el-sub-menu > .el-sub-menu__title:focus {
- background-color: rgba(64, 158, 255, 0.2) !important;
- border-left: 4px solid #409eff !important;
- color: #409eff !important;
- font-weight: 600 !important;
- }
- /* 为了确保样式能被正确应用,添加更直接的选择器 */
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu > .el-sub-menu__title {
- position: relative;
- z-index: 10;
- }
- /* 当子菜单被选中时,父级大类也显示高亮 */
- .el-menu-vertical-demo .el-sub-menu .el-menu-item.is-active {
- background-color: rgba(64, 158, 255, 0.1) !important;
- color: #409eff !important;
- font-weight: 600 !important;
- }
- /* 大类鼠标悬停效果 */
- .el-menu-vertical-demo .el-sub-menu > .el-sub-menu__title:hover {
- background-color: rgba(64, 158, 255, 0.15) !important;
- border-left: 3px solid rgba(64, 158, 255, 0.8) !important;
- transition: all 0.3s ease !important;
- }
- /* 直接为大类标题添加更通用的样式,确保选中时有视觉反馈 */
- .el-menu-vertical-demo > .el-menu-item-group > .el-sub-menu > .el-sub-menu__title {
- padding: 12px 20px !important;
- margin: 5px 0 !important;
- border-radius: 4px !important;
- transition: all 0.3s ease !important;
- }
- /* 增强选中状态的样式,使用更通用的选择器 */
- .el-menu-vertical-demo .el-sub-menu.is-active > .el-sub-menu__title {
- background-color: rgba(64, 158, 255, 0.25) !important;
- border-left: 4px solid #409eff !important;
- color: #409eff !important;
- font-weight: 600 !important;
- padding-left: 19px !important;
- }
- .menu-title-text {
- font-size: 1rem !important;
- font-weight: 600;
- }
- .tree-menu {
- padding: 1.5rem;
- height: 100%;
- display: flex;
- flex-direction: column;
- border-radius: 12px;
- background-color: #f8f9fa;
- }
- .menu-title {
- font-size: 1.125rem;
- color: #2c3e50;
- margin-bottom: 1.5rem;
- font-weight: 600;
- line-height: 1.5;
- }
- .menu-items {
- display: flex;
- flex-direction: column;
- gap: 0;
- flex-grow: 1;
- }
- .menu-item {
- display: flex;
- align-items: center;
- gap: 0.8rem;
- padding: 1rem 1.5rem;
- cursor: pointer;
- transition: all 0.3s ease;
- font-size: 1rem;
- color: #577cf3;
- font-weight: 400;
- line-height: 1.6;
- }
- .menu-item:hover {
- background: #f0f5ff;
- }
- .menu-icon {
- font-size: 1.25rem;
- }
- /* 右侧内容区域 */
- .right-content {
- flex: 1;
- padding: 1rem;
- overflow-y: auto;
- }
- .model-section {
- padding: 0 1rem;
- margin-bottom: 2.5rem;
- }
- .section-title {
- font-size: 1.5rem;
- color: #2c3e50;
- margin-bottom: 2rem;
- font-weight: 600;
- line-height: 1.4;
- }
- .model-grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
- gap: 2rem;
- }
- .model-card {
- background: white;
- padding: 2.5rem;
- border-radius: 16px;
- box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
- transition: all 0.3s ease;
- }
- .model-card:hover {
- transform: translateY(-10px);
- box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
- }
- .model-name {
- font-size: 1.25rem;
- color: #2c3e50;
- margin-bottom: 1rem;
- font-weight: 600;
- line-height: 1.4;
- }
- .model-description {
- font-size: 1rem;
- color: #7f8c8d;
- line-height: 1.6;
- margin-bottom: 2rem;
- font-weight: 400;
- }
- .model-actions {
- display: flex;
- gap: 1rem;
- }
- .btn {
- padding: 0.8rem 1.5rem;
- border: none;
- border-radius: 50px;
- font-size: 1rem;
- font-weight: 400;
- cursor: pointer;
- transition: all 0.3s ease;
- text-decoration: none;
- display: inline-block;
- white-space: nowrap;
- line-height: 1.6;
- }
- .btn-primary {
- background: #577cf3;
- color: white;
- }
- .btn-primary:hover {
- transform: translateY(-3px);
- box-shadow: 0 15px 30px rgba(87, 124, 243, 0.4);
- }
- .btn-secondary {
- background: white;
- color: #577cf3;
- border: 2px solid #577cf3;
- }
- .btn-secondary:hover {
- background: #577cf3;
- color: white;
- transform: translateY(-3px);
- }
- /* 页面底部 */
- .page-footer {
- background: white;
- color: #577cf3;
- text-align: center;
- padding: 1.5rem 0;
- height: 10px;
- display: flex;
- align-items: center;
- justify-content: center;
- border-top: 1px solid #f0f5ff;
- }
- .menu-bar {
- height: 100%;
- background: #f0f5ff;
- }
- .page-footer p {
- margin: 0;
- font-size: 0.875rem;
- line-height: 1.5;
- font-weight: 400;
- }
- </style>
|