添加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,29 +18,69 @@
<div class="flow-left">
<div class="flow-section-title">
<span>源卷列表</span>
<el-button type="text" size="mini" @click="addSourceCoil" icon="el-icon-plus">添加钢卷</el-button>
<el-button v-if="!readonly" type="text" size="mini" @click="addSourceCoil" icon="el-icon-plus">添加钢卷</el-button>
</div>
<div class="source-list">
<div class="source-coil-card" v-for="(item, index) in sourceCoils" :key="index">
<div class="source-coil-header">
<div class="source-number">{{ index + 1 }}</div>
<div class="source-info">
<div class="source-id">{{ item.currentCoilNo || '待选择' }}</div>
<div class="source-weight">{{ item.weight || '—' }} t</div>
</div>
<el-button
type="text"
size="mini"
icon="el-icon-delete"
<el-button
v-if="!readonly"
type="text"
size="mini"
icon="el-icon-delete"
@click="removeSourceCoil(index)"
class="btn-remove"
></el-button>
</div>
<div class="source-coil-body">
<el-button type="text" size="small" @click="selectCoil(index)">
<template v-if="item.coilId">
<div class="source-detail-row">
<span class="detail-label">入场钢卷号</span>
<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>
</div>
<div class="source-detail-row" v-if="item.materialName || item.productName">
<span class="detail-label">物料名称</span>
<span class="detail-value">{{ item.materialName || item.productName || '—' }}</span>
</div>
</template>
<!-- 第二个位置显示待合卷列表 -->
<template v-else-if="index === 1 && !readonly">
<div class="pending-list-title">待合卷钢卷列表</div>
<div class="pending-coil-list" v-if="pendingMergeList.length > 0">
<div
class="pending-coil-item"
v-for="pending in pendingMergeList"
:key="pending.actionId"
@click="selectPendingCoil(pending, index)"
>
<div class="pending-coil-no">{{ pending.currentCoilNo }}</div>
<div class="pending-coil-info">
<span class="pending-label">扫码时间</span>
<span class="pending-value">{{ formatTime(pending.scanTime) }}</span>
</div>
</div>
</div>
<div v-else class="empty-tip">
<i class="el-icon-info"></i>
暂无其他待合卷钢卷
</div>
</template>
<!-- 其他位置显示选择按钮 -->
<el-button v-else-if="!readonly" type="text" size="small" @click="selectCoil(index)">
<i class="el-icon-search"></i> 选择钢卷
</el-button>
<div v-else class="empty-tip">未选择钢卷</div>
</div>
</div>
</div>
@@ -51,14 +91,14 @@
<div class="merge-arrow-container">
<svg width="120" height="100%" viewBox="0 0 120 400" xmlns="http://www.w3.org/2000/svg">
<!-- 多条线汇聚到一点 -->
<line
v-for="(item, index) in sourceCoils"
<line
v-for="(item, index) in sourceCoils"
:key="index"
:x1="0"
:y1="50 + index * 80"
:x2="100"
:y2="200"
stroke="#0066cc"
:x1="0"
:y1="50 + index * 80"
:x2="100"
:y2="200"
stroke="#0066cc"
stroke-width="2"
stroke-dasharray="5,5"
/>
@@ -83,31 +123,68 @@
<div class="target-coil-body">
<el-form size="small" label-width="90px">
<el-form-item label="卷号">
<el-input v-model="targetCoil.currentCoilNo" placeholder="输入目标卷号"></el-input>
<el-input v-model="targetCoil.currentCoilNo" placeholder="输入目标卷号" :disabled="readonly"></el-input>
</el-form-item>
<el-form-item label="钢种">
<el-input v-model="targetCoil.grade" placeholder="继承源卷"></el-input>
<el-form-item label="班组">
<el-input v-model="targetCoil.team" placeholder="请输入班组名称" :disabled="readonly"></el-input>
</el-form-item>
<el-form-item label="厚度(mm)">
<el-input-number
v-model="targetCoil.thickness"
:min="0"
:precision="2"
controls-position="right"
<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%"
></el-input-number>
clearable
: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="宽度(mm)">
<el-input-number
v-model="targetCoil.width"
:min="0"
:precision="2"
controls-position="right"
style="width: 100%"
></el-input-number>
<el-form-item label="毛重(t)">
<el-input
v-model.number="targetCoil.grossWeight"
placeholder="请输入毛重"
type="number"
step="0.01"
:disabled="readonly"
>
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="重(t)">
<el-input v-model="totalWeight" disabled></el-input>
<el-form-item label="重(t)">
<el-input
v-model.number="targetCoil.netWeight"
placeholder="请输入净重"
type="number"
step="0.01"
:disabled="readonly"
>
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item label="目标库区">
<el-select v-model="targetCoil.nextWarehouseId" placeholder="请选择" style="width: 100%" clearable :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>
@@ -120,10 +197,9 @@
合卷规则
</div>
<ul class="rule-list">
<li>同一钢种才可合</li>
<li>厚度差异不超过±0.05mm</li>
<li>宽度必须完全一致</li>
<li>目标卷重量为源卷总和</li>
<li>至少需要2个源</li>
<li>所有源卷的物品类型和物品ID应保持一致</li>
<li>请确保录入正确的新钢卷号和班组信息</li>
</ul>
</div>
</div>
@@ -139,6 +215,10 @@
<script>
import { getMaterialCoil, mergeMaterialCoil } from '@/api/wms/coil';
import { listWarehouse } from '@/api/wms/warehouse';
import { listRawMaterial } from '@/api/wms/rawMaterial';
import { listProduct } from '@/api/wms/product';
import { listPendingAction, completeAction } from '@/api/wms/pendingAction';
import CoilSelector from '@/components/CoilSelector';
export default {
@@ -153,51 +233,306 @@ export default {
// 目标卷信息
targetCoil: {
currentCoilNo: '',
grade: '',
thickness: null,
width: null,
warehouseId: null,
team: null,
team: '',
itemType: null,
itemId: null
itemId: null,
grossWeight: null,
netWeight: null,
nextWarehouseId: null
},
loading: false,
// 钢卷选择器可见性
coilSelectorVisible: false,
// 当前选择的源卷索引
currentSelectIndex: -1
currentSelectIndex: -1,
// 库区列表
warehouseList: [],
// 原材料和产品列表
rawMaterialList: [],
productList: [],
itemSearchLoading: false,
// 只读模式
readonly: false,
// 待合卷列表(其他待操作的合卷任务)
pendingMergeList: [],
pendingLoading: false
};
},
computed: {
// 源卷总重量
totalWeight() {
return this.sourceCoils.reduce((sum, item) => sum + (Number(item.weight) || 0), 0).toFixed(2);
// 当前物品列表(根据物品类型动态切换)
currentItemList() {
if (this.targetCoil.itemType === 'raw_material') {
return this.rawMaterialList.map(item => ({
id: item.rawMaterialId,
name: item.rawMaterialName
}));
} else if (this.targetCoil.itemType === 'product') {
return this.productList.map(item => ({
id: item.productId,
name: item.productName
}));
}
return [];
}
},
created() {
// 初始化至少2个源卷
this.sourceCoils = [
{ coilId: null, currentCoilNo: '', grade: '', weight: 0, thickness: null, width: null },
{ coilId: null, currentCoilNo: '', grade: '', weight: 0, thickness: null, width: null }
];
watch: {
// 监听物品类型变化,加载对应的列表
'targetCoil.itemType'(newVal, oldVal) {
if (newVal !== oldVal) {
this.targetCoil.itemId = null; // 清空物品ID
this.loadItemList(newVal);
}
}
},
async created() {
// 加载库区列表
await this.loadWarehouses();
// 从路由参数获取coilId、actionId和readonly
const coilId = this.$route.query.coilId;
const actionId = this.$route.query.actionId;
const readonly = this.$route.query.readonly;
// 保存当前页面的待操作ID
if (actionId) {
this.actionId = actionId;
}
// 设置只读模式
if (readonly === 'true' || readonly === true) {
this.readonly = true;
}
// 如果有coilId加载该钢卷作为第一个源卷
if (coilId) {
await this.loadFirstCoil(coilId);
// 加载其他待合卷的钢卷列表
await this.loadPendingMergeList();
} else {
// 没有coilId初始化空的源卷
this.sourceCoils = [
{
coilId: null,
enterCoilNo: '',
currentCoilNo: '',
itemType: null,
itemId: null,
warehouseName: '',
materialName: '',
productName: ''
},
{
coilId: null,
enterCoilNo: '',
currentCoilNo: '',
itemType: null,
itemId: null,
warehouseName: '',
materialName: '',
productName: ''
}
];
}
},
methods: {
// 加载第一个钢卷(从待操作进入时)
async loadFirstCoil(coilId) {
try {
this.loading = true;
const response = await getMaterialCoil(coilId);
if (response.code === 200 && response.data) {
const data = response.data;
// 初始化源卷列表,第一个是当前钢卷
this.sourceCoils = [
{
coilId: data.coilId,
enterCoilNo: data.enterCoilNo || '',
currentCoilNo: data.currentCoilNo || '',
itemType: data.itemType,
itemId: data.itemId,
warehouseName: data.warehouseName || (data.warehouse ? data.warehouse.warehouseName : ''),
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : '')
},
{
coilId: null,
enterCoilNo: '',
currentCoilNo: '',
itemType: null,
itemId: null,
warehouseName: '',
materialName: '',
productName: ''
}
];
// 自动填充目标卷信息
this.targetCoil.itemType = data.itemType;
this.targetCoil.itemId = data.itemId;
this.targetCoil.nextWarehouseId = data.warehouseId;
// 加载对应的物品列表
if (data.itemType) {
await this.loadItemList(data.itemType);
}
}
} catch (error) {
this.$message.error('加载钢卷信息失败');
console.error(error);
} finally {
this.loading = false;
}
},
// 加载待合卷列表
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);
}
} catch (error) {
console.error('加载待合卷列表失败', error);
} finally {
this.pendingLoading = false;
}
},
// 选择待操作中的钢卷
async selectPendingCoil(pending, index) {
try {
this.loading = true;
const response = await getMaterialCoil(pending.coilId);
if (response.code === 200 && response.data) {
const data = response.data;
this.$set(this.sourceCoils, index, {
coilId: data.coilId,
enterCoilNo: data.enterCoilNo || '',
currentCoilNo: data.currentCoilNo || '',
itemType: data.itemType,
itemId: data.itemId,
warehouseName: data.warehouseName || (data.warehouse ? data.warehouse.warehouseName : ''),
materialName: data.materialName || (data.rawMaterial ? data.rawMaterial.rawMaterialName : ''),
productName: data.productName || (data.product ? data.product.productName : ''),
actionId: pending.actionId // 保存待操作ID用于后续完成操作
});
this.$message.success('已添加到合卷列表');
}
} catch (error) {
this.$message.error('加载钢卷信息失败');
console.error(error);
} finally {
this.loading = false;
}
},
// 格式化时间
formatTime(time) {
if (!time) return '';
const date = new Date(time);
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hour = String(date.getHours()).padStart(2, '0');
const minute = String(date.getMinutes()).padStart(2, '0');
return `${month}-${day} ${hour}:${minute}`;
},
// 加载库区列表
async loadWarehouses() {
try {
const response = await listWarehouse({ pageNum: 1, pageSize: 1000 });
if (response.code === 200) {
this.warehouseList = response.rows || response.data || [];
}
} catch (error) {
console.error('加载库区列表失败', error);
}
},
// 加载物品列表(根据类型)
async loadItemList(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;
}
},
// 搜索物品
async searchItems(query) {
if (!this.targetCoil.itemType) {
this.$message.warning('请先选择物品类型');
return;
}
try {
this.itemSearchLoading = true;
if (this.targetCoil.itemType === 'raw_material') {
const response = await listRawMaterial({
rawMaterialName: query,
pageNum: 1,
pageSize: 50
});
if (response.code === 200) {
this.rawMaterialList = response.rows || [];
}
} else if (this.targetCoil.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;
}
},
// 添加源卷
addSourceCoil() {
this.sourceCoils.push({
coilId: null,
enterCoilNo: '',
currentCoilNo: '',
grade: '',
weight: 0,
thickness: null,
width: null,
warehouseId: null,
team: null,
itemType: null,
itemId: null
itemId: null,
warehouseName: '',
materialName: '',
productName: ''
});
},
// 删除源卷
removeSourceCoil(index) {
if (this.sourceCoils.length > 2) {
@@ -206,7 +541,7 @@ export default {
this.$message.warning('至少需要2个源卷才能合卷');
}
},
// 选择钢卷
selectCoil(index) {
this.currentSelectIndex = index;
@@ -218,31 +553,25 @@ export default {
const index = this.currentSelectIndex;
this.$set(this.sourceCoils, index, {
coilId: coil.coilId,
enterCoilNo: coil.enterCoilNo || '',
currentCoilNo: coil.currentCoilNo || '',
grade: coil.grade || '',
weight: coil.weight || 0,
thickness: coil.thickness,
width: coil.width,
warehouseId: coil.warehouseId,
team: coil.team,
itemType: coil.itemType,
itemId: coil.itemId
itemId: coil.itemId,
warehouseName: coil.warehouseName || '',
materialName: coil.materialName || '',
productName: coil.productName || ''
});
// 如果是第一个源卷,自动填充目标卷信息
if (index === 0) {
this.targetCoil.grade = coil.grade;
this.targetCoil.thickness = coil.thickness;
this.targetCoil.width = coil.width;
this.targetCoil.warehouseId = coil.warehouseId;
this.targetCoil.team = coil.team;
this.targetCoil.itemType = coil.itemType;
this.targetCoil.itemId = coil.itemId;
this.targetCoil.nextWarehouseId = coil.warehouseId;
}
this.$message.success('钢卷选择成功');
},
// 保存合卷
async handleSave() {
// 验证源卷数量
@@ -266,52 +595,48 @@ export default {
return;
}
// 验证源卷规格一致性
const firstCoil = this.sourceCoils[0];
for (let i = 1; i < this.sourceCoils.length; i++) {
const coil = this.sourceCoils[i];
if (coil.grade !== firstCoil.grade) {
this.$message.error('源卷钢种不一致,无法合卷');
return;
}
if (Math.abs(coil.thickness - firstCoil.thickness) > 0.05) {
this.$message.error('源卷厚度差异超过±0.05mm,无法合卷');
return;
}
if (coil.width !== firstCoil.width) {
this.$message.error('源卷宽度不一致,无法合卷');
return;
}
// 验证班组
if (!this.targetCoil.team || this.targetCoil.team.trim() === '') {
this.$message.error('请输入班组名称');
return;
}
try {
this.loading = true;
// 构造合卷数据
// 入场钢卷号:所有源卷的入场钢卷号拼接(逗号分隔)
const enterCoilNos = this.sourceCoils
.map(item => item.enterCoilNo)
.filter(no => no) // 过滤空值
.join(',');
const mergeData = {
enterCoilNo: enterCoilNos, // 拼接的入场钢卷号
currentCoilNo: this.targetCoil.currentCoilNo,
grade: this.targetCoil.grade,
thickness: this.targetCoil.thickness,
width: this.targetCoil.width,
weight: Number(this.totalWeight),
warehouseId: this.targetCoil.warehouseId,
team: this.targetCoil.team,
itemType: this.targetCoil.itemType,
itemId: this.targetCoil.itemId,
grossWeight: this.targetCoil.grossWeight,
netWeight: this.targetCoil.netWeight,
nextWarehouseId: this.targetCoil.nextWarehouseId,
hasMergeSplit: 2, // 2表示合卷
newCoils: this.sourceCoils.map(item => ({
coilId: item.coilId,
currentCoilNo: item.currentCoilNo,
grade: item.grade,
thickness: item.thickness,
width: item.width,
weight: item.weight
enterCoilNo: item.enterCoilNo,
currentCoilNo: item.currentCoilNo
}))
};
console.log('提交的合卷数据:', mergeData);
const response = await mergeMaterialCoil(mergeData);
if (response.code === 200) {
this.$message.success('合卷保存成功');
// 完成所有相关的待操作记录
await this.completeAllRelatedActions();
// 延迟返回,让用户看到成功提示
setTimeout(() => {
this.$router.back();
@@ -326,7 +651,38 @@ export default {
this.loading = false;
}
},
// 完成所有相关的待操作记录
async completeAllRelatedActions() {
try {
// 收集所有待操作ID
const actionIds = [];
// 当前页面的actionId从路由参数获取
if (this.actionId) {
actionIds.push(this.actionId);
}
// 从待合卷列表中选择的钢卷的actionId
this.sourceCoils.forEach(item => {
if (item.actionId) {
actionIds.push(item.actionId);
}
});
// 批量完成所有待操作
console.log('需要完成的待操作ID列表:', actionIds);
const promises = actionIds.map(id => completeAction(id));
await Promise.all(promises);
console.log('所有待操作已完成');
} catch (error) {
console.error('完成待操作失败:', error);
// 不影响主流程,只记录错误
}
},
// 取消操作
handleCancel() {
this.$router.back();
@@ -361,7 +717,7 @@ export default {
display: flex;
align-items: center;
gap: 8px;
i {
color: #0066cc;
font-size: 20px;
@@ -416,11 +772,11 @@ export default {
overflow-y: auto;
padding-right: 10px;
margin-bottom: 20px;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #dcdfe6;
border-radius: 3px;
@@ -433,7 +789,7 @@ export default {
border-radius: 8px;
margin-bottom: 12px;
transition: all 0.3s;
&:hover {
border-color: #0066cc;
box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
@@ -481,13 +837,107 @@ export default {
.source-coil-body {
padding: 12px 16px;
text-align: center;
&:empty {
text-align: center;
}
.empty-tip {
text-align: center;
color: #909399;
font-size: 13px;
padding: 10px 0;
i {
display: block;
font-size: 24px;
margin-bottom: 5px;
}
}
}
/* 待合卷列表 */
.pending-list-title {
font-size: 13px;
font-weight: 500;
color: #606266;
margin-bottom: 10px;
padding-bottom: 8px;
border-bottom: 1px solid #e4e7ed;
}
.pending-coil-list {
max-height: 300px;
overflow-y: auto;
&::-webkit-scrollbar {
width: 4px;
}
&::-webkit-scrollbar-thumb {
background: #dcdfe6;
border-radius: 2px;
}
}
.pending-coil-item {
padding: 10px;
margin-bottom: 8px;
background: #f5f7fa;
border: 1px solid #e4e7ed;
border-radius: 4px;
cursor: pointer;
transition: all 0.3s;
&:hover {
background: #ecf5ff;
border-color: #0066cc;
}
.pending-coil-no {
font-size: 14px;
font-weight: 500;
color: #303133;
margin-bottom: 4px;
}
.pending-coil-info {
font-size: 12px;
color: #909399;
.pending-label {
margin-right: 4px;
}
}
}
.source-detail-row {
display: flex;
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;
word-break: break-all;
}
}
.btn-remove {
color: #f56c6c;
padding: 0;
&:hover {
color: #f56c6c;
}
@@ -562,12 +1012,43 @@ export default {
.rule-list {
padding-left: 20px;
margin: 0;
li {
color: #606266;
font-size: 13px;
line-height: 24px;
}
}
// 优化按钮文字颜色
// 实心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;
}
}
// 修复数字输入框的上下箭头溢出
.target-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>