style: 优化库位树折叠状态及下钻选择器点击热区

This commit is contained in:
DXC
2026-03-06 17:07:38 +08:00
parent f9eb3e9646
commit 1adaa38893
2 changed files with 65 additions and 16 deletions

View File

@ -64,24 +64,33 @@
v-for="item in currentList" v-for="item in currentList"
:key="item.id" :key="item.id"
class="location-item" class="location-item"
@click="handleSelect(item)"
> >
<div class="item-left"> <!-- 左侧热区点击进入下级或选中 -->
<el-icon><Location /></el-icon> <div
class="item-main"
:class="{ 'has-children': item.children && item.children.length > 0 }"
@click="handleItemClick(item)"
>
<el-icon class="item-icon"><Location /></el-icon>
<span class="item-name">{{ item.name }}</span> <span class="item-name">{{ item.name }}</span>
<el-icon v-if="item.children && item.children.length > 0" class="item-arrow">
<ArrowRight />
</el-icon>
</div> </div>
<div class="item-right"> <!-- 右侧操作区 -->
<div class="item-actions">
<el-tag v-if="!item.children || item.children.length === 0" type="info" size="small">
末级
</el-tag>
<el-button <el-button
v-if="item.children && item.children.length > 0" v-else
type="primary" type="primary"
link
size="small" size="small"
@click.stop="handleDrillDown(item)" @click.stop="handleDrillDown(item)"
> >
进入下级 进入下级
<el-icon><ArrowRight /></el-icon> <el-icon><ArrowRight /></el-icon>
</el-button> </el-button>
<el-tag v-else type="info" size="small">末级</el-tag>
</div> </div>
</li> </li>
</ul> </ul>
@ -92,7 +101,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, watch } from 'vue' import { ref, computed } from 'vue'
import { ArrowDown, ArrowLeft, ArrowRight, Location } from '@element-plus/icons-vue' import { ArrowDown, ArrowLeft, ArrowRight, Location } from '@element-plus/icons-vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
@ -173,6 +182,17 @@ const handleDrillDown = (item: WarehouseItem) => {
currentPath.value.push(item) currentPath.value.push(item)
} }
// 点击列表项 - 左侧热区逻辑
const handleItemClick = (item: WarehouseItem) => {
if (item.children && item.children.length > 0) {
// 有子节点:进入下一级
handleDrillDown(item)
} else {
// 末级:直接选中
handleSelect(item)
}
}
// 选择当前项 // 选择当前项
const handleSelect = (item: WarehouseItem) => { const handleSelect = (item: WarehouseItem) => {
emit('update:modelValue', item.full_path) emit('update:modelValue', item.full_path)
@ -234,7 +254,7 @@ const handleSelect = (item: WarehouseItem) => {
} }
.selector-body { .selector-body {
max-height: 300px; max-height: 320px;
overflow-y: auto; overflow-y: auto;
} }
@ -254,33 +274,62 @@ const handleSelect = (item: WarehouseItem) => {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
padding: 12px 16px; border-bottom: 1px solid #f0f0f0;
cursor: pointer;
transition: background 0.2s; transition: background 0.2s;
} }
.location-item:last-child {
border-bottom: none;
}
.location-item:hover { .location-item:hover {
background: #f5f7fa; background: #f5f7fa;
} }
.item-left { /* 左侧主热区 - 占80%宽度 */
.item-main {
flex: 1;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
padding: 14px 12px;
cursor: pointer;
min-width: 0;
} }
.item-left .el-icon { .item-main.has-children {
cursor: pointer;
}
.item-main:hover {
background: rgba(64, 158, 255, 0.08);
}
.item-icon {
color: #409eff; color: #409eff;
flex-shrink: 0;
} }
.item-name { .item-name {
font-size: 14px; font-size: 14px;
color: #303133; color: #303133;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
} }
.item-right { .item-arrow {
color: #c0c4cc;
font-size: 12px;
flex-shrink: 0;
}
/* 右侧操作区 */
.item-actions {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; padding-right: 12px;
flex-shrink: 0;
} }
</style> </style>

View File

@ -78,7 +78,7 @@
node-key="id" node-key="id"
:props="treeProps" :props="treeProps"
:expand-on-click-node="false" :expand-on-click-node="false"
:default-expand-all="true" :default-expand-all="false"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<div class="tree-node"> <div class="tree-node">