feat(wms/coil): 新增异常继承功能并优化钢卷列表页面

1.  为异常管理弹窗添加继承异常按钮和继承弹窗
2.  新增罩式退火原料库选项
3.  优化钢卷列表表格样式与列配置,新增标签预览、打印、数字钢卷、追溯功能
4.  复用生产工序配置常量统一维护
This commit is contained in:
2026-06-10 17:11:05 +08:00
parent fd50118161
commit 7bf7d24f29
4 changed files with 367 additions and 33 deletions

View File

@@ -17,6 +17,10 @@
<h4 class="section-title">异常记录</h4>
<div>
<el-button type="primary" size="mini" @click="handleSave" :loading="buttonLoading">保存</el-button>
<el-button v-if="showInheritButton" type="warning" size="mini" icon="el-icon-download" plain
@click="handleOpenInherit" :loading="inheritLoading">
继承
</el-button>
<el-button type="default" icon="el-icon-refresh" plain size="mini" @click="refreshAbnormalList"
:loading="abnormalLoading">
刷新
@@ -111,6 +115,61 @@
</el-table-column>
</el-table>
</div>
<el-dialog title="异常继承" :visible.sync="inheritDialogVisible" width="1200px" append-to-body top="5vh"
:close-on-click-modal="false">
<div v-loading="inheritLoading">
<template v-if="parentCoils.length > 0">
<el-alert title="以下为加工前钢卷的异常记录,请选择要继承的异常" type="info" :closable="false" show-icon
style="margin-bottom: 16px;" />
<div v-for="(parent, pIdx) in parentCoils" :key="parent.coilId" class="parent-coil-section">
<div class="parent-header">
<span class="parent-title">加工前钢卷 #{{ pIdx + 1 }}入场{{ parent.coil.enterCoilNo }} / 当前{{ parent.coil.currentCoilNo }}</span>
<el-button type="text" size="mini" @click="handleViewParentCoil(parent)">查看钢卷信息</el-button>
</div>
<el-table :data="parent.abnormalList" border stripe size="small" style="width: 100%">
<el-table-column width="50">
<template slot="header">
<el-checkbox :indeterminate="parent.isIndeterminate" :value="parent.checkedAll"
@change="val => handleParentSelectAll(parent, val)" />
</template>
<template slot-scope="scope">
<el-checkbox v-model="scope.row._selected" @change="() => recalcParentCheckState(parent)" />
</template>
</el-table-column>
<el-table-column label="缺陷描述" prop="remark" show-overflow-tooltip />
<el-table-column label="开始位置" prop="startPosition" width="80" />
<el-table-column label="结束位置" prop="endPosition" width="80" />
<el-table-column label="长度" width="70">
<template slot-scope="scope">{{ scope.row.endPosition - scope.row.startPosition }}</template>
</el-table-column>
<el-table-column label="上下版面" prop="plateSurface" width="100" />
<el-table-column label="断面位置" prop="position" width="160" />
<el-table-column label="缺陷代码" prop="defectCode" width="80" />
<el-table-column label="程度" prop="degree" width="60" />
<el-table-column label="主缺陷" width="60">
<template slot-scope="scope">{{ scope.row.mainMark === 1 ? '是' : '否' }}</template>
</el-table-column>
</el-table>
</div>
</template>
<el-empty v-else description="未找到加工前钢卷或异常记录" />
</div>
<span slot="footer">
<el-button @click="inheritDialogVisible = false">取消</el-button>
<el-button type="primary" :loading="inheritButtonLoading" @click="confirmInherit"
:disabled="selectedInheritCount === 0">
确认继承 ({{ selectedInheritCount }})
</el-button>
</span>
</el-dialog>
<el-dialog title="加工前钢卷信息" :visible.sync="parentCoilDialogVisible" width="800px" append-to-body>
<CoilInfoRender v-if="parentViewCoil" :coilInfo="parentViewCoil" :column="4" />
<span slot="footer">
<el-button @click="parentCoilDialogVisible = false">关闭</el-button>
</span>
</el-dialog>
</div>
</template>
@@ -120,6 +179,16 @@ import { getMaterialCoil } from '@/api/wms/coil'
import AbnormalForm from './AbnormalForm'
import ImageUpload from '@/components/ImageUpload'
const PRODUCTION_LINES = [
{ label: '酸连轧工序', warehouseIds: { raw_material: '1988150044862377986', product: '1988150099140866050' } },
{ label: '镀锌工序', warehouseIds: { raw_material: '1988150263284953089', product: '1988150323162836993' } },
{ label: '脱脂工序', warehouseIds: { raw_material: '1988150545175736322', product: '1988150586938421250' } },
{ label: '退火工序', warehouseIds: { raw_material: '1988150648993148929', product: '1988150704496373761' } },
{ label: '拉矫平整工序', warehouseIds: { raw_material: '1988150854442741762', product: '1988150915591499777' } },
{ label: '双机架工序', warehouseIds: { raw_material: '1992873386047643650', product: '1992873437713080322' } },
{ label: '镀铬工序', warehouseIds: { raw_material: '1988151076996706306', product: '1988151132361519105' } },
]
export default {
name: 'ExceptionManager',
components: {
@@ -131,6 +200,10 @@ export default {
coilId: {
type: String,
required: true
},
showInheritButton: {
type: Boolean,
default: false
}
},
data() {
@@ -151,6 +224,23 @@ export default {
abnormalLoading: false,
coilInfoLoading: false,
buttonLoading: false,
inheritDialogVisible: false,
inheritLoading: false,
inheritButtonLoading: false,
parentCoils: [],
parentCoilDialogVisible: false,
parentViewCoil: null,
}
},
computed: {
selectedInheritCount() {
let count = 0
for (const parent of this.parentCoils) {
for (const row of parent.abnormalList) {
if (row._selected) count++
}
}
return count
}
},
watch: {
@@ -396,6 +486,105 @@ export default {
})
}
},
handleOpenInherit() {
const parentCoilId = this.coilInfo.parentCoilId
if (!parentCoilId) {
this.$message.info('该钢卷无加工前记录')
return
}
const parentIds = String(parentCoilId).split(',').map(id => id.trim()).filter(Boolean)
if (parentIds.length === 0) {
this.$message.info('该钢卷无加工前记录')
return
}
this.inheritDialogVisible = true
this.parentCoils = []
this.inheritLoading = true
const promises = parentIds.map(id =>
getMaterialCoil(id).then(res => {
const coil = res.data || {}
return listCoilAbnormal({ coilId: id, pageSize: 999 }).then(res2 => {
const list = (res2.rows || []).map(item => ({ ...item, _selected: false }))
return { coil, abnormalList: list, checkedAll: false, isIndeterminate: false, coilId: id }
})
}).catch(() => null)
)
Promise.all(promises).then(results => {
this.parentCoils = results.filter(Boolean)
if (this.parentCoils.length === 0) {
this.$message.info('未找到加工前钢卷或异常记录')
}
}).finally(() => {
this.inheritLoading = false
})
},
recalcParentCheckState(parent) {
const selected = parent.abnormalList.filter(r => r._selected)
const total = parent.abnormalList.length
parent.checkedAll = selected.length === total && total > 0
parent.isIndeterminate = selected.length > 0 && selected.length < total
},
handleParentSelectAll(parent, val) {
parent.abnormalList.forEach(row => { row._selected = val })
parent.checkedAll = val
parent.isIndeterminate = false
},
handleViewParentCoil(parent) {
this.parentViewCoil = parent.coil
this.parentCoilDialogVisible = true
},
confirmInherit() {
const selected = []
for (const parent of this.parentCoils) {
for (const row of parent.abnormalList) {
if (row._selected) {
const end = Number(row.endPosition) || 0
const start = Number(row.startPosition) || 0
selected.push({
coilId: this.coilId,
position: row.position,
plateSurface: row.plateSurface,
startPosition: start,
endPosition: end,
length: end - start,
defectCode: row.defectCode,
degree: row.degree,
mainMark: row.mainMark,
remark: row.remark,
attachmentFiles: row.attachmentFiles,
productionLine: row.productionLine,
processSource: this.getProductionLineByWarehouseId(parent.coil.warehouseId),
sourceSystem: '4',
parentAbnormalId: row.abnormalId
})
}
}
}
if (selected.length === 0) {
this.$message.info('请选择要继承的异常')
return
}
this.inheritButtonLoading = true
const requests = selected.map(data => addCoilAbnormal(data))
Promise.all(requests).then(() => {
this.$message.success(`成功继承 ${selected.length} 条异常记录`)
this.inheritDialogVisible = false
this.loadAbnormalList()
}).catch(error => {
this.$message.error('继承异常失败: ' + (error.message || error))
}).finally(() => {
this.inheritButtonLoading = false
})
},
getProductionLineByWarehouseId(warehouseId) {
if (!warehouseId) return ''
for (const line of PRODUCTION_LINES) {
if (line.warehouseIds.raw_material === warehouseId || line.warehouseIds.product === warehouseId) {
return line.label
}
}
return ''
},
clearRowData(row) {
// 清空一行的所有数据
row.remark = null
@@ -486,4 +675,27 @@ export default {
.radio-single .el-button {
margin-left: 10px;
}
.parent-coil-section {
margin-bottom: 20px;
padding: 12px;
background-color: #fafafa;
border: 1px solid #e4e7ed;
border-radius: 4px;
}
.parent-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
padding-bottom: 8px;
border-bottom: 1px solid #e4e7ed;
}
.parent-title {
font-size: 14px;
font-weight: 600;
color: #303133;
}
</style>