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> <template>
<el-tree v-loading="loading" :data="treeData" :props="treeProps" node-key="warehouseId" highlight-current <div>
@node-click="handleNodeClick" :expand-on-click-node="false" <el-tree key="warehouseTree" v-loading="loading" :data="treeData" :props="treeProps" node-key="actualWarehouseId" highlight-current
:lazy="this.warehouseType === 'real'" :load="loadChildren" class="stock-tree" /> @node-click="handleNodeClick" :expand-on-click-node="false" class="stock-tree" />
</div>
</template> </template>
<script> <script>
import { listWarehouse } from '@/api/wms/warehouse'; 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 { export default {
name: "WarehouseTree", name: "WarehouseTree",
@@ -22,8 +24,8 @@ export default {
loading: true, loading: true,
treeProps: { treeProps: {
children: 'children', children: 'children',
label: 'warehouseLabel', label: 'actualWarehouseName',
isLeaf: () => false isLeaf: 'isLeaf'
} }
}; };
}, },
@@ -37,33 +39,30 @@ export default {
}, },
methods: { methods: {
loadChildren(node, resolve) { loadChildren(node, resolve) {
console.log(node); if (this.warehouseType !== 'real') {
return;
}
if (node.level === 0) { if (node.level === 0) {
// resolve(this.handleTree(this.treeData, 'warehouseId', 'parentId')); // resolve(this.handleTree(this.treeData, 'warehouseId', 'parentId'));
} else { } else {
listActualWarehouse({ parentId: node.data.actualWarehouseId }).then(response => { listActualWarehouse({ parentId: node.data.actualWarehouseId }).then(response => {
resolve(response.data.map(item => ({ resolve(response.data);
...item,
warehouseLabel: item.actualWarehouseName
})));
}); });
} }
}, },
getWarehouseTree() { getWarehouseTree() {
this.loading = true; this.loading = true;
if (this.warehouseType === 'real') { if (this.warehouseType === 'real') {
listActualWarehouse({ parentId: 0 }).then(response => { treeActualWarehouseTwoLevel().then(response => {
this.treeData = response.data.map(item => ({ this.treeData = response.data
...item,
warehouseLabel: item.actualWarehouseName
}))
this.loading = false; this.loading = false;
}); });
} else { } else {
listWarehouse().then(response => { listWarehouse().then(response => {
this.treeData = response.data.map(item => ({ this.treeData = response.data.map(item => ({
...item, ...item,
warehouseLabel: item.warehouseName actualWarehouseId: item.warehouseId,
actualWarehouseName: item.warehouseName
})) }))
this.loading = false; 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="warehouseName" v-if="!hideWarehouseQuery" />
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" 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" prop="materialType" /> -->
<el-table-column label="产品类型" align="center" width="220"> <el-table-column label="产品类型" align="center" width="250">
<template slot-scope="scope"> <template slot-scope="scope">
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" /> <ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" /> <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" /> <dict-tag :options="dict.type.stock_item_type" :value="scope.row.itemType" />
</template> </template>
</el-table-column> </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"> <template slot-scope="scope">
<ProductInfo v-if="scope.row.itemType == 'product' || scope.row.itemType == 'semi'" :product="scope.row.product" /> <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" /> <RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
@@ -231,7 +231,33 @@ export default {
}); });
} else { } else {
listStock(this.queryParams).then(response => { 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.total = response.total;
this.loading = false; this.loading = false;
}); });

View File

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