From fa6b1b8adab35a250c333cad093bacefbe8b585a Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Fri, 12 Dec 2025 13:07:37 +0800 Subject: [PATCH] =?UTF-8?q?2025-12-12=20=E8=BF=87=E7=AB=99=E9=87=87?= =?UTF-8?q?=E9=9B=86-=E3=80=8B=E8=BD=A6=E9=97=B4=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0->=E5=88=9B=E5=BB=BA=E5=88=86=E5=8D=B7-?= =?UTF-8?q?=E3=80=8B=E5=BC=82=E5=B8=B8=E6=88=AA=E5=8D=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/yieldReport/com_separate_roll.js | 11 + .../modules/yieldReport/com_separate_roll.vue | 198 ++++++++++++++++++ 2 files changed, 209 insertions(+) diff --git a/src/api/yieldReport/com_separate_roll.js b/src/api/yieldReport/com_separate_roll.js index 2d1f0fc..bb9d65b 100644 --- a/src/api/yieldReport/com_separate_roll.js +++ b/src/api/yieldReport/com_separate_roll.js @@ -37,3 +37,14 @@ export const markShiftChangeAsProcessed = data => createAPI('schedule/shiftChang // 校验数据条数 export const validateShiftChangeDataCount = data => createAPI('schedule/shiftChange/validateDataCount', 'POST', data) +// ==================== 异常截卷相关接口 ==================== + +// 保存异常截卷数据 +export const saveAbnormalRollData = data => createAPI('schedule/abnormalRoll/saveAbnormalRollData', 'POST', data) + +// 查询未处理的异常截卷数据 +export const getUnprocessedAbnormalRollData = data => createAPI('schedule/abnormalRoll/getUnprocessedData', 'POST', data) + +// 更新异常截卷数据为已处理 +export const markAbnormalRollAsProcessed = data => createAPI('schedule/abnormalRoll/markAsProcessed', 'POST', data) + diff --git a/src/views/modules/yieldReport/com_separate_roll.vue b/src/views/modules/yieldReport/com_separate_roll.vue index 36cbb17..5985d6c 100644 --- a/src/views/modules/yieldReport/com_separate_roll.vue +++ b/src/views/modules/yieldReport/com_separate_roll.vue @@ -122,6 +122,7 @@ 产量报告 换班结转 + 异常截卷 {{ buttons.closeButton }} @@ -230,6 +231,7 @@ saveShiftChangeData,/*保存换班结转数据*/ markShiftChangeAsProcessed,/*更新换班结转数据为已处理*/ validateShiftChangeDataCount,/*校验数据条数*/ + saveAbnormalRollData,/*保存异常截卷数据*/ } from '@/api/yieldReport/com_separate_roll.js'; /*打印标签专用的js*/ @@ -332,6 +334,7 @@ export default { saveLoading: false, // 保存loading状态 hasCachedData: false, // 是否有缓存数据 cachedDataCount: 0, // 缓存数据条数 + cachedRowDataList: [], // 缓存的原始行数据(用于校验) isLoadingCachedData: false, // 是否正在加载缓存数据(防止触发handleRowCountChange) buttons: { confirmButton: '确定', @@ -477,6 +480,7 @@ export default { // 重置缓存数据标记 this.hasCachedData = false; this.cachedDataCount = 0; + this.cachedRowDataList = []; // 重置缓存的原始行数据 // 清空行数据列表 this.rowDataList = []; //判断是否启用多语言 @@ -542,6 +546,9 @@ export default { remark: item.remark || '' })); + // 保存缓存的原始数据(用于产量报告时校验) + this.cachedRowDataList = JSON.parse(JSON.stringify(this.rowDataList)); + console.log('恢复后的行数据:', this.rowDataList); this.$message.info(`已加载上次换班结转的缓存数据(${this.cachedDataCount}条)`); @@ -715,6 +722,171 @@ export default { } }, + // 异常截卷操作(产量报告 + 换班结转) + async executeAbnormalRollCut() { + // 人员判断 + if (this.pageData.operatorId === '' || this.pageData.operatorId == null) { + this.$message.error(this.labels.pleaseSwitchOperator); + return false; + } + + // 基础校验 + if (this.pageData.rowCount <= 0) { + this.$message.warning('请输入有效的排数'); + return false; + } + if (this.pageData.rollCount <= 0) { + this.$message.warning('请输入有效的卷数'); + return false; + } + if (this.pageData.rollCount > this.pageData.rowCount) { + this.$message.warning('卷数不能大于排数'); + return false; + } + + // 验证排数据 + if (!this.validateRowData()) { + return false; + } + + // 确认框 + try { + await this.$confirm('确定执行异常截卷操作吗?该操作将执行产量报告(不打印)并保存缓存数据。', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }); + } catch (e) { + return false; // 用户取消 + } + + try { + // ========== 第一步:执行产量报告(不打印)========== + // 计算分卷 + const rowsPerRoll = Math.floor(this.pageData.rowCount / this.pageData.rollCount); + const remainingRows = this.pageData.rowCount % this.pageData.rollCount; + + let currentRowIndex = 0; + let newRollNo = ''; // 用于保存产量报告返回的新卷号 + + // 循环创建每一卷 + for (let rollIndex = 0; rollIndex < this.pageData.rollCount; rollIndex++) { + const currentRollRows = rowsPerRoll + (rollIndex < remainingRows ? 1 : 0); + + // 计算当前卷的良品和不良总数 + let totalGoodQty = 0; + let totalDefectQty = 0; + const rollRows = []; + + // 获取当前卷的备注 + let rollRemark = ''; + + for (let i = 0; i < currentRollRows; i++) { + const row = this.rowDataList[currentRowIndex + i]; + totalGoodQty += row.goodQty || 0; + totalDefectQty += row.defectQty || 0; + + if (i === 0) { + rollRemark = row.remark || ''; + } + + rollRows.push({ + rowNumber: row.rowNumber, + goodQty: row.goodQty || 0, + surfaceLossQty: row.surfaceLossQty || 0, + poorPerformanceQty: row.poorPerformanceQty || 0, + defectQty: row.defectQty || 0, + totalQty: row.totalQty || 0, + remark: row.remark || '' + }); + } + + // 构建请求数据 + const requestData = { + ...this.pageData, + rollQty: totalGoodQty, + rollNums: 1, + totalDefectQty: totalDefectQty, + rollRows: rollRows, + remark: rollRemark + }; + + // 调用后端创建单个卷 + const {data} = await createSplitSfdcRoll(requestData); + + if (data.code === 500) { + throw new Error(data.msg); + } + + // 保存返回的新卷号(取最后一个卷的卷号) + if (data.printList && data.printList.length > 0) { + newRollNo = data.printList[0].rollNo || ''; + } + + this.$message.success(`第${rollIndex + 1}/${this.pageData.rollCount}卷创建成功`); + + currentRowIndex += currentRollRows; + } + + // 如果有换班结转缓存数据,标记为已处理 + if (this.hasCachedData) { + try { + await markShiftChangeAsProcessed({ + site: this.scheduleData.site, + orderNo: this.scheduleData.orderNo, + seqNo: parseInt(this.scheduleData.seqNo) || 0, + processedBy: this.pageData.operatorId + }); + this.hasCachedData = false; + this.cachedDataCount = 0; + } catch (err) { + console.error('标记换班结转数据为已处理失败:', err); + } + } + + // ========== 第二步:保存异常截卷缓存数据 ========== + const abnormalRollData = { + site: this.scheduleData.site, + buNo: this.scheduleData.buNo, + orderNo: this.scheduleData.orderNo, + seqNo: parseInt(this.scheduleData.seqNo) || 0, + fixtureNo: this.pageData.fixture, + shiftFrom: this.scheduleData.shiftNo || '', + rowCount: this.pageData.rowCount, + rollCount: this.pageData.rollCount, + createdBy: this.pageData.operatorId, + // 新增字段 + currentRollNo: this.scheduleData.rollNo || '', // 当前卷号(机台工作台的当前卷号) + newRollNo: newRollNo, // 新卷号(产量报告返回的卷号) + operatorId: this.pageData.operatorId, // 操作人 + rowDataList: this.rowDataList.map(row => ({ + rowNumber: row.rowNumber, + goodQty: row.goodQty || 0, + surfaceLossQty: row.surfaceLossQty || 0, + poorPerformanceQty: row.poorPerformanceQty || 0, + defectQty: row.defectQty || 0, + remark: row.remark || '' + })) + }; + + const {data: abnormalData} = await saveAbnormalRollData(abnormalRollData); + + if (abnormalData && abnormalData.code === 0) { + this.$message.success('异常截卷操作完成!数据已保存。'); + // 延时关闭弹窗 + setTimeout(() => { + this.closeDialog(); + }, 1000); + } else { + this.$message.error(abnormalData.msg || '异常截卷缓存数据保存失败'); + } + + } catch (error) { + console.error('异常截卷操作失败:', error); + this.$message.error('异常截卷操作失败:' + error.message); + } + }, + // 表格合并行方法(备注列根据卷数合并) objectSpanMethod({ row, column, rowIndex, columnIndex }) { // 只对备注列进行合并(最后一列) @@ -999,6 +1171,32 @@ export default { return false; } + // 如果有缓存数据,校验缓存中带过来的数据的良品数、面损、性能不良不能小于缓存中的数据 + if (this.hasCachedData && this.cachedRowDataList.length > 0) { + for (let i = 0; i < this.cachedRowDataList.length; i++) { + const cachedRow = this.cachedRowDataList[i]; + const currentRow = this.rowDataList[i]; + + if (currentRow) { + // 校验良品数不能小于缓存值 + if ((currentRow.goodQty || 0) < (cachedRow.goodQty || 0)) { + this.$message.error(`第${i + 1}排的良品数量(${currentRow.goodQty})不能小于缓存值(${cachedRow.goodQty})`); + return false; + } + // 校验面损数量不能小于缓存值 + if ((currentRow.surfaceLossQty || 0) < (cachedRow.surfaceLossQty || 0)) { + this.$message.error(`第${i + 1}排的面损数量(${currentRow.surfaceLossQty})不能小于缓存值(${cachedRow.surfaceLossQty})`); + return false; + } + // 校验性能不良数量不能小于缓存值 + if ((currentRow.poorPerformanceQty || 0) < (cachedRow.poorPerformanceQty || 0)) { + this.$message.error(`第${i + 1}排的性能不良数量(${currentRow.poorPerformanceQty})不能小于缓存值(${cachedRow.poorPerformanceQty})`); + return false; + } + } + } + } + // //获取当前是的数量 // let rollQty = parseFloat(this.pageData.rollQty); // //判断是否可以修改