解决bomId为空时会查询所有bom的bug
This commit is contained in:
@@ -80,10 +80,6 @@
|
||||
<i class="el-icon-refresh"></i>
|
||||
刷新
|
||||
</el-button>
|
||||
<el-button type="text" @click="exportData">
|
||||
<i class="el-icon-download"></i>
|
||||
导出
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<div ref="chartContainer" style="width: 100%; height: calc(100vh - 100px);"></div>
|
||||
<div style="display: flex; height: calc(100vh - 100px);">
|
||||
<!-- 左侧导航树 -->
|
||||
<div style="width: 280px; min-width: 200px; border-right: 1px solid #eee; padding: 10px 0;">
|
||||
<el-tree
|
||||
:data="warehouseTreeData"
|
||||
node-key="warehouseId"
|
||||
:props="treeProps"
|
||||
highlight-current
|
||||
@node-click="handleTreeNodeClick"
|
||||
:default-expand-all="true"
|
||||
style="height: 100%; overflow-y: auto;"
|
||||
/>
|
||||
</div>
|
||||
<!-- 右侧图表 -->
|
||||
<div ref="chartContainer" style="flex: 1; height: 100%;"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -8,6 +21,7 @@
|
||||
import * as echarts from 'echarts';
|
||||
import { listStock } from "@/api/wms/stock";
|
||||
import { listWarehouse } from "@/api/wms/warehouse";
|
||||
import 'element-ui/lib/theme-chalk/index.css';
|
||||
|
||||
export default {
|
||||
name: "StockBox",
|
||||
@@ -16,7 +30,14 @@ export default {
|
||||
chart: null,
|
||||
stockData: [],
|
||||
warehouseData: [],
|
||||
warehouseTreeData: []
|
||||
warehouseTreeData: [],
|
||||
treeProps: {
|
||||
label: 'warehouseName',
|
||||
children: 'children',
|
||||
isLeaf: 'isLeaf',
|
||||
id: 'id'
|
||||
},
|
||||
currentTreeNode: null
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
@@ -93,16 +114,17 @@ export default {
|
||||
// 创建树形数据
|
||||
createTreeData() {
|
||||
// 递归构建仓库树
|
||||
const buildWarehouseTree = (warehouseNode) => {
|
||||
const buildWarehouseTree = (warehouseNode, parentId = '') => {
|
||||
const stocks = this.stockData.filter(stock => stock.warehouseId === warehouseNode.warehouseId);
|
||||
const children = [];
|
||||
let totalQuantity = 0;
|
||||
|
||||
// 添加库存物品
|
||||
stocks.forEach(stock => {
|
||||
const quantity = Number(stock.quantity) || 0;
|
||||
totalQuantity += quantity;
|
||||
// 物料节点 id 用 仓库id+物料编码
|
||||
children.push({
|
||||
id: `${warehouseNode.warehouseId}_${stock.itemCode || stock.itemName}`,
|
||||
name: stock.itemName,
|
||||
value: quantity,
|
||||
itemInfo: {
|
||||
@@ -113,19 +135,19 @@ export default {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 递归处理子仓库
|
||||
if (warehouseNode.children && warehouseNode.children.length > 0) {
|
||||
warehouseNode.children.forEach(child => {
|
||||
const childNode = buildWarehouseTree(child);
|
||||
const childNode = buildWarehouseTree(child, warehouseNode.warehouseId);
|
||||
if (childNode.value > 0) {
|
||||
children.push(childNode);
|
||||
totalQuantity += childNode.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 仓库节点 id 用 warehouseId
|
||||
return {
|
||||
id: String(warehouseNode.warehouseId),
|
||||
name: warehouseNode.warehouseName,
|
||||
value: totalQuantity,
|
||||
warehouseInfo: {
|
||||
@@ -134,7 +156,6 @@ export default {
|
||||
children: children.length > 0 ? children : undefined
|
||||
};
|
||||
};
|
||||
|
||||
// 直接返回顶级仓库节点
|
||||
return this.warehouseTreeData.map(warehouse => buildWarehouseTree(warehouse));
|
||||
},
|
||||
@@ -282,6 +303,30 @@ export default {
|
||||
// 刷新数据
|
||||
refresh() {
|
||||
this.loadData();
|
||||
},
|
||||
// 导航树点击事件
|
||||
handleTreeNodeClick(node) {
|
||||
this.currentTreeNode = node;
|
||||
// 图表高亮并聚焦对应节点
|
||||
if (node && node.id) {
|
||||
this.highlightChartNode(node.id);
|
||||
}
|
||||
},
|
||||
// 高亮并聚焦图表节点
|
||||
highlightChartNode(id) {
|
||||
if (!this.chart) return;
|
||||
// 高亮节点
|
||||
this.chart.dispatchAction({
|
||||
type: 'highlight',
|
||||
seriesIndex: 0,
|
||||
targetNodeId: id
|
||||
});
|
||||
// 聚焦节点(自动缩放到该节点)
|
||||
this.chart.dispatchAction({
|
||||
type: 'zoomToNode',
|
||||
seriesIndex: 0,
|
||||
targetNodeId: id
|
||||
});
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
|
||||
@@ -65,8 +65,25 @@
|
||||
<dict-tag :options="dict.type.stock_item_type" :value="scope.row.itemType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="物品" align="center" prop="itemName" />
|
||||
<el-table-column label="物品编号" align="center" prop="itemCode" />
|
||||
<el-table-column label="物品" align="center" prop="itemName">
|
||||
<template slot-scope="scope">
|
||||
<ProductInfo v-if="scope.row.itemType === 'product'" :productId="scope.row.itemId">
|
||||
<template #default="{ product }">
|
||||
{{ product.productName }}({{ product.productCode }})
|
||||
</template>
|
||||
</ProductInfo>
|
||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :materialId="scope.row.itemId">
|
||||
<template #default="{ material }">
|
||||
{{ material.rawMaterialName }}({{ material.rawMaterialCode }})
|
||||
</template>
|
||||
</RawMaterialInfo>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="BOM">
|
||||
<template slot-scope="scope">
|
||||
<BomInfoMini :itemType="scope.row.itemType" :itemId="scope.row.itemId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存数量" align="center" prop="quantity" />
|
||||
<el-table-column label="单位" align="center" prop="unit" />
|
||||
<el-table-column label="批次号" align="center" prop="batchNo" />
|
||||
@@ -96,7 +113,7 @@
|
||||
:value="dict.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="物品ID" prop="itemId">
|
||||
<el-form-item label="物品" prop="itemId">
|
||||
<raw-material-select v-if="form.itemType === 'rawMaterial'" v-model="form.itemId" placeholder="请选择原材料"
|
||||
style="width: 100%;" clearable />
|
||||
<product-select v-else-if="form.itemType === 'product'" v-model="form.itemId" placeholder="请选择产品"
|
||||
@@ -132,6 +149,9 @@ import RawMaterialSelect from "@/components/KLPService/RawMaterialSelect";
|
||||
import ProductSelect from "@/components/KLPService/ProductSelect";
|
||||
import WarehouseSelect from "@/components/WarehouseSelect";
|
||||
import StockBox from './box';
|
||||
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
|
||||
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
||||
import BomInfoMini from "@/components/KLPService/Renderer/BomInfoMini";
|
||||
|
||||
export default {
|
||||
name: "Stock",
|
||||
@@ -140,7 +160,10 @@ export default {
|
||||
WarehouseSelect,
|
||||
RawMaterialSelect,
|
||||
ProductSelect,
|
||||
StockBox
|
||||
StockBox,
|
||||
RawMaterialInfo,
|
||||
ProductInfo,
|
||||
BomInfoMini
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
<!-- 审核按钮 -->
|
||||
<el-button
|
||||
v-if="stockIo.status === 1 && stockIo.ioType != 'in'"
|
||||
v-if="stockIo.status === 1"
|
||||
type="primary"
|
||||
:loading="auditLoading"
|
||||
@click="handleAudit"
|
||||
@@ -161,7 +161,7 @@
|
||||
|
||||
<!-- 撤回按钮 -->
|
||||
<el-button
|
||||
v-if="stockIo.status === 2 && stockIo.ioType != 'in'"
|
||||
v-if="stockIo.status === 2"
|
||||
type="warning"
|
||||
:loading="cancelLoading"
|
||||
@click="handleCancel"
|
||||
|
||||
Reference in New Issue
Block a user