feat(仓库管理): 实现实际仓库的懒加载功能
- 在WarehouseTree组件中为实际仓库类型添加懒加载支持 - 重构ActualWarehouseSelect组件实现树形选择器的懒加载 - 在real.vue页面中使用懒加载表格展示仓库数据 - 优化表单验证和操作逻辑,提升用户体验
This commit is contained in:
@@ -1,16 +1,7 @@
|
||||
|
||||
<template>
|
||||
<el-tree
|
||||
v-loading="loading"
|
||||
:data="treeData"
|
||||
:props="treeProps"
|
||||
node-key="warehouseId"
|
||||
highlight-current
|
||||
@node-click="handleNodeClick"
|
||||
:expand-on-click-node="false"
|
||||
:default-expand-all="true"
|
||||
class="stock-tree"
|
||||
/>
|
||||
<el-tree v-loading="loading" :data="treeData" :props="treeProps" node-key="warehouseId" highlight-current
|
||||
@node-click="handleNodeClick" :expand-on-click-node="false"
|
||||
:lazy="this.warehouseType === 'real'" :load="loadChildren" class="stock-tree" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -45,16 +36,28 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadChildren(node, resolve) {
|
||||
console.log(node);
|
||||
if (node.level === 0) {
|
||||
// resolve(this.handleTree(this.treeData, 'warehouseId', 'parentId'));
|
||||
} else {
|
||||
listActualWarehouse({ parentId: node.data.actualWarehouseId }).then(response => {
|
||||
resolve(response.data.map(item => ({
|
||||
...item,
|
||||
warehouseLabel: item.actualWarehouseName
|
||||
})));
|
||||
});
|
||||
}
|
||||
},
|
||||
getWarehouseTree() {
|
||||
this.loading = true;
|
||||
if (this.warehouseType === 'real') {
|
||||
listActualWarehouse({ pageSize: 1000 }).then(response => {
|
||||
this.treeData = response.rows.map(item => ({
|
||||
listActualWarehouse({ parentId: 0 }).then(response => {
|
||||
this.treeData = response.data.map(item => ({
|
||||
...item,
|
||||
warehouseLabel: item.actualWarehouseName
|
||||
}))
|
||||
this.loading = false;
|
||||
// this.treeData = [{ warehouseName: '全部', value: undefined }, ...this.handleTree(response.rows, 'warehouseId', 'parentId')];
|
||||
});
|
||||
} else {
|
||||
listWarehouse().then(response => {
|
||||
@@ -63,7 +66,6 @@ export default {
|
||||
warehouseLabel: item.warehouseName
|
||||
}))
|
||||
this.loading = false;
|
||||
// this.treeData = [{ warehouseName: '全部', value: undefined }, ...this.handleTree(response.data, 'warehouseId', 'parentId')];
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -80,22 +82,4 @@ export default {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- <style scoped>
|
||||
.stock-tree-card {
|
||||
height: 100%;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
.stock-tree-title {
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
padding: 8px 0;
|
||||
}
|
||||
.stock-tree {
|
||||
min-height: 500px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style> -->
|
||||
</script>
|
||||
Reference in New Issue
Block a user