Browse Source

2026-06-26

创建分卷增加不良
master
fengyuan_yang 1 month ago
parent
commit
1efe05faa6
  1. 426
      src/views/modules/yieldReport/com_separate_roll.vue

426
src/views/modules/yieldReport/com_separate_roll.vue

@ -41,7 +41,7 @@
</el-col>
<el-col :span="3">
<el-form-item label="分切卷数">
<el-input-number :controls="false" :step="0" v-model="pageData.rollCount" style="width: 60px;"></el-input-number>
<el-input-number :controls="false" :step="0" v-model="pageData.rollCount" @change="handleRollCountChange" style="width: 60px;"></el-input-number>
</el-form-item>
</el-col>
</el-row>
@ -135,6 +135,11 @@
</div>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="110" class-name="operation-column">
<template slot-scope="scope">
<el-button type="text" size="mini" @click="openRollDefectDialog(scope.$index)">不良原因</el-button>
</template>
</el-table-column>
</el-table>
</div>
</el-form>
@ -146,6 +151,68 @@
</span>
</el-dialog>
<!-- 分卷不良原因对话框 -->
<el-dialog
title="不良原因"
:close-on-click-modal="false"
:visible.sync="rollDefectDialogVisible"
width="700px"
append-to-body>
<div class="roll-defect-summary">
<span>当前卷{{ currentRollDefectIndex }}</span>
<span>面损合计{{ formatQty(getCurrentRollSurfaceLossQty()) }}</span>
<span>已选不良合计{{ formatQty(getCurrentRollDefectTotal()) }}</span>
</div>
<el-form :inline="true" label-position="top" class="roll-defect-form">
<el-form-item>
<span slot="label" class="defect-code-label" @click="getBaseList(89)"><a>不良代码</a></span>
<el-input
v-model="rollDefectForm.defectCode"
readonly
class="defect-code-input"
style="width: 130px"
placeholder="请选择"
@click.native="getBaseList(89)">
</el-input>
</el-form-item>
<el-form-item label="不良数量">
<el-input-number
v-model="rollDefectForm.defectQty"
:controls="false"
:min="0"
style="width: 120px">
</el-input-number>
</el-form-item>
<el-form-item label="不良描述">
<el-input
v-model="rollDefectForm.defectDesc"
readonly
style="width: 250px">
</el-input>
</el-form-item>
<el-form-item label=" ">
<el-button type="primary" @click="addRollDefectItem">添加</el-button>
</el-form-item>
</el-form>
<el-table
:data="currentRollDefectList"
border
height="260"
style="width: 100%;">
<el-table-column prop="defectCode" label="不良代码" width="120" align="center"></el-table-column>
<el-table-column prop="defectDesc" label="不良描述" min-width="260" align="left"></el-table-column>
<el-table-column prop="defectQty" label="不良数量" width="110" align="right"></el-table-column>
<el-table-column label="操作" width="80" align="center">
<template slot-scope="scope">
<el-button type="text" @click="removeRollDefectItem(scope.$index)">删除</el-button>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="rollDefectDialogVisible = false">确定</el-button>
</span>
</el-dialog>
<!-- 固定载具选择对话框 -->
<el-dialog title="固定载具清单" :close-on-click-modal="false" v-drag :visible.sync="carrierModelFlag" width="950px">
<div class="rq">
@ -311,6 +378,7 @@
<el-button @click="addCarrierFlag=false">关闭</el-button>
</el-footer>
</el-dialog>
<Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
</div>
</template>
@ -326,6 +394,7 @@
saveAbnormalRollData,/*保存异常截卷数据*/
} from '@/api/yieldReport/com_separate_roll.js';
import { fixedCarrierSave } from '@/api/fixedCarrier/fixedCarrier.js';
import Chooselist from '@/views/modules/common/Chooselist';
/*打印标签专用的js*/
import {
@ -344,7 +413,6 @@
removerLanguage,
saveSysLanguageList
} from "@/api/sysLanguage.js";
import {
getPartLabelTemplateList,
callUspPartLabelTemplate
@ -358,6 +426,9 @@
export default {
name: "com_separate_roll",
mixins: [labelPrintTemplates],
components: {
Chooselist
},
data() {
return {
titleCon: '创建分卷',
@ -411,6 +482,17 @@ export default {
carrierNo: ''
},
rowDataList: [], //
//
rollDefectDialogVisible: false,
currentRollDefectIndex: 1,
tagNo: '',
rollDefectForm: {
defectCode: '',
defectDesc: '',
defectQty: null
},
rollDefectMap: {},
currentRollDefectList: [],
operatorData: {
site: this.$store.state.user.site,
username: this.$store.state.user.name,
@ -603,6 +685,8 @@ export default {
this.hasCachedData = false;
this.cachedDataCount = 0;
this.cachedRowDataList = []; //
//
this.resetRollDefectData();
//
this.rowDataList = [];
//
@ -725,6 +809,22 @@ export default {
this.pageData.rollCount = this.pageData.rowCount
}
this.initRowDataList()
this.resetRollDefectData()
},
//
handleRollCountChange() {
if (this.pageData.rollCount > this.pageData.rowCount) {
this.pageData.rollCount = this.pageData.rowCount
}
const hasDefectReason = Object.keys(this.rollDefectMap).some(key => {
const list = this.rollDefectMap[key]
return Array.isArray(list) && list.length > 0
})
if (hasDefectReason) {
this.$message.warning('卷数已变更,原不良原因已清空,请重新维护')
}
this.resetRollDefectData()
},
//
@ -744,6 +844,206 @@ export default {
}
},
resetRollDefectData() {
this.rollDefectDialogVisible = false
this.currentRollDefectIndex = 1
this.rollDefectMap = {}
this.currentRollDefectList = []
this.resetRollDefectForm()
},
resetRollDefectForm() {
this.rollDefectForm = {
defectCode: '',
defectDesc: '',
defectQty: null
}
},
normalizeRollDefectMap() {
const maxRollCount = Number(this.pageData.rollCount || 0)
Object.keys(this.rollDefectMap).forEach(key => {
if (Number(key) > maxRollCount) {
this.$delete(this.rollDefectMap, key)
}
})
},
getRollSegments() {
const totalRows = Array.isArray(this.rowDataList) ? this.rowDataList.length : 0
const rollCount = Number(this.pageData.rollCount || 0)
if (totalRows <= 0 || rollCount <= 0) {
return []
}
const rowsPerRoll = Math.floor(totalRows / rollCount)
const remainingRows = totalRows % rollCount
const segments = []
let startRow = 0
for (let i = 0; i < rollCount; i++) {
const currentRollRows = rowsPerRoll + (i < remainingRows ? 1 : 0)
if (currentRollRows <= 0) {
continue
}
segments.push({
rollIndex: i + 1,
startRow: startRow,
endRow: startRow + currentRollRows - 1,
rowCount: currentRollRows
})
startRow += currentRollRows
}
return segments
},
getRollSegmentByRowIndex(rowIndex) {
const segments = this.getRollSegments()
return segments.find(item => rowIndex >= item.startRow && rowIndex <= item.endRow) || null
},
getRollSegmentByRollIndex(rollIndex) {
const segments = this.getRollSegments()
return segments.find(item => item.rollIndex === rollIndex) || null
},
ensureRollDefectList(rollIndex) {
const key = String(rollIndex)
if (!Array.isArray(this.rollDefectMap[key])) {
this.$set(this.rollDefectMap, key, [])
}
},
openRollDefectDialog(rowIndex) {
const segment = this.getRollSegmentByRowIndex(rowIndex)
if (!segment) {
this.$message.warning('当前卷信息无效,请先确认排数和卷数')
return
}
this.currentRollDefectIndex = segment.rollIndex
this.ensureRollDefectList(segment.rollIndex)
this.currentRollDefectList = this.rollDefectMap[String(segment.rollIndex)]
this.resetRollDefectForm()
this.rollDefectDialogVisible = true
},
getRollSurfaceLossQty(rollIndex) {
const segment = this.getRollSegmentByRollIndex(rollIndex)
if (!segment) {
return 0
}
let total = 0
for (let i = segment.startRow; i <= segment.endRow; i++) {
const row = this.rowDataList[i]
total += Number(row && row.surfaceLossQty ? row.surfaceLossQty : 0)
}
return total
},
getCurrentRollSurfaceLossQty() {
return this.getRollSurfaceLossQty(this.currentRollDefectIndex)
},
getRollDefectTotal(rollIndex) {
const list = this.rollDefectMap[String(rollIndex)] || []
return list.reduce((sum, item) => sum + Number(item && item.defectQty ? item.defectQty : 0), 0)
},
getCurrentRollDefectTotal() {
return this.getRollDefectTotal(this.currentRollDefectIndex)
},
formatQty(value) {
const num = Number(value || 0)
return Number(num.toFixed(6)).toString()
},
async addRollDefectItem() {
if (!this.currentRollDefectList) {
return
}
this.rollDefectForm.defectCode = (this.rollDefectForm.defectCode || '').trim().toUpperCase()
if (!this.rollDefectForm.defectCode) {
this.$message.error('请先选择不良代码')
return
}
if (!this.rollDefectForm.defectDesc) {
this.$message.error('请选择有效的不良代码')
return
}
const defectQty = Number(this.rollDefectForm.defectQty)
if (!defectQty || defectQty <= 0) {
this.$message.error('不良数量必须大于0')
return
}
const existing = this.currentRollDefectList.find(item => item.defectCode === this.rollDefectForm.defectCode)
if (existing) {
existing.defectQty = Number(existing.defectQty || 0) + defectQty
existing.defectDesc = this.rollDefectForm.defectDesc
} else {
this.currentRollDefectList.push({
defectCode: this.rollDefectForm.defectCode,
defectDesc: this.rollDefectForm.defectDesc,
defectQty: defectQty
})
}
this.resetRollDefectForm()
},
removeRollDefectItem(index) {
if (!this.currentRollDefectList) {
return
}
this.currentRollDefectList.splice(index, 1)
},
getBaseData(val) {
if (this.tagNo === 89) {
this.rollDefectForm.defectCode = val.DefectCode || ''
this.rollDefectForm.defectDesc = val.DefectDesc || ''
}
},
getBaseList(val) {
this.tagNo = val
this.$nextTick(() => {
let strVal = ''
if (val === 89) {
strVal = this.rollDefectForm.defectCode || ''
}
this.$refs.baseList.init(val, strVal)
})
},
getRollDefectDetails(rollIndex) {
const list = this.rollDefectMap[String(rollIndex)] || []
return list
.map(item => ({
defectCode: item.defectCode,
defectDesc: item.defectDesc || '',
defectQty: Number(item.defectQty || 0)
}))
.filter(item => item.defectCode && item.defectQty > 0)
},
//
validateRollDefectQtyBySurfaceLoss() {
const segments = this.getRollSegments()
if (!segments.length) {
return true
}
this.normalizeRollDefectMap()
for (let i = 0; i < segments.length; i++) {
const rollIndex = segments[i].rollIndex
const surfaceLossQty = this.getRollSurfaceLossQty(rollIndex)
const defectReasonQty = this.getRollDefectTotal(rollIndex)
if (Math.abs(surfaceLossQty - defectReasonQty) > 0.000001) {
this.$message.error(`${rollIndex}卷不良原因数量合计(${this.formatQty(defectReasonQty)})必须等于该卷面损数合计(${this.formatQty(surfaceLossQty)})`)
return false
}
}
return true
},
//
validateRowData() {
if (this.pageData.rowCount <= 0) {
@ -784,13 +1084,26 @@ export default {
return true
}
for (let i = 0; i < this.rowDataList.length; i++) {
const row = this.rowDataList[i]
const segments = this.getRollSegments()
if (!segments.length) {
return true
}
for (let i = 0; i < segments.length; i++) {
const segment = segments[i]
let hasPackingList = false
for (let rowIndex = segment.startRow; rowIndex <= segment.endRow; rowIndex++) {
const row = this.rowDataList[rowIndex]
const packingList = row && row.packingList !== undefined && row.packingList !== null
? String(row.packingList).trim()
: ''
if (!packingList) {
this.$message.error(`Packing List不能为空`)
if (packingList) {
hasPackingList = true
break
}
}
if (!hasPackingList) {
this.$message.error(`${segment.rollIndex}卷的Packing List不能为空`)
return false
}
}
@ -899,6 +1212,11 @@ export default {
return false;
}
//
if (!this.validateRollDefectQtyBySurfaceLoss()) {
return false;
}
//
try {
await this.$confirm('确定执行异常截卷操作吗?该操作将执行产量报告。', '提示', {
@ -978,6 +1296,7 @@ export default {
rollNums: 1,
totalDefectQty: totalDefectQty,
rollRows: rollRows,
rollDefectDetails: this.getRollDefectDetails(rollIndex + 1),
packingList: rollPackingList,
remark: rollRemark
};
@ -1062,42 +1381,23 @@ export default {
//
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
// Packing List
if (column.label === '备注' || column.label === 'Packing List') {
//
const rowsPerRoll = Math.floor(this.pageData.rowCount / this.pageData.rollCount)
const remainingRows = this.pageData.rowCount % this.pageData.rollCount
//
let currentRollIndex = 0
let accumulatedRows = 0
for (let i = 0; i < this.pageData.rollCount; i++) {
const currentRollRows = rowsPerRoll + (i < remainingRows ? 1 : 0)
if (rowIndex < accumulatedRows + currentRollRows) {
currentRollIndex = i
break
}
accumulatedRows += currentRollRows
// Packing List
if (column.label === '备注' || column.label === 'Packing List' || column.label === '操作') {
const segment = this.getRollSegmentByRowIndex(rowIndex)
if (!segment) {
return
}
//
const currentRollRows = rowsPerRoll + (currentRollIndex < remainingRows ? 1 : 0)
//
if (rowIndex === accumulatedRows) {
if (rowIndex === segment.startRow) {
return {
rowspan: currentRollRows,
rowspan: segment.rowCount,
colspan: 1
}
} else {
//
}
return {
rowspan: 0,
colspan: 0
}
}
}
},
// wrapper使padding-top
@ -1105,26 +1405,11 @@ export default {
if (this.pageData.rowCount <= 0 || this.pageData.rollCount <= 0) {
return {}
}
//
const rowsPerRoll = Math.floor(this.pageData.rowCount / this.pageData.rollCount)
const remainingRows = this.pageData.rowCount % this.pageData.rollCount
//
let currentRollIndex = 0
let accumulatedRows = 0
for (let i = 0; i < this.pageData.rollCount; i++) {
const currentRollRows = rowsPerRoll + (i < remainingRows ? 1 : 0)
if (rowIndex < accumulatedRows + currentRollRows) {
currentRollIndex = i
break
}
accumulatedRows += currentRollRows
const segment = this.getRollSegmentByRowIndex(rowIndex)
if (!segment) {
return {}
}
//
const currentRollRows = rowsPerRoll + (currentRollIndex < remainingRows ? 1 : 0)
const currentRollRows = segment.rowCount
// 32px
const rowHeight = 32
@ -1432,6 +1717,12 @@ export default {
return false
}
//
if (!this.validateRollDefectQtyBySurfaceLoss()) {
this.yieldReportLoading = false;
return false
}
try {
//
const rowsPerRoll = Math.floor(this.pageData.rowCount / this.pageData.rollCount)
@ -1484,6 +1775,7 @@ export default {
rollNums: 1, // 1
defectQty: totalDefectQty, //
rollRows: rollRows, //
rollDefectDetails: this.getRollDefectDetails(rollIndex + 1),
packingList: rollPackingList, // Packing List
remark: rollRemark //
}
@ -1797,7 +2089,6 @@ export default {
}
/* 备注列单元格样式 - 使用绝对定位填满 */
.customer-dialog >>> .el-table td:last-child,
.customer-dialog >>> .el-table td.remark-column,
.customer-dialog >>> .el-table td.packing-list-column {
padding: 0 !important;
@ -1805,7 +2096,6 @@ export default {
overflow: hidden !important;
}
.customer-dialog /deep/ .el-table td:last-child,
.customer-dialog /deep/ .el-table td.remark-column,
.customer-dialog /deep/ .el-table td.packing-list-column {
padding: 0 !important;
@ -1869,6 +2159,33 @@ export default {
overflow-y: auto !important;
}
/* 分卷不良原因对话框 */
.roll-defect-summary {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
padding: 8px 12px;
background: #f5f7fa;
border-radius: 4px;
color: #606266;
}
.roll-defect-form /deep/ .el-form-item {
margin-right: 12px;
}
.roll-defect-form .defect-code-label a {
color: #409EFF;
font-weight: 600;
cursor: pointer;
}
.roll-defect-form /deep/ .defect-code-input .el-input__inner {
color: #409EFF;
font-weight: 600;
}
</style>
<style lang="scss">
@ -1886,7 +2203,6 @@ export default {
}
/* 备注列样式 - 只针对创建分卷对话框 */
.customer-css .el-table td:last-child,
.customer-css .el-table td.remark-column,
.customer-css .el-table td.packing-list-column {
padding: 0 !important;

Loading…
Cancel
Save