WEB/src/views/warehouse/WarehouseTree.vue

110 lines
2.5 KiB
Vue

<template>
<el-card class="warehouse-tree-card">
<template #header>
<div class="clearfix">
<span>仓库列表</span>
<el-button type="text" @click="emit('add')">添加仓库</el-button>
</div>
</template>
<div class="tree-container">
<el-tree
ref="treeRef"
:data="props.warehouseList"
node-key="id"
:props="treeProps"
:expand-on-click-node="false"
:highlight-current="true"
@node-click="handleNodeClick"
>
<template #default="{ node, data }">
<span class="tree-node">
<el-icon><office-building /></el-icon>
<span class="node-label">{{ data.label }}</span>
</span>
</template>
</el-tree>
</div>
</el-card>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { OfficeBuilding } from '@element-plus/icons-vue'
const props = defineProps({
warehouseList: { type: Array, default: () => [] }
})
const emit = defineEmits(['add', 'select'])
const treeRef = ref(null)
const treeProps = {
children: 'children',
label: 'name'
}
onMounted(() => {
console.log(props.warehouseList)
})
function handleNodeClick(data: any) {
emit('select', data)
}
</script>
<style scoped>
.warehouse-tree-card {
height: 200px;
display:flex;
flex-direction: column;
.el-card__header {
padding: 0;
height:30px;
line-height: 30px;
padding-left: 10px;
.clearfix{
display:flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
height: 30px;
font-size: 16px;
padding-right: 6px;
}
}
.el-card__body{
flex:1;
height: 10px;
padding: 6px 8px;
}
.tree-container {
height: 100%;
overflow-y: auto;
.tree-node {
display: flex;
align-items: center;
font-size: 12px;
i {
margin-right: 4px;
color: #409EFF;
}
.node-label {
flex: 1;
}
}
}
}
:deep(.el-card__header .el-button) {
font-size: 11px;
padding: 0 4px;
min-height: 22px;
}
:deep(.el-tree-node__content) {
height: 26px;
}
</style>