添加web的合卷分卷合并操作

This commit is contained in:
2025-11-03 17:03:03 +08:00
parent 8f0d48a892
commit ffbe9e181a
15 changed files with 3307 additions and 247 deletions

View File

@@ -7,8 +7,8 @@
<span>钢卷分卷</span>
</div>
<div class="header-actions">
<el-button type="primary" size="small" @click="handleSave" :loading="loading">保存分卷</el-button>
<el-button size="small" @click="handleCancel" :disabled="loading">取消</el-button>
<el-button v-if="!readonly" type="primary" size="small" @click="handleSave" :loading="loading">保存分卷</el-button>
<el-button size="small" @click="handleCancel" :disabled="loading">{{ readonly ? '返回' : '取消' }}</el-button>
</div>
</div>
@@ -18,30 +18,52 @@
<div class="flow-left">
<div class="flow-section-title">
<span>母卷信息</span>
<el-button type="text" size="mini" @click="showCoilSelector" icon="el-icon-search">选择母卷</el-button>
</div>
<div class="coil-card mother-coil">
<div class="coil-header">
<i class="el-icon-s-grid"></i>
<span class="coil-id">{{ motherCoil.currentCoilNo || '—' }}</span>
<span class="coil-title">钢卷信息</span>
</div>
<div class="coil-body">
<div class="coil-info-row">
<span class="label">钢种</span>
<span class="value">{{ motherCoil.grade || '—' }}</span>
<span class="label">入场钢卷号</span>
<span class="value">{{ motherCoil.enterCoilNo || '—' }}</span>
</div>
<div class="coil-info-row">
<span class="label">厚度</span>
<span class="value">{{ motherCoil.thickness || '—' }} mm</span>
<span class="label">当前钢卷号</span>
<span class="value">{{ motherCoil.currentCoilNo || '—' }}</span>
</div>
<div class="coil-info-row">
<span class="label">宽度</span>
<span class="value">{{ motherCoil.width || '' }} mm</span>
<span class="label">当前库区</span>
<span class="value">{{ motherCoil.warehouseName || '未分配' }}</span>
</div>
<div class="coil-info-row">
<span class="label">重量</span>
<span class="value highlight">{{ motherCoil.weight || '—' }} t</span>
<span class="label">班组</span>
<span class="value">{{ motherCoil.team || '—' }}</span>
</div>
<div class="coil-info-row" v-if="motherCoil.materialName || motherCoil.productName">
<span class="label">物料名称</span>
<span class="value">{{ motherCoil.materialName || motherCoil.productName || '—' }}</span>
</div>
<div class="coil-info-row">
<span class="label">毛重</span>
<span class="value">{{ motherCoil.grossWeight ? motherCoil.grossWeight + ' t' : '—' }}</span>
</div>
<div class="coil-info-row">
<span class="label">净重</span>
<span class="value">{{ motherCoil.netWeight ? motherCoil.netWeight + ' t' : '—' }}</span>
</div>
<!-- BOM参数展示 -->
<template v-if="motherCoil.bomItems && motherCoil.bomItems.length > 0">
<el-divider content-position="left" style="margin: 15px 0 10px;">参数信息</el-divider>
<div class="bom-params">
<div class="param-item" v-for="(param, index) in motherCoil.bomItems" :key="index">
<span class="param-name">{{ param.attrKey }}</span>
<span class="param-value">{{ param.attrValue }}</span>
</div>
</div>
</template>
</div>
</div>
</div>
@@ -65,43 +87,101 @@
<div class="flow-right">
<div class="flow-section-title">
<span>子卷列表</span>
<el-button type="text" size="mini" @click="addSplitItem" icon="el-icon-plus">添加子卷</el-button>
<div>
<el-button v-if="!readonly" type="text" size="mini" @click="copyToAllSubCoils" icon="el-icon-document-copy">复制到全部</el-button>
<el-button v-if="!readonly" type="text" size="mini" @click="addSplitItem" icon="el-icon-plus">添加子卷</el-button>
</div>
</div>
<div class="split-list">
<div class="sub-coil-card" v-for="(item, index) in splitList" :key="index">
<div class="sub-coil-header">
<span class="sub-coil-number">{{ index + 1 }}</span>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
<el-button
v-if="!readonly"
type="text"
size="mini"
icon="el-icon-delete"
@click="removeSplitItem(index)"
class="btn-remove"
></el-button>
</div>
<div class="sub-coil-body">
<el-form size="small" label-width="70px">
<el-form-item label="卷号">
<el-input v-model="item.currentCoilNo" placeholder="输入子卷卷号"></el-input>
<el-form size="small" label-width="90px">
<el-form-item label="卷号" required>
<el-input v-model="item.currentCoilNo" placeholder="输入子卷卷号" :disabled="readonly"></el-input>
</el-form-item>
<el-form-item label="重量(t)">
<el-input-number
v-model="item.weight"
:min="0"
:precision="2"
controls-position="right"
style="width: 100%"
></el-input-number>
<el-form-item label="班组" required>
<el-input v-model="item.team" placeholder="输入班组名称" :disabled="readonly"></el-input>
</el-form-item>
<el-form-item label="长度(m)">
<el-input-number
v-model="item.length"
:min="0"
:precision="2"
controls-position="right"
<el-form-item label="物品类型" required>
<el-select
v-model="item.itemType"
placeholder="请选择"
style="width: 100%"
></el-input-number>
@change="handleItemTypeChange(index)"
:disabled="readonly"
>
<el-option label="原材料" value="raw_material" />
<el-option label="产品" value="product" />
</el-select>
</el-form-item>
<el-form-item label="物品" required>
<el-select
v-model="item.itemId"
placeholder="请选择物品"
filterable
remote
:remote-method="(query) => searchItemsForSplit(query, index)"
:loading="itemSearchLoading"
style="width: 100%"
:disabled="readonly"
>
<el-option
v-for="option in getItemListForSplit(item.itemType)"
:key="option.id"
:label="option.name"
:value="option.id"
/>
</el-select>
</el-form-item>
<el-form-item label="毛重(t)" required>
<el-input
v-model.number="item.grossWeight"
placeholder="请输入毛重"
type="number"
step="0.01"
:disabled="readonly"
>
<template slot="append">吨</template>
</el-input>
</el-form-item>
<el-form-item label="净重(t)" required>
<el-input
v-model.number="item.netWeight"
placeholder="请输入净重"
type="number"
step="0.01"
:disabled="readonly"
>
<template slot="append">吨</template>
</el-input>
</el-form-item>
<el-form-item label="目标库区" required>
<el-select
v-model="item.nextWarehouseId"
placeholder="请选择目标库区"
style="width: 100%"
filterable
:disabled="readonly"
>
<el-option
v-for="warehouse in warehouseList"
:key="warehouse.warehouseId"
:label="warehouse.warehouseName"
:value="warehouse.warehouseId"
/>
</el-select>
</el-form-item>
</el-form>
</div>
@@ -114,18 +194,6 @@
<span class="summary-label">子卷数量:</span>
<span class="summary-value">{{ splitList.length }}</span>
</div>
<div class="summary-item">
<span class="summary-label">总重量</span>
<span class="summary-value" :class="{ 'error': totalWeight > motherCoil.weight }">
{{ totalWeight.toFixed(2) }} t
</span>
</div>
<div class="summary-item">
<span class="summary-label">剩余重量</span>
<span class="summary-value" :class="{ 'error': remainWeight < 0 }">
{{ remainWeight.toFixed(2) }} t
</span>
</div>
</div>
</div>
</div>
@@ -140,6 +208,9 @@
<script>
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 CoilSelector from '@/components/CoilSelector';
export default {
@@ -152,45 +223,146 @@ export default {
// 母卷信息
motherCoil: {
coilId: null,
enterCoilNo: '',
currentCoilNo: '',
grade: '',
thickness: null,
width: null,
weight: null,
team: '',
warehouseId: null,
team: null,
warehouseName: '',
itemType: null,
itemId: null,
enterCoilNo: '',
supplierCoilNo: ''
materialName: '',
productName: '',
grossWeight: null,
netWeight: null,
bomItems: []
},
// 子卷列表
splitList: [
{ currentCoilNo: '', weight: 0, length: 0 }
{
currentCoilNo: '',
team: '',
itemType: null,
itemId: null,
grossWeight: null,
netWeight: null,
nextWarehouseId: null
}
],
loading: false,
// 钢卷选择器可见性
coilSelectorVisible: false
coilSelectorVisible: false,
// 库区列表
warehouseList: [],
// 原材料和产品列表
rawMaterialList: [],
productList: [],
itemSearchLoading: false,
// 只读模式
readonly: false
};
},
computed: {
// 子卷总重量
totalWeight() {
return this.splitList.reduce((sum, item) => sum + (Number(item.weight) || 0), 0);
},
// 剩余重量
remainWeight() {
return (Number(this.motherCoil.weight) || 0) - this.totalWeight;
}
},
created() {
// 如果URL中有coilId参数则加载母卷信息
async created() {
// 先加载库区列表
await this.loadWarehouses();
// 从路由参数获取coilId和readonly
const coilId = this.$route.query.coilId;
const readonly = this.$route.query.readonly;
if (coilId) {
this.loadMotherCoil(coilId);
await this.loadMotherCoil(coilId);
}
// 设置只读模式
if (readonly === 'true' || readonly === true) {
this.readonly = true;
}
},
methods: {
// 获取子卷的物品列表
getItemListForSplit(itemType) {
if (itemType === 'raw_material') {
return this.rawMaterialList.map(item => ({
id: item.rawMaterialId,
name: item.rawMaterialName
}));
} else if (itemType === 'product') {
return this.productList.map(item => ({
id: item.productId,
name: item.productName
}));
}
return [];
},
// 物品类型变化
handleItemTypeChange(index) {
this.splitList[index].itemId = null;
this.loadItemListForSplit(this.splitList[index].itemType);
},
// 搜索子卷物品
async searchItemsForSplit(query, index) {
const itemType = this.splitList[index].itemType;
if (!itemType) {
this.$message.warning('请先选择物品类型');
return;
}
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({
rawMaterialName: query,
pageNum: 1,
pageSize: 50
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({
productName: query,
pageNum: 1,
pageSize: 50
});
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('搜索物品失败', error);
} finally {
this.itemSearchLoading = false;
}
},
// 加载子卷物品列表
async loadItemListForSplit(itemType) {
if (!itemType) return;
try {
this.itemSearchLoading = true;
if (itemType === 'raw_material') {
const response = await listRawMaterial({ pageNum: 1, pageSize: 100 });
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (itemType === 'product') {
const response = await listProduct({ pageNum: 1, pageSize: 100 });
if (response.code === 200) {
this.productList = response.rows || [];
}
}
} catch (error) {
console.error('加载物品列表失败', error);
} finally {
this.itemSearchLoading = false;
}
},
// 显示钢卷选择器
showCoilSelector() {
this.coilSelectorVisible = true;
@@ -200,17 +372,18 @@ export default {
handleCoilSelect(coil) {
this.motherCoil = {
coilId: coil.coilId,
enterCoilNo: coil.enterCoilNo || '',
currentCoilNo: coil.currentCoilNo || '',
grade: coil.grade || '',
thickness: coil.thickness,
width: coil.width,
weight: coil.weight,
team: coil.team || '',
warehouseId: coil.warehouseId,
team: coil.team,
warehouseName: coil.warehouseName || '',
itemType: coil.itemType,
itemId: coil.itemId,
enterCoilNo: coil.enterCoilNo || '',
supplierCoilNo: coil.supplierCoilNo || ''
materialName: coil.materialName || '',
productName: coil.productName || '',
grossWeight: coil.grossWeight,
netWeight: coil.netWeight,
bomItems: coil.bomItemList || coil.bomItems || []
};
this.$message.success('母卷选择成功');
},
@@ -224,17 +397,18 @@ export default {
const data = response.data;
this.motherCoil = {
coilId: data.coilId,
enterCoilNo: data.enterCoilNo || '',
currentCoilNo: data.currentCoilNo || '',
grade: data.grade || '',
thickness: data.thickness,
width: data.width,
weight: data.weight,
team: data.team || '',
warehouseId: data.warehouseId,
team: data.team,
warehouseName: data.warehouseName || (data.warehouse ? data.warehouse.warehouseName : ''),
itemType: data.itemType,
itemId: data.itemId,
enterCoilNo: data.enterCoilNo || '',
supplierCoilNo: data.supplierCoilNo || ''
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : ''),
grossWeight: data.grossWeight,
netWeight: data.netWeight,
bomItems: data.bomItemList || data.bomItems || []
};
}
} catch (error) {
@@ -245,15 +419,32 @@ export default {
}
},
// 加载库区列表
async loadWarehouses() {
try {
const response = await listWarehouse({ pageNum: 1, pageSize: 1000 });
if (response.code === 200) {
this.warehouseList = response.rows || response.data || [];
console.log('库区列表加载成功,数量:', this.warehouseList.length);
}
} catch (error) {
console.error('加载库区列表失败', error);
}
},
// 添加子卷
addSplitItem() {
this.splitList.push({
currentCoilNo: '',
weight: 0,
length: 0
team: '',
itemType: null,
itemId: null,
grossWeight: null,
netWeight: null,
nextWarehouseId: null
});
},
// 删除子卷
removeSplitItem(index) {
if (this.splitList.length > 1) {
@@ -262,7 +453,7 @@ export default {
this.$message.warning('至少保留一个子卷');
}
},
// 保存分卷
async handleSave() {
// 验证母卷信息
@@ -277,12 +468,6 @@ export default {
return;
}
// 验证重量
if (this.remainWeight < 0) {
this.$message.error('子卷总重量不能超过母卷重量');
return;
}
// 验证子卷信息
for (let i = 0; i < this.splitList.length; i++) {
const item = this.splitList[i];
@@ -290,8 +475,28 @@ export default {
this.$message.error(`第${i + 1}个子卷的卷号不能为空`);
return;
}
if (!item.weight || item.weight <= 0) {
this.$message.error(`${i + 1}个子卷的重量必须大于0`);
if (!item.team || item.team.trim() === '') {
this.$message.error(`第${i + 1}个子卷的班组不能为空`);
return;
}
if (!item.itemType) {
this.$message.error(`第${i + 1}个子卷的物品类型不能为空`);
return;
}
if (!item.itemId) {
this.$message.error(`第${i + 1}个子卷的物品不能为空`);
return;
}
if (item.grossWeight === null || item.grossWeight === undefined || item.grossWeight === '') {
this.$message.error(`第${i + 1}个子卷的毛重不能为空`);
return;
}
if (item.netWeight === null || item.netWeight === undefined || item.netWeight === '') {
this.$message.error(`第${i + 1}个子卷的净重不能为空`);
return;
}
if (!item.nextWarehouseId) {
this.$message.error(`第${i + 1}个子卷的目标库区不能为空`);
return;
}
}
@@ -302,24 +507,24 @@ export default {
// 构造分卷数据
const splitData = {
coilId: this.motherCoil.coilId,
enterCoilNo: this.motherCoil.enterCoilNo, // 入场钢卷号(必填)
currentCoilNo: this.motherCoil.currentCoilNo,
hasMergeSplit: 1, // 1表示分卷
newCoils: this.splitList.map(item => ({
enterCoilNo: this.motherCoil.enterCoilNo, // 子卷继承母卷的入场钢卷号
currentCoilNo: item.currentCoilNo,
weight: item.weight,
length: item.length,
hasMergeSplit: 1,
// 继承母卷的基本信息
grade: this.motherCoil.grade,
thickness: this.motherCoil.thickness,
width: this.motherCoil.width,
warehouseId: this.motherCoil.warehouseId,
team: this.motherCoil.team,
itemType: this.motherCoil.itemType,
itemId: this.motherCoil.itemId
team: item.team,
itemType: item.itemType || this.motherCoil.itemType,
itemId: item.itemId || this.motherCoil.itemId,
grossWeight: item.grossWeight,
netWeight: item.netWeight,
nextWarehouseId: item.nextWarehouseId,
hasMergeSplit: 1
}))
};
console.log('提交的分卷数据:', splitData);
const response = await splitMaterialCoil(splitData);
if (response.code === 200) {
this.$message.success('分卷保存成功');
@@ -337,10 +542,46 @@ export default {
this.loading = false;
}
},
// 取消操作
handleCancel() {
this.$router.back();
},
// 复制到全部子卷
copyToAllSubCoils() {
if (!this.motherCoil.coilId) {
this.$message.warning('请先加载母卷信息');
return;
}
// 复制到所有子卷
this.splitList.forEach((item, index) => {
// 自动生成卷号:母卷号-1, 母卷号-2, 母卷号-3...
if (!item.currentCoilNo) {
item.currentCoilNo = `${this.motherCoil.currentCoilNo}-${index + 1}`;
}
// 复制班组
if (!item.team) {
item.team = this.motherCoil.team;
}
// 复制物品类型和物品ID
if (!item.itemType) {
item.itemType = this.motherCoil.itemType;
}
if (!item.itemId) {
item.itemId = this.motherCoil.itemId;
}
});
// 加载物品列表
if (this.motherCoil.itemType) {
this.loadItemListForSplit(this.motherCoil.itemType);
}
this.$message.success('已复制到所有子卷');
}
}
};
@@ -372,7 +613,7 @@ export default {
display: flex;
align-items: center;
gap: 8px;
i {
color: #0066cc;
font-size: 20px;
@@ -418,7 +659,7 @@ export default {
display: flex;
justify-content: space-between;
align-items: center;
.el-button--text {
font-size: 12px;
}
@@ -444,15 +685,15 @@ export default {
display: flex;
align-items: center;
gap: 10px;
i {
font-size: 20px;
}
.coil-id {
.coil-title {
flex: 1;
font-size: 16px;
font-weight: 600;
letter-spacing: 1px;
}
}
@@ -462,24 +703,27 @@ export default {
.coil-info-row {
display: flex;
align-items: center;
align-items: flex-start;
margin-bottom: 12px;
&:last-child {
margin-bottom: 0;
}
.label {
color: #909399;
font-size: 14px;
min-width: 70px;
min-width: 100px;
flex-shrink: 0;
}
.value {
color: #303133;
font-size: 14px;
font-weight: 500;
flex: 1;
word-break: break-all;
&.highlight {
color: #0066cc;
font-size: 16px;
@@ -488,6 +732,30 @@ export default {
}
}
/* BOM参数展示 */
.bom-params {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
margin-top: 10px;
}
.param-item {
display: flex;
align-items: center;
font-size: 13px;
.param-name {
color: #909399;
min-width: 80px;
}
.param-value {
color: #303133;
font-weight: 500;
}
}
/* 流程箭头 */
.flow-arrow-container {
position: absolute;
@@ -549,11 +817,11 @@ export default {
overflow-y: auto;
margin-bottom: 20px;
padding-right: 10px;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #dcdfe6;
border-radius: 3px;
@@ -566,7 +834,7 @@ export default {
border-radius: 8px;
margin-bottom: 16px;
transition: all 0.3s;
&:hover {
border-color: #0066cc;
box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
@@ -598,7 +866,7 @@ export default {
.btn-remove {
color: #f56c6c;
padding: 0;
&:hover {
color: #f56c6c;
}
@@ -634,10 +902,41 @@ export default {
font-size: 20px;
font-weight: 600;
color: #0066cc;
&.error {
color: #f56c6c;
}
}
// 优化按钮文字颜色
// 实心primary按钮白色文字
::v-deep .el-button--primary.el-button--small:not(.is-plain) {
color: #fff;
}
// plain按钮和text按钮蓝色文字
::v-deep .el-button--primary.el-button--small.is-plain,
::v-deep .el-button--text {
color: #409eff;
&:hover {
color: #66b1ff;
}
}
// 修复数字输入框的上下箭头溢出
.sub-coil-body {
::v-deep input[type="number"] {
appearance: textfield;
-moz-appearance: textfield;
&::-webkit-outer-spin-button,
&::-webkit-inner-spin-button {
-webkit-appearance: none;
appearance: none;
margin: 0;
}
}
}
</style>