解决bomId为空时会查询所有bom的bug
This commit is contained in:
@@ -5,11 +5,6 @@
|
|||||||
{{ item.attrValue }}
|
{{ item.attrValue }}
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<div v-else-if="mini">
|
|
||||||
<el-tooltip :content="bomInfo.map(item => item.attrKey + ':' + item.attrValue).join(',')" class="bom-info" placement="top">
|
|
||||||
<span>{{ bomInfo.map(item => item.attrKey).join(',') }}</span>
|
|
||||||
</el-tooltip>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<el-empty description="暂无BOM信息" />
|
<el-empty description="暂无BOM信息" />
|
||||||
</div>
|
</div>
|
||||||
@@ -17,6 +12,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// 如果传递了bomId直接使用bomId, 如果没有传递,则根据itemType和itemId获取bomId
|
||||||
import { listBomItem } from '@/api/wms/bomItem';
|
import { listBomItem } from '@/api/wms/bomItem';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
|
|
||||||
@@ -44,13 +40,23 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
|
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
|
||||||
},
|
},
|
||||||
created() {
|
watch: {
|
||||||
this.getBomInfo();
|
bomId: {
|
||||||
|
handler: function (newVal) {
|
||||||
|
this.getBomInfo();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
itemId: {
|
||||||
|
handler: function (newVal) {
|
||||||
|
this.getBomInfo();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getBomInfo() {
|
getBomInfo() {
|
||||||
const bomMap = this.$store.getters.bomMap;
|
const bomMap = this.$store.getters.bomMap;
|
||||||
console.log(bomMap)
|
|
||||||
if (!this.bomId && !this.itemType && !this.itemId) {
|
if (!this.bomId && !this.itemType && !this.itemId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -62,13 +68,17 @@ export default {
|
|||||||
bomId = this.rawMaterialMap[this.itemId].bomId;
|
bomId = this.rawMaterialMap[this.itemId].bomId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!bomId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (bomMap[bomId]) {
|
if (bomMap[bomId]) {
|
||||||
this.bomInfo = bomMap[bomId];
|
this.bomInfo = bomMap[bomId];
|
||||||
} else {
|
} else {
|
||||||
listBomItem({ bomId: bomId }).then(res => {
|
listBomItem({ bomId }).then(res => {
|
||||||
this.bomInfo = res.rows;
|
this.bomInfo = res.rows;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log(this.bomInfo, bomId, bomMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,17 +40,26 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
|
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
|
||||||
},
|
},
|
||||||
created() {
|
watch: {
|
||||||
this.getBomInfo();
|
bomId: {
|
||||||
|
handler: function (newVal) {
|
||||||
|
this.getBomInfo();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
itemId: {
|
||||||
|
handler: function (newVal) {
|
||||||
|
this.getBomInfo();
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getBomInfo() {
|
getBomInfo() {
|
||||||
const bomMap = this.$store.getters.bomMap;
|
const bomMap = this.$store.getters.bomMap;
|
||||||
console.log(bomMap)
|
|
||||||
if (!this.bomId && !this.itemType && !this.itemId) {
|
if (!this.bomId && !this.itemType && !this.itemId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(this.itemType, this.itemId)
|
|
||||||
let bomId = this.bomId;
|
let bomId = this.bomId;
|
||||||
if (!bomId) {
|
if (!bomId) {
|
||||||
if (this.itemType === 'product') {
|
if (this.itemType === 'product') {
|
||||||
@@ -59,10 +68,13 @@ export default {
|
|||||||
bomId = this.rawMaterialMap[this.itemId].bomId;
|
bomId = this.rawMaterialMap[this.itemId].bomId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!bomId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (bomMap[bomId]) {
|
if (bomMap[bomId]) {
|
||||||
this.bomInfo = bomMap[bomId];
|
this.bomInfo = bomMap[bomId];
|
||||||
} else {
|
} else {
|
||||||
listBomItem({ bomId: bomId }).then(res => {
|
listBomItem({ bomId }).then(res => {
|
||||||
this.bomInfo = res.rows;
|
this.bomInfo = res.rows;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,11 +56,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
clickHandle() {
|
clickHandle() {
|
||||||
console.log('clickHandle');
|
|
||||||
this.showDetail = true;
|
this.showDetail = true;
|
||||||
},
|
|
||||||
getStatusText(status) {
|
|
||||||
return status === 1 ? '启用中' : '已禁用';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export default {
|
|||||||
materialId: {
|
materialId: {
|
||||||
handler: function (newVal) {
|
handler: function (newVal) {
|
||||||
const res = this.materialMap ? this.materialMap[this.materialId] : {};
|
const res = this.materialMap ? this.materialMap[this.materialId] : {};
|
||||||
console.log(this.materialMap, this.materialId, 'materialMap', 'materialId', res);
|
|
||||||
this.material = res;
|
this.material = res;
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
|
|||||||
@@ -7,26 +7,13 @@
|
|||||||
|
|
||||||
<div class="right-menu">
|
<div class="right-menu">
|
||||||
<template v-if="device!=='mobile'">
|
<template v-if="device!=='mobile'">
|
||||||
<el-tooltip content="驰骋BPM" effect="dark" placement="bottom">
|
|
||||||
<a href="http://ccflow.org/?frm=KonBAI" target="_blank" class="right-menu-item hover-effect">驰骋BPM</a>
|
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<search id="header-search" class="right-menu-item" />
|
<search id="header-search" class="right-menu-item" />
|
||||||
|
|
||||||
<el-tooltip content="源码地址" effect="dark" placement="bottom">
|
|
||||||
<ruo-yi-git id="klp-git" class="right-menu-item hover-effect" />
|
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<el-tooltip content="文档地址" effect="dark" placement="bottom">
|
|
||||||
<ruo-yi-doc id="klp-doc" class="right-menu-item hover-effect" />
|
|
||||||
</el-tooltip>
|
|
||||||
|
|
||||||
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
<screenfull id="screenfull" class="right-menu-item hover-effect" />
|
||||||
|
|
||||||
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
||||||
<size-select id="size-select" class="right-menu-item hover-effect" />
|
<size-select id="size-select" class="right-menu-item hover-effect" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
|
||||||
|
|||||||
@@ -80,10 +80,6 @@
|
|||||||
<i class="el-icon-refresh"></i>
|
<i class="el-icon-refresh"></i>
|
||||||
刷新
|
刷新
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button type="text" @click="exportData">
|
|
||||||
<i class="el-icon-download"></i>
|
|
||||||
导出
|
|
||||||
</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div style="display: flex; height: calc(100vh - 100px);">
|
||||||
<div ref="chartContainer" style="width: 100%; height: calc(100vh - 100px);"></div>
|
<!-- 左侧导航树 -->
|
||||||
|
<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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -8,6 +21,7 @@
|
|||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import { listStock } from "@/api/wms/stock";
|
import { listStock } from "@/api/wms/stock";
|
||||||
import { listWarehouse } from "@/api/wms/warehouse";
|
import { listWarehouse } from "@/api/wms/warehouse";
|
||||||
|
import 'element-ui/lib/theme-chalk/index.css';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "StockBox",
|
name: "StockBox",
|
||||||
@@ -16,7 +30,14 @@ export default {
|
|||||||
chart: null,
|
chart: null,
|
||||||
stockData: [],
|
stockData: [],
|
||||||
warehouseData: [],
|
warehouseData: [],
|
||||||
warehouseTreeData: []
|
warehouseTreeData: [],
|
||||||
|
treeProps: {
|
||||||
|
label: 'warehouseName',
|
||||||
|
children: 'children',
|
||||||
|
isLeaf: 'isLeaf',
|
||||||
|
id: 'id'
|
||||||
|
},
|
||||||
|
currentTreeNode: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@@ -93,16 +114,17 @@ export default {
|
|||||||
// 创建树形数据
|
// 创建树形数据
|
||||||
createTreeData() {
|
createTreeData() {
|
||||||
// 递归构建仓库树
|
// 递归构建仓库树
|
||||||
const buildWarehouseTree = (warehouseNode) => {
|
const buildWarehouseTree = (warehouseNode, parentId = '') => {
|
||||||
const stocks = this.stockData.filter(stock => stock.warehouseId === warehouseNode.warehouseId);
|
const stocks = this.stockData.filter(stock => stock.warehouseId === warehouseNode.warehouseId);
|
||||||
const children = [];
|
const children = [];
|
||||||
let totalQuantity = 0;
|
let totalQuantity = 0;
|
||||||
|
|
||||||
// 添加库存物品
|
// 添加库存物品
|
||||||
stocks.forEach(stock => {
|
stocks.forEach(stock => {
|
||||||
const quantity = Number(stock.quantity) || 0;
|
const quantity = Number(stock.quantity) || 0;
|
||||||
totalQuantity += quantity;
|
totalQuantity += quantity;
|
||||||
|
// 物料节点 id 用 仓库id+物料编码
|
||||||
children.push({
|
children.push({
|
||||||
|
id: `${warehouseNode.warehouseId}_${stock.itemCode || stock.itemName}`,
|
||||||
name: stock.itemName,
|
name: stock.itemName,
|
||||||
value: quantity,
|
value: quantity,
|
||||||
itemInfo: {
|
itemInfo: {
|
||||||
@@ -113,19 +135,19 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 递归处理子仓库
|
// 递归处理子仓库
|
||||||
if (warehouseNode.children && warehouseNode.children.length > 0) {
|
if (warehouseNode.children && warehouseNode.children.length > 0) {
|
||||||
warehouseNode.children.forEach(child => {
|
warehouseNode.children.forEach(child => {
|
||||||
const childNode = buildWarehouseTree(child);
|
const childNode = buildWarehouseTree(child, warehouseNode.warehouseId);
|
||||||
if (childNode.value > 0) {
|
if (childNode.value > 0) {
|
||||||
children.push(childNode);
|
children.push(childNode);
|
||||||
totalQuantity += childNode.value;
|
totalQuantity += childNode.value;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 仓库节点 id 用 warehouseId
|
||||||
return {
|
return {
|
||||||
|
id: String(warehouseNode.warehouseId),
|
||||||
name: warehouseNode.warehouseName,
|
name: warehouseNode.warehouseName,
|
||||||
value: totalQuantity,
|
value: totalQuantity,
|
||||||
warehouseInfo: {
|
warehouseInfo: {
|
||||||
@@ -134,7 +156,6 @@ export default {
|
|||||||
children: children.length > 0 ? children : undefined
|
children: children.length > 0 ? children : undefined
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// 直接返回顶级仓库节点
|
// 直接返回顶级仓库节点
|
||||||
return this.warehouseTreeData.map(warehouse => buildWarehouseTree(warehouse));
|
return this.warehouseTreeData.map(warehouse => buildWarehouseTree(warehouse));
|
||||||
},
|
},
|
||||||
@@ -282,6 +303,30 @@ export default {
|
|||||||
// 刷新数据
|
// 刷新数据
|
||||||
refresh() {
|
refresh() {
|
||||||
this.loadData();
|
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() {
|
beforeDestroy() {
|
||||||
|
|||||||
@@ -65,8 +65,25 @@
|
|||||||
<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" />
|
<el-table-column label="物品" align="center" prop="itemName">
|
||||||
<el-table-column label="物品编号" align="center" prop="itemCode" />
|
<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="quantity" />
|
||||||
<el-table-column label="单位" align="center" prop="unit" />
|
<el-table-column label="单位" align="center" prop="unit" />
|
||||||
<el-table-column label="批次号" align="center" prop="batchNo" />
|
<el-table-column label="批次号" align="center" prop="batchNo" />
|
||||||
@@ -96,7 +113,7 @@
|
|||||||
:value="dict.value"></el-option>
|
:value="dict.value"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</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="请选择原材料"
|
<raw-material-select v-if="form.itemType === 'rawMaterial'" v-model="form.itemId" placeholder="请选择原材料"
|
||||||
style="width: 100%;" clearable />
|
style="width: 100%;" clearable />
|
||||||
<product-select v-else-if="form.itemType === 'product'" v-model="form.itemId" placeholder="请选择产品"
|
<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 ProductSelect from "@/components/KLPService/ProductSelect";
|
||||||
import WarehouseSelect from "@/components/WarehouseSelect";
|
import WarehouseSelect from "@/components/WarehouseSelect";
|
||||||
import StockBox from './box';
|
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 {
|
export default {
|
||||||
name: "Stock",
|
name: "Stock",
|
||||||
@@ -140,7 +160,10 @@ export default {
|
|||||||
WarehouseSelect,
|
WarehouseSelect,
|
||||||
RawMaterialSelect,
|
RawMaterialSelect,
|
||||||
ProductSelect,
|
ProductSelect,
|
||||||
StockBox
|
StockBox,
|
||||||
|
RawMaterialInfo,
|
||||||
|
ProductInfo,
|
||||||
|
BomInfoMini
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
|
|
||||||
<!-- 审核按钮 -->
|
<!-- 审核按钮 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="stockIo.status === 1 && stockIo.ioType != 'in'"
|
v-if="stockIo.status === 1"
|
||||||
type="primary"
|
type="primary"
|
||||||
:loading="auditLoading"
|
:loading="auditLoading"
|
||||||
@click="handleAudit"
|
@click="handleAudit"
|
||||||
@@ -161,7 +161,7 @@
|
|||||||
|
|
||||||
<!-- 撤回按钮 -->
|
<!-- 撤回按钮 -->
|
||||||
<el-button
|
<el-button
|
||||||
v-if="stockIo.status === 2 && stockIo.ioType != 'in'"
|
v-if="stockIo.status === 2"
|
||||||
type="warning"
|
type="warning"
|
||||||
:loading="cancelLoading"
|
:loading="cancelLoading"
|
||||||
@click="handleCancel"
|
@click="handleCancel"
|
||||||
|
|||||||
Reference in New Issue
Block a user