Merge remote-tracking branch 'origin/0.8.X' into 0.8.X

This commit is contained in:
2025-08-01 13:38:53 +08:00
9 changed files with 119 additions and 51 deletions

View File

@@ -5,11 +5,6 @@
{{ item.attrValue }}
</el-descriptions-item>
</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>
<el-empty description="暂无BOM信息" />
</div>
@@ -17,6 +12,7 @@
</template>
<script>
// 如果传递了bomId直接使用bomId, 如果没有传递则根据itemType和itemId获取bomId
import { listBomItem } from '@/api/wms/bomItem';
import { mapState } from 'vuex';
@@ -44,13 +40,23 @@ export default {
computed: {
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
},
created() {
this.getBomInfo();
watch: {
bomId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
},
itemId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
}
},
methods: {
getBomInfo() {
const bomMap = this.$store.getters.bomMap;
console.log(bomMap)
if (!this.bomId && !this.itemType && !this.itemId) {
return;
}
@@ -62,13 +68,17 @@ export default {
bomId = this.rawMaterialMap[this.itemId].bomId;
}
}
if (!bomId) {
return;
}
if (bomMap[bomId]) {
this.bomInfo = bomMap[bomId];
} else {
listBomItem({ bomId: bomId }).then(res => {
listBomItem({ bomId }).then(res => {
this.bomInfo = res.rows;
})
}
console.log(this.bomInfo, bomId, bomMap)
}
}
}

View File

@@ -40,17 +40,26 @@ export default {
computed: {
...mapState('category', ['bomMap', 'productMap', 'rawMaterialMap']),
},
created() {
this.getBomInfo();
watch: {
bomId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
},
itemId: {
handler: function (newVal) {
this.getBomInfo();
},
immediate: true
}
},
methods: {
getBomInfo() {
const bomMap = this.$store.getters.bomMap;
console.log(bomMap)
if (!this.bomId && !this.itemType && !this.itemId) {
return;
}
console.log(this.itemType, this.itemId)
let bomId = this.bomId;
if (!bomId) {
if (this.itemType === 'product') {
@@ -59,10 +68,13 @@ export default {
bomId = this.rawMaterialMap[this.itemId].bomId;
}
}
if (!bomId) {
return;
}
if (bomMap[bomId]) {
this.bomInfo = bomMap[bomId];
} else {
listBomItem({ bomId: bomId }).then(res => {
listBomItem({ bomId }).then(res => {
this.bomInfo = res.rows;
})
}

View File

@@ -56,11 +56,7 @@ export default {
},
methods: {
clickHandle() {
console.log('clickHandle');
this.showDetail = true;
},
getStatusText(status) {
return status === 1 ? '启用中' : '已禁用';
}
},
watch: {

View File

@@ -48,7 +48,6 @@ export default {
materialId: {
handler: function (newVal) {
const res = this.materialMap ? this.materialMap[this.materialId] : {};
console.log(this.materialMap, this.materialId, 'materialMap', 'materialId', res);
this.material = res;
},
immediate: true

View File

@@ -7,26 +7,13 @@
<div class="right-menu">
<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" />
<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" />
<el-tooltip content="布局大小" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip>
</template>
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">

View File

@@ -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>

View File

@@ -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() {

View File

@@ -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 {

View File

@@ -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"