Files
klp-oa/klp-ui/src/components/KLPService/WarehouseTree/index.vue
砂糖 96082b9124 feat(wms): 添加左侧逻辑库位查询功能并优化钢卷管理界面
在钢卷管理相关页面添加左侧逻辑库位树形查询功能,方便用户快速筛选库位
移除部分冗余代码和注释,优化页面布局和交互体验
添加钢卷统计数据显示功能,提升数据可视化
2026-04-18 13:36:24 +08:00

83 lines
2.1 KiB
Vue

<template>
<div>
<el-tree key="warehouseTree" v-loading="loading" :data="treeData" :props="treeProps" node-key="actualWarehouseId" highlight-current
@node-click="handleNodeClick" :expand-on-click-node="false" class="stock-tree" />
</div>
</template>
<script>
import { listWarehouse } from '@/api/wms/warehouse';
import { treeActualWarehouseTwoLevel } from '@/api/wms/actualWarehouse';
export default {
name: "WarehouseTree",
props: {
warehouseType: {
type: String,
default: 'real'
},
showEmpty: {
type: Boolean,
default: false
}
},
data() {
return {
treeData: [],
loading: true,
treeProps: {
children: 'children',
label: 'actualWarehouseName',
isLeaf: 'isLeaf'
}
};
},
watch: {
warehouseType: {
handler(newVal, oldVal) {
this.getWarehouseTree()
},
immediate: true
}
},
methods: {
getWarehouseTree() {
this.loading = true;
if (this.warehouseType === 'real') {
treeActualWarehouseTwoLevel().then(response => {
const data = response.data;
if (this.showEmpty) {
data.unshift({
actualWarehouseId: '-1',
actualWarehouseName: '空置库',
isLeaf: true
})
}
this.treeData = data;
this.loading = false;
});
} else {
listWarehouse().then(response => {
this.treeData = response.data.map(item => ({
...item,
actualWarehouseId: item.warehouseId,
actualWarehouseName: item.warehouseName
}))
this.loading = false;
});
}
},
handleTree(data, id, parentId) {
const cloneData = JSON.parse(JSON.stringify(data));
return cloneData.filter(father => {
const branchArr = cloneData.filter(child => father[id] === child[parentId]);
if (branchArr.length > 0) father.children = branchArr;
return father[parentId] === 0 || father[parentId] === null;
});
},
handleNodeClick(node) {
this.$emit('node-click', node);
}
}
};
</script>