Merge branch '0.8.X' of https://gitee.com/hdka/klp-oa into 0.8.X

This commit is contained in:
砂糖
2025-11-05 22:27:02 +08:00
6 changed files with 466 additions and 174 deletions

View File

@@ -44,13 +44,32 @@
<span class="detail-value">{{ item.enterCoilNo || '—' }}</span>
</div>
<div class="source-detail-row">
<span class="detail-label">当前库区</span>
<span class="detail-value">{{ item.warehouseName || '未分配' }}</span>
<span class="detail-label">逻辑库区</span>
<span class="detail-value">{{ item.warehouseName || '' }}</span>
</div>
<div class="source-detail-row" v-if="item.materialName || item.productName">
<div class="source-detail-row">
<span class="detail-label">真实库区</span>
<span class="detail-value">{{ item.actualWarehouseName || '—' }}</span>
</div>
<div class="source-detail-row">
<span class="detail-label">物料名称</span>
<span class="detail-value">{{ item.materialName || item.productName || '—' }}</span>
</div>
<div class="source-detail-row" v-if="item.specification">
<span class="detail-label">物料规格</span>
<span class="detail-value">{{ item.specification }}</span>
</div>
<!-- BOM参数展示 -->
<template v-if="item.bomItems && item.bomItems.length > 0">
<div class="source-detail-divider">BOM参数</div>
<div class="source-bom-params">
<div class="source-bom-item" v-for="(param, idx) in item.bomItems.slice(0, 3)" :key="idx">
<span class="bom-key">{{ param.attrKey }}</span>
<span class="bom-value">{{ param.attrValue }}</span>
</div>
</div>
</template>
</template>
<!-- 第二个位置显示待合卷列表 -->
@@ -128,8 +147,31 @@
<el-form-item label="班组">
<el-input v-model="targetCoil.team" placeholder="请输入班组名称" :disabled="readonly"></el-input>
</el-form-item>
<MaterialSelect :hideType="hideType" :itemId.sync="targetCoil.itemId" :itemType.sync="targetCoil.itemType" />
<el-form-item label="物品类型">
<el-select v-model="targetCoil.itemType" placeholder="请选择物品类型" style="width: 100%" :disabled="readonly">
<el-option label="原材料" value="raw_material" />
<el-option label="产品" value="product" />
</el-select>
</el-form-item>
<el-form-item label="物品">
<el-select
v-model="targetCoil.itemId"
placeholder="请选择物品"
filterable
remote
:remote-method="searchItems"
:loading="itemSearchLoading"
style="width: 100%"
:disabled="readonly"
>
<el-option
v-for="item in currentItemList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="毛重(t)">
<el-input
@@ -153,8 +195,8 @@
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="目标库位">
<el-select v-model="targetCoil.warehouseId" placeholder="请选择" style="width: 100%" clearable :disabled="readonly">
<el-form-item label="逻辑库区">
<el-select v-model="targetCoil.warehouseId" placeholder="请选择逻辑库区" style="width: 100%" filterable :disabled="readonly">
<el-option
v-for="warehouse in warehouseList"
:key="warehouse.warehouseId"
@@ -207,14 +249,12 @@ import { listProduct } from '@/api/wms/product';
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
import CoilSelector from '@/components/CoilSelector';
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
import MaterialSelect from "@/components/KLPService/MaterialSelect";
export default {
name: 'MergeCoil',
components: {
CoilSelector,
ActualWarehouseSelect,
MaterialSelect
ActualWarehouseSelect
},
data() {
return {
@@ -255,12 +295,12 @@ export default {
if (this.targetCoil.itemType === 'raw_material') {
return this.rawMaterialList.map(item => ({
id: item.rawMaterialId,
name: item.rawMaterialName
name: this.formatItemName(item)
}));
} else if (this.targetCoil.itemType === 'product') {
return this.productList.map(item => ({
id: item.productId,
name: item.productName
name: this.formatItemName(item)
}));
}
return [];
@@ -309,8 +349,11 @@ export default {
itemType: null,
itemId: null,
warehouseName: '',
actualWarehouseName: '',
materialName: '',
productName: ''
productName: '',
specification: '',
bomItems: []
},
{
coilId: null,
@@ -319,8 +362,11 @@ export default {
itemType: null,
itemId: null,
warehouseName: '',
actualWarehouseName: '',
materialName: '',
productName: ''
productName: '',
specification: '',
bomItems: []
}
];
}
@@ -343,8 +389,11 @@ export default {
itemType: data.itemType,
itemId: data.itemId,
warehouseName: data.warehouseName || (data.warehouse ? data.warehouse.warehouseName : ''),
actualWarehouseName: data.actualWarehouseName || (data.actualWarehouse ? data.actualWarehouse.warehouseName : ''),
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : '')
productName: data.productName || (data.product ? data.product.productName : ''),
specification: data.rawMaterial?.specification || data.product?.specification || '',
bomItems: data.bomItemList || []
},
{
coilId: null,
@@ -353,8 +402,11 @@ export default {
itemType: null,
itemId: null,
warehouseName: '',
actualWarehouseName: '',
materialName: '',
productName: ''
productName: '',
specification: '',
bomItems: []
}
];
@@ -377,22 +429,47 @@ export default {
}
},
// 加载待合卷列表
// 加载待合卷列表(查询待处理和处理中的记录)
async loadPendingMergeList() {
try {
this.pendingLoading = true;
const response = await listPendingAction({
actionType: 1, // 1=合卷
actionStatus: 0, // 0=待处理
pageNum: 1,
pageSize: 50
});
if (response.code === 200) {
// 排除当前钢卷
const currentCoilId = this.sourceCoils[0].coilId;
this.pendingMergeList = (response.rows || []).filter(item => item.coilId !== currentCoilId);
}
console.log('=== 开始加载待合卷列表 ===');
// 分别查询待处理和处理中的记录
const responses = await Promise.all([
listPendingAction({
actionType: 1, // 1=合卷
actionStatus: 0, // 0=待处理
pageNum: 1,
pageSize: 50
}),
listPendingAction({
actionType: 1, // 1=合卷
actionStatus: 1, // 1=处理中
pageNum: 1,
pageSize: 50
})
]);
console.log('待处理响应:', responses[0]);
console.log('处理中响应:', responses[1]);
// 合并两个列表
const allPending = [
...(responses[0].rows || []),
...(responses[1].rows || [])
];
console.log('所有待合卷记录数量:', allPending.length);
console.log('所有待合卷记录:', allPending);
// 排除当前钢卷
const currentCoilId = this.sourceCoils[0] ? this.sourceCoils[0].coilId : null;
console.log('当前钢卷ID:', currentCoilId);
this.pendingMergeList = allPending.filter(item => item.coilId !== currentCoilId);
console.log('过滤后的待合卷列表数量:', this.pendingMergeList.length);
console.log('过滤后的待合卷列表:', this.pendingMergeList);
} catch (error) {
console.error('加载待合卷列表失败', error);
} finally {
@@ -414,8 +491,11 @@ export default {
itemType: data.itemType,
itemId: data.itemId,
warehouseName: data.warehouseName || (data.warehouse ? data.warehouse.warehouseName : ''),
actualWarehouseName: data.actualWarehouseName || (data.actualWarehouse ? data.actualWarehouse.warehouseName : ''),
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : ''),
specification: data.rawMaterial?.specification || data.product?.specification || '',
bomItems: data.bomItemList || [],
actionId: pending.actionId // 保存待操作ID用于后续完成操作
});
@@ -440,6 +520,41 @@ export default {
return `${month}-${day} ${hour}:${minute}`;
},
// 格式化物品名称添加规格和BOM信息
formatItemName(item) {
if (!item) return '';
// 获取名称(原材料或产品)
const name = item.rawMaterialName || item.productName || '';
if (!name) return '';
let displayName = name;
const specs = [];
// 1. 优先显示规格从对象的specification字段
if (item.specification) {
specs.push(item.specification);
}
// 2. 添加BOM参数最多2个
if (item.bomItems && item.bomItems.length > 0) {
const bomParams = item.bomItems
.filter(bomItem => bomItem.attrKey && bomItem.attrValue)
.slice(0, 2); // 最多2个BOM参数
bomParams.forEach(param => {
specs.push(`${param.attrKey}:${param.attrValue}`);
});
}
// 3. 拼接成最终格式
if (specs.length > 0) {
displayName += `${specs.join(' ')}`;
}
return displayName;
},
// 加载库区列表
async loadWarehouses() {
try {
@@ -455,16 +570,24 @@ export default {
// 加载物品列表(根据类型)
async loadItemList(itemType) {
if (!itemType) return;
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({ pageNum: 1, pageSize: 100 });
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({ pageNum: 1, pageSize: 100 });
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
}
@@ -482,23 +605,30 @@ export default {
this.$message.warning('请先选择物品类型');
return;
}
if (!query || query.trim() === '') {
this.loadItemList(this.targetCoil.itemType);
return;
}
try {
this.itemSearchLoading = true;
if (this.targetCoil.itemType === 'raw_material') {
const response = await listRawMaterial({
const response = await listRawMaterial({
rawMaterialName: query,
pageNum: 1,
pageSize: 50
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (this.targetCoil.itemType === 'product') {
const response = await listProduct({
const response = await listProduct({
productName: query,
pageNum: 1,
pageSize: 50
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
@@ -520,8 +650,11 @@ export default {
itemType: null,
itemId: null,
warehouseName: '',
actualWarehouseName: '',
materialName: '',
productName: ''
productName: '',
specification: '',
bomItems: []
});
},
@@ -550,8 +683,11 @@ export default {
itemType: coil.itemType,
itemId: coil.itemId,
warehouseName: coil.warehouseName || '',
actualWarehouseName: coil.actualWarehouseName || '',
materialName: coil.materialName || '',
productName: coil.productName || ''
productName: coil.productName || '',
specification: coil.rawMaterial?.specification || coil.product?.specification || '',
bomItems: coil.bomItemList || []
});
// 如果是第一个源卷,自动填充目标卷信息
@@ -915,17 +1051,17 @@ export default {
align-items: flex-start;
margin-bottom: 8px;
font-size: 13px;
&:last-child {
margin-bottom: 0;
}
.detail-label {
color: #909399;
min-width: 90px;
flex-shrink: 0;
}
.detail-value {
color: #303133;
flex: 1;
@@ -933,6 +1069,36 @@ export default {
}
}
.source-detail-divider {
margin: 10px 0 8px;
padding: 5px 0;
font-size: 12px;
font-weight: 500;
color: #606266;
border-bottom: 1px solid #e4e7ed;
}
.source-bom-params {
margin-top: 8px;
}
.source-bom-item {
display: flex;
align-items: center;
margin-bottom: 6px;
font-size: 12px;
.bom-key {
color: #909399;
min-width: 60px;
}
.bom-value {
color: #303133;
flex: 1;
}
}
.btn-remove {
color: #f56c6c;
padding: 0;

View File

@@ -139,10 +139,10 @@
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="目标库区" required>
<el-form-item label="逻辑库区" required>
<el-select
v-model="item.warehouseId"
placeholder="请选择目标库位"
placeholder="请选择逻辑库区"
style="width: 100%"
filterable
:disabled="readonly"
@@ -155,7 +155,7 @@
/>
</el-select>
</el-form-item>
<el-form-item label="展示库区" required>
<el-form-item label="真实库区" required>
<ActualWarehouseSelect
v-model="item.actualWarehouseId"
placeholder="请选择真实库区"
@@ -192,6 +192,7 @@ import { getMaterialCoil, splitMaterialCoil } from '@/api/wms/coil';
import { listWarehouse } from '@/api/wms/warehouse';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listProduct } from '@/api/wms/product';
import { completeAction } from '@/api/wms/pendingAction';
import CoilSelector from '@/components/CoilSelector';
import ActualWarehouseSelect from "@/components/KLPService/ActualWarehouseSelect";
import MaterialSelect from "@/components/KLPService/MaterialSelect";
@@ -244,7 +245,9 @@ export default {
productList: [],
itemSearchLoading: false,
// 只读模式
readonly: false
readonly: false,
// 待操作ID
actionId: null
};
},
computed: {
@@ -253,14 +256,20 @@ export default {
// 先加载库区列表
await this.loadWarehouses();
// 从路由参数获取coilId和readonly
// 从路由参数获取coilId、actionId和readonly
const coilId = this.$route.query.coilId;
const actionId = this.$route.query.actionId;
const readonly = this.$route.query.readonly;
if (coilId) {
await this.loadMotherCoil(coilId);
}
// 保存待操作ID
if (actionId) {
this.actionId = actionId;
}
// 设置只读模式
if (readonly === 'true' || readonly === true) {
this.readonly = true;
@@ -272,17 +281,52 @@ export default {
if (itemType === 'raw_material') {
return this.rawMaterialList.map(item => ({
id: item.rawMaterialId,
name: item.rawMaterialName
name: this.formatItemName(item)
}));
} else if (itemType === 'product') {
return this.productList.map(item => ({
id: item.productId,
name: item.productName
name: this.formatItemName(item)
}));
}
return [];
},
// 格式化物品名称添加规格和BOM信息
formatItemName(item) {
if (!item) return '';
// 获取名称(原材料或产品)
const name = item.rawMaterialName || item.productName || '';
if (!name) return '';
let displayName = name;
const specs = [];
// 1. 优先显示规格从对象的specification字段
if (item.specification) {
specs.push(item.specification);
}
// 2. 添加BOM参数最多2个
if (item.bomItems && item.bomItems.length > 0) {
const bomParams = item.bomItems
.filter(bomItem => bomItem.attrKey && bomItem.attrValue)
.slice(0, 2); // 最多2个BOM参数
bomParams.forEach(param => {
specs.push(`${param.attrKey}:${param.attrValue}`);
});
}
// 3. 拼接成最终格式
if (specs.length > 0) {
displayName += `${specs.join(' ')}`;
}
return displayName;
},
// 物品类型变化
handleItemTypeChange(index) {
this.splitList[index].itemId = null;
@@ -296,23 +340,30 @@ export default {
this.$message.warning('请先选择物品类型');
return;
}
if (!query || query.trim() === '') {
this.loadItemListForSplit(itemType);
return;
}
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({
const response = await listRawMaterial({
rawMaterialName: query,
pageNum: 1,
pageSize: 50
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({
const response = await listProduct({
productName: query,
pageNum: 1,
pageSize: 50
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
@@ -328,16 +379,24 @@ export default {
// 加载子卷物品列表
async loadItemListForSplit(itemType) {
if (!itemType) return;
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({ pageNum: 1, pageSize: 100 });
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({ pageNum: 1, pageSize: 100 });
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
}
@@ -522,6 +581,12 @@ export default {
const response = await splitMaterialCoil(splitData);
if (response.code === 200) {
this.$message.success('分卷保存成功');
// 如果是从待操作列表进来的,标记操作为完成
if (this.actionId) {
await completeAction(this.actionId);
}
// 延迟返回,让用户看到成功提示
setTimeout(() => {
this.$router.back();

View File

@@ -55,7 +55,7 @@
<span class="info-value">{{ currentInfo.netWeight ? currentInfo.netWeight + ' t' : '—' }}</span>
</div>
<div class="info-row">
<span class="info-label">目标库区</span>
<span class="info-label">逻辑库区</span>
<span class="info-value">{{ currentInfo.nextWarehouseName || '—' }}</span>
</div>
<div class="info-row" v-if="currentInfo.remark">
@@ -122,8 +122,8 @@
</el-input>
</el-form-item>
<el-form-item label="目标库位" prop="warehouseId">
<el-select v-model="updateForm.warehouseId" placeholder="请选择目标库区" style="width: 100%" filterable
<el-form-item label="逻辑库区" prop="warehouseId">
<el-select v-model="updateForm.warehouseId" placeholder="请选择逻辑库区" style="width: 100%" filterable
:disabled="readonly">
<el-option v-for="warehouse in warehouseList" :key="warehouse.warehouseId"
:label="warehouse.warehouseName" :value="warehouse.warehouseId" />
@@ -256,7 +256,7 @@ export default {
{ type: 'number', message: '净重必须为数字', trigger: 'blur' }
],
warehouseId: [
{ required: true, message: '请选择目标库区', trigger: 'change' }
{ required: true, message: '请选择逻辑库区', trigger: 'change' }
],
actualWarehouseId: [
{ required: true, message: '请选择真实库区', trigger: 'change' }
@@ -279,12 +279,12 @@ export default {
if (this.updateForm.itemType === 'raw_material') {
return this.rawMaterialList.map(item => ({
id: item.rawMaterialId,
name: item.rawMaterialName
name: this.formatItemName(item)
}));
} else if (this.updateForm.itemType === 'product') {
return this.productList.map(item => ({
id: item.productId,
name: item.productName
name: this.formatItemName(item)
}));
}
return [];
@@ -395,6 +395,49 @@ export default {
return warehouse ? warehouse.warehouseName : '';
},
// 格式化物品名称添加规格和BOM信息
formatItemName(name, bomItems) {
if (!name) return '';
let displayName = name;
// 如果有BOM参数添加到名称后面
if (bomItems && bomItems.length > 0) {
const specs = [];
// 查找规格参数
const specItem = bomItems.find(item =>
item.attrKey === '规格' ||
item.attrKey === 'spec' ||
item.attrKey === '型号'
);
if (specItem && specItem.attrValue) {
specs.push(specItem.attrValue);
}
// 添加其他关键参数最多3个
const otherParams = bomItems
.filter(item =>
item.attrKey !== '规格' &&
item.attrKey !== 'spec' &&
item.attrKey !== '型号'
)
.slice(0, 2); // 最多2个其他参数
otherParams.forEach(param => {
if (param.attrValue) {
specs.push(`${param.attrKey}:${param.attrValue}`);
}
});
if (specs.length > 0) {
displayName += `${specs.join(' ')}`;
}
}
return displayName;
},
// 加载库区列表
async loadWarehouses() {
try {
@@ -411,16 +454,26 @@ export default {
// 加载物品列表(根据类型)
async loadItemList(itemType) {
if (!itemType) return;
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({ pageNum: 1, pageSize: 100 });
// 使用带BOM的接口
const response = await listRawMaterial({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含BOM信息
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({ pageNum: 1, pageSize: 100 });
// 使用带BOM的接口
const response = await listProduct({
pageNum: 1,
pageSize: 100,
withBom: true // 请求包含BOM信息
});
if (response.code === 200) {
this.productList = response.rows || [];
}
@@ -432,29 +485,37 @@ export default {
}
},
// 搜索物品
// 搜索物品(支持名称和规格搜索)
async searchItems(query) {
if (!this.updateForm.itemType) {
this.$message.warning('请先选择物品类型');
return;
}
if (!query || query.trim() === '') {
// 如果搜索为空,加载默认列表
this.loadItemList(this.updateForm.itemType);
return;
}
try {
this.itemSearchLoading = true;
if (this.updateForm.itemType === 'raw_material') {
const response = await listRawMaterial({
rawMaterialName: query,
pageNum: 1,
pageSize: 50
const response = await listRawMaterial({
rawMaterialName: query, // 按名称搜索
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (this.updateForm.itemType === 'product') {
const response = await listProduct({
productName: query,
pageNum: 1,
pageSize: 50
const response = await listProduct({
productName: query, // 按名称搜索
pageNum: 1,
pageSize: 50,
withBom: true
});
if (response.code === 200) {
this.productList = response.rows || [];
@@ -534,24 +595,26 @@ export default {
try {
this.loading = true;
// 构造更新数据使用标准update接口会创建历史版本
// 构造更新数据使用标准update接口直接更新原记录
const updateData = {
coilId: this.currentInfo.coilId,
enterCoilNo: this.currentInfo.enterCoilNo, // 入场钢卷号,从当前信息获取(必填)
supplierCoilNo: this.currentInfo.supplierCoilNo, // 厂家原料卷号(保持不变)
enterCoilNo: this.currentInfo.enterCoilNo,
supplierCoilNo: this.currentInfo.supplierCoilNo,
currentCoilNo: this.updateForm.currentCoilNo,
team: this.updateForm.team,
itemType: this.updateForm.itemType,
itemId: this.updateForm.itemId,
grossWeight: this.updateForm.grossWeight,
netWeight: this.updateForm.netWeight,
// warehouseId: this.currentInfo.warehouseId, // 当前库区ID保持不变
actualWarehouseId: this.updateForm.actualWarehouseId, // 真实库区ID
warehouseId: this.updateForm.warehouseId, // 目标库区ID
warehouseId: this.updateForm.warehouseId,
actualWarehouseId: this.updateForm.actualWarehouseId,
remark: this.updateForm.remark
// 注意不要传newCoils否则会走批量更新逻辑
};
console.log('=== 正常更新操作 ===');
console.log('提交的更新数据:', updateData);
console.log('是否有newCoils:', updateData.newCoils);
const response = await updateMaterialCoil(updateData);