feat(仓库管理): 优化仓库树组件和产品类型显示

调整仓库树组件逻辑,使用两级树结构并修改节点属性
增加产品类型列宽度以更好显示内容
修改实际仓库管理页面,允许新增顶级节点并优化表单逻辑
在库存列表中添加产品/原材料信息映射逻辑
This commit is contained in:
砂糖
2025-12-05 15:39:25 +08:00
parent 68a0b9c68d
commit 1656f3da6a
4 changed files with 52 additions and 28 deletions

View File

@@ -1,12 +1,14 @@
<template>
<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" />
<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 { listActualWarehouse } from '@/api/wms/actualWarehouse';
// import { listActualWarehouse } from '@/api/wms/actualWarehouse';
import { treeActualWarehouseTwoLevel } from '@/api/wms/actualWarehouse';
export default {
name: "WarehouseTree",
@@ -22,8 +24,8 @@ export default {
loading: true,
treeProps: {
children: 'children',
label: 'warehouseLabel',
isLeaf: () => false
label: 'actualWarehouseName',
isLeaf: 'isLeaf'
}
};
},
@@ -37,33 +39,30 @@ export default {
},
methods: {
loadChildren(node, resolve) {
console.log(node);
if (this.warehouseType !== 'real') {
return;
}
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
})));
resolve(response.data);
});
}
},
getWarehouseTree() {
this.loading = true;
if (this.warehouseType === 'real') {
listActualWarehouse({ parentId: 0 }).then(response => {
this.treeData = response.data.map(item => ({
...item,
warehouseLabel: item.actualWarehouseName
}))
treeActualWarehouseTwoLevel().then(response => {
this.treeData = response.data
this.loading = false;
});
} else {
listWarehouse().then(response => {
this.treeData = response.data.map(item => ({
...item,
warehouseLabel: item.warehouseName
actualWarehouseId: item.warehouseId,
actualWarehouseName: item.warehouseName
}))
this.loading = false;
});

View File

@@ -85,7 +85,7 @@
<el-table-column label="逻辑库位" align="center" prop="warehouseName" v-if="!hideWarehouseQuery" />
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" v-if="!hideWarehouseQuery" />
<!-- <el-table-column label="物料类型" align="center" prop="materialType" /> -->
<el-table-column label="产品类型" align="center" width="220">
<el-table-column label="产品类型" align="center" width="250">
<template slot-scope="scope">
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />

View File

@@ -36,7 +36,7 @@
<dict-tag :options="dict.type.stock_item_type" :value="scope.row.itemType" />
</template>
</el-table-column>
<el-table-column label="产品类型" align="center" prop="itemName" width="220">
<el-table-column label="产品类型" align="center" prop="itemName" width="250">
<template slot-scope="scope">
<ProductInfo v-if="scope.row.itemType == 'product' || scope.row.itemType == 'semi'" :product="scope.row.product" />
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
@@ -231,7 +231,33 @@ export default {
});
} else {
listStock(this.queryParams).then(response => {
this.stockList = response.rows;
this.stockList = response.rows.map(item => {
const itemType = item.itemType
if (itemType === 'raw_material') {
item.rawMaterial = {
rawMaterialId: item.itemId,
rawMaterialName: item.itemName,
rawMaterialCode: item.itemCode,
specification: item.specification,
material: item.material,
surfaceTreatment: item.surfaceTreatment,
zincLayer: item.zincLayer,
manufacturer: item.manufacturer,
}
} else if (itemType === 'product') {
item.product = {
productId: item.itemId,
productName: item.itemName,
productCode: item.itemCode,
specification: item.specification,
material: item.material,
surfaceTreatment: item.surfaceTreatment,
zincLayer: item.zincLayer,
manufacturer: item.manufacturer,
}
}
return item
});
this.total = response.total;
this.loading = false;
});

View File

@@ -34,9 +34,9 @@
<el-button type="primary" icon="el-icon-plus" size="mini" @click="openQuickDialog()">
快速新增 1~3
</el-button>
<!-- <el-button type="success" icon="el-icon-plus" size="mini" @click="openCreateDialog()">
新增级节点
</el-button> -->
<el-button type="success" icon="el-icon-plus" size="mini" @click="openCreateDialog()">
新增级节点
</el-button>
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleDownloadTemplate">
下载导入模板
</el-button>
@@ -237,7 +237,7 @@
>
<el-form ref="editForm" :model="editDialog.form" :rules="editDialog.rules" label-width="90px">
<el-form-item label="层级" prop="actualWarehouseType">
<el-radio-group v-model="editDialog.form.actualWarehouseType" size="small">
<el-radio-group disabled v-model="editDialog.form.actualWarehouseType" size="small">
<el-radio-button :label="1">一级</el-radio-button>
<el-radio-button :label="2">二级</el-radio-button>
<el-radio-button :label="3">三级</el-radio-button>
@@ -279,7 +279,8 @@
custom-class="warehouse-dialog"
>
<el-form ref="createForm" :model="createDialog.form" :rules="createDialog.rules" label-width="90px">
<el-form-item label="父节点">
<!-- 仅当不是顶级节点时显示父节点和层级 -->
<el-form-item v-if="createDialog.form.parentId !== 0 || createDialog.parentNode" label="父节点">
<template v-if="createDialog.parentPath">
<span>{{ createDialog.parentPath }}</span>
</template>
@@ -292,7 +293,7 @@
/>
</template>
</el-form-item>
<el-form-item label="层级" prop="actualWarehouseType">
<el-form-item v-if="createDialog.form.parentId !== 0 || createDialog.parentNode" label="层级" prop="actualWarehouseType">
<el-radio-group v-model="createDialog.form.actualWarehouseType" size="small" :disabled="!!createDialog.parentNode">
<el-radio-button :label="1">一级</el-radio-button>
<el-radio-button :label="2">二级</el-radio-button>
@@ -382,7 +383,6 @@ export default {
remark: ""
},
rules: {
actualWarehouseType: [{ required: true, message: "请选择层级", trigger: "change" }],
actualWarehouseCode: [{ required: true, message: "请输入编码", trigger: "blur" }],
actualWarehouseName: [{ required: true, message: "请输入名称", trigger: "blur" }],
sortNo: [{ required: true, type: "number", message: "请输入排序号", trigger: "change" }]
@@ -404,7 +404,6 @@ export default {
remark: ""
},
rules: {
actualWarehouseType: [{ required: true, message: "请选择层级", trigger: "change" }],
actualWarehouseCode: [{ required: true, message: "请输入编码", trigger: "blur" }],
actualWarehouseName: [{ required: true, message: "请输入名称", trigger: "blur" }],
sortNo: [{ required: true, type: "number", message: "请输入排序号", trigger: "change" }]