From b01d5293b7586953983e101931cd7fe33323bc8a Mon Sep 17 00:00:00 2001 From: fengyuan_yang <1976974459@qq.com> Date: Wed, 3 Dec 2025 09:55:43 +0800 Subject: [PATCH] =?UTF-8?q?2025-12-03=201=E3=80=81=E5=A2=9E=E5=8A=A0"?= =?UTF-8?q?=E6=8D=A2=E7=8F=AD=E7=BB=93=E8=BD=AC"=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=9A=E4=BA=A7=E9=87=8F=E6=8A=A5=E5=91=8A=E3=80=81=E6=8D=A2?= =?UTF-8?q?=E7=8F=AD=E7=BB=93=E8=BD=AC=E3=80=81=E5=85=B3=E9=97=AD=20=20=20?= =?UTF-8?q?=20=20=20=20=20=201.1=20=20=20=E5=8F=AA=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=B0shift=5Fchange=5Fproduction=5Freport=EF=BC=8C=E4=B8=8D?= =?UTF-8?q?=E8=B5=B0=E4=B9=8B=E5=89=8D=E7=9A=84=E4=BF=9D=E5=AD=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=202=E3=80=81=E6=AF=8F=E6=AC=A1=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=88=86=E5=8D=B7=E6=97=B6=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AEsite+order=5Fno=20+=20seq=5Fno=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=87=BAis=5Fprocessed=20=3D=200=E7=9A=84=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E6=95=B0=E6=8D=AE=E5=B9=B6=E8=B5=8B=E5=80=BC?= =?UTF-8?q?=E5=88=B0=E5=89=8D=E5=8F=B0=E7=95=8C=E9=9D=A2=203=E3=80=81?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E5=89=8D=E6=A0=A1=E9=AA=8C=E8=BF=99=E4=BA=9B?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A1=AB=E5=86=99=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BF=85=E9=A1=BB=E5=A4=A7=E4=BA=8E=E7=AD=89=E4=BA=8Eshift=5Fc?= =?UTF-8?q?hange=5Fproduction=5Freport=E8=A1=A8=E4=B8=AD=E7=9A=84=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=204=E3=80=81=E4=BF=9D=E5=AD=98=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E6=A0=B9=E6=8D=AE=E6=9D=A1=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0shift=5Fchange=5Fproduction=5Freport=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?is=5Fprocessed=20=3D=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/yieldReport/com_separate_roll.js | 14 ++ .../modules/yieldReport/com_separate_roll.vue | 198 +++++++++++++++++- 2 files changed, 206 insertions(+), 6 deletions(-) diff --git a/src/api/yieldReport/com_separate_roll.js b/src/api/yieldReport/com_separate_roll.js index c8bba18..2d1f0fc 100644 --- a/src/api/yieldReport/com_separate_roll.js +++ b/src/api/yieldReport/com_separate_roll.js @@ -23,3 +23,17 @@ export const getFixedCarrierList = data => createAPI('schedule/getFixedCarrierLi // 批量更新固定载具可用数量 export const updateFixedCarrierBatch = data => createAPI('schedule/updateFixedCarrierBatch', 'POST', data) +// ==================== 换班结转相关接口 ==================== + +// 查询未处理的换班结转数据 +export const getUnprocessedShiftChangeData = data => createAPI('schedule/shiftChange/getUnprocessedData', 'POST', data) + +// 保存换班结转数据 +export const saveShiftChangeData = data => createAPI('schedule/shiftChange/saveShiftChangeData', 'POST', data) + +// 更新换班结转数据为已处理 +export const markShiftChangeAsProcessed = data => createAPI('schedule/shiftChange/markAsProcessed', 'POST', data) + +// 校验数据条数 +export const validateShiftChangeDataCount = data => createAPI('schedule/shiftChange/validateDataCount', 'POST', data) + diff --git a/src/views/modules/yieldReport/com_separate_roll.vue b/src/views/modules/yieldReport/com_separate_roll.vue index 980e2cf..36cbb17 100644 --- a/src/views/modules/yieldReport/com_separate_roll.vue +++ b/src/views/modules/yieldReport/com_separate_roll.vue @@ -120,7 +120,8 @@ - 保存 + 产量报告 + 换班结转 {{ buttons.closeButton }} @@ -225,6 +226,10 @@ checkCreateSplitSfdcRoll,/*校验是否可以创建分卷*/ createSplitSfdcRoll,/*执行创建分卷的操作*/ getFixedCarrierList,/*获取固定载具列表*/ + getUnprocessedShiftChangeData,/*查询未处理的换班结转数据*/ + saveShiftChangeData,/*保存换班结转数据*/ + markShiftChangeAsProcessed,/*更新换班结转数据为已处理*/ + validateShiftChangeDataCount,/*校验数据条数*/ } from '@/api/yieldReport/com_separate_roll.js'; /*打印标签专用的js*/ @@ -325,6 +330,9 @@ export default { }, editBatchVisible: false, // 批量编辑状态 saveLoading: false, // 保存loading状态 + hasCachedData: false, // 是否有缓存数据 + cachedDataCount: 0, // 缓存数据条数 + isLoadingCachedData: false, // 是否正在加载缓存数据(防止触发handleRowCountChange) buttons: { confirmButton: '确定', closeButton: '关闭', @@ -442,7 +450,10 @@ export default { }, methods: { //页面初始化是的方法 - init(scheduleData, operatorData) { + async init(scheduleData, operatorData) { + // 设置标记,防止初始化过程中触发handleRowCountChange + this.isLoadingCachedData = true; + //初始化参数 this.scheduleData = scheduleData; //初始化操作员对象 @@ -459,25 +470,103 @@ export default { //清空参数 this.pageData.rollQty = 0; this.pageData.rollNums = 1; - // 初始化新增字段 + // 初始化新增字段(先设置默认值) this.pageData.rowCount = scheduleData.rowCount; this.pageData.rollCount = scheduleData.rollCount; this.pageData.fixture = scheduleData.carrierNo; - //判断是否启用多语言 + // 重置缓存数据标记 + this.hasCachedData = false; + this.cachedDataCount = 0; + // 清空行数据列表 + this.rowDataList = []; + //判断是否启用多语言 // this.getMultiLanguageList(); //刷新多语言的信息 //获取焦点 this.$nextTick(() => { this.$refs.rollQty && this.$refs.rollQty.focus(); }); this.titleCon = this.labels.componentTitle;//重置标题 - // 初始化排数据列表 - this.initRowDataList(); + + // 查询是否有缓存的换班结转数据(等待完成) + await this.loadCachedShiftChangeData(); + + // 如果没有缓存数据,初始化空白行 + if (!this.hasCachedData) { + this.initRowDataList(); + } + + // 取消标记 + this.isLoadingCachedData = false; + }, + + // 查询缓存的换班结转数据 + async loadCachedShiftChangeData() { + try { + const params = { + site: this.scheduleData.site, + orderNo: this.scheduleData.orderNo, + seqNo: parseInt(this.scheduleData.seqNo) || 0 + }; + + console.log('查询缓存数据参数:', params); + + const {data} = await getUnprocessedShiftChangeData(params); + + console.log('查询缓存数据结果:', data); + + if (data && data.code === 0 && data.data && data.data.length > 0) { + // 有缓存数据,恢复到界面 + this.hasCachedData = true; + this.cachedDataCount = data.count; + + const cachedList = data.data; + + console.log('缓存数据列表:', cachedList); + + // 恢复排数和卷数 + if (cachedList.length > 0) { + this.pageData.rowCount = cachedList[0].rowCount || 0; + this.pageData.rollCount = cachedList[0].rollCount || 0; + this.pageData.fixture = cachedList[0].fixtureNo || ''; + } + + // 恢复行数据列表 + this.rowDataList = cachedList.map(item => ({ + rowNumber: item.rowBumber, + goodQty: Number(item.goodQty) || 0, + surfaceLossQty: Number(item.surfaceLossQty) || 0, + poorPerformanceQty: Number(item.poorPerformanceQty) || 0, + defectQty: Number(item.defectQty) || 0, + yieldRate: this.calculateYieldRate(Number(item.goodQty) || 0, Number(item.defectQty) || 0), + totalQty: (Number(item.goodQty) || 0) + (Number(item.defectQty) || 0), + remark: item.remark || '' + })); + + console.log('恢复后的行数据:', this.rowDataList); + + this.$message.info(`已加载上次换班结转的缓存数据(${this.cachedDataCount}条)`); + } + // 如果没有缓存数据,不做任何处理,由init方法负责初始化 + } catch (error) { + console.error('加载缓存数据失败:', error); + // 加载失败时不做处理,由init方法负责初始化 + } + }, + + // 计算良率 + calculateYieldRate(goodQty, defectQty) { + const totalQty = goodQty + defectQty; + if (totalQty > 0) { + return ((goodQty / totalQty) * 100).toFixed(2) + '%'; + } + return '0.00%'; }, // ===================== 新增分卷优化方法 ===================== // 初始化排数据列表 initRowDataList() { + console.log('initRowDataList被调用, isLoadingCachedData=', this.isLoadingCachedData, ', 调用栈:', new Error().stack); this.rowDataList = [] for (let i = 0; i < this.pageData.rowCount; i++) { this.rowDataList.push({ @@ -495,6 +584,12 @@ export default { // 排数变化时重新初始化 handleRowCountChange() { + console.log('handleRowCountChange被调用, isLoadingCachedData=', this.isLoadingCachedData); + // 如果是从缓存加载数据,不要重新初始化 + if (this.isLoadingCachedData) { + console.log('跳过初始化,因为正在加载缓存数据'); + return; + } if (this.pageData.rollCount > this.pageData.rowCount) { this.pageData.rollCount = this.pageData.rowCount } @@ -552,6 +647,74 @@ export default { return true }, + // 换班结转保存 + async saveShiftChangeTransfer() { + // 人员判断 + 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.hasCachedData && this.rowDataList.length < this.cachedDataCount) { + this.$message.error(`数据条数不能减少!当前缓存数据${this.cachedDataCount}条,本次提交${this.rowDataList.length}条`); + return false; + } + + try { + // 构建保存数据 + const saveData = { + 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, + 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} = await saveShiftChangeData(saveData); + + if (data && data.code === 0) { + this.$message.success('换班结转数据保存成功!'); + // 更新缓存状态 + this.hasCachedData = true; + this.cachedDataCount = this.rowDataList.length; + // 关闭对话框 + this.closeDialog(); + } else { + this.$message.error(data.msg || '换班结转保存失败'); + } + } catch (error) { + console.error('换班结转保存失败:', error); + this.$message.error('换班结转保存失败:' + error.message); + } + }, + // 表格合并行方法(备注列根据卷数合并) objectSpanMethod({ row, column, rowIndex, columnIndex }) { // 只对备注列进行合并(最后一列) @@ -830,6 +993,12 @@ export default { return false; } + // 如果有缓存数据,校验本次数据条数必须大于等于之前的数据 + if (this.hasCachedData && this.rowDataList.length < this.cachedDataCount) { + this.$message.error(`数据条数不能减少!当前缓存数据${this.cachedDataCount}条,本次提交${this.rowDataList.length}条`); + return false; + } + // //获取当前是的数量 // let rollQty = parseFloat(this.pageData.rollQty); // //判断是否可以修改 @@ -947,6 +1116,23 @@ export default { // 所有卷创建完成 this.$message.success('创建分卷完成!') + // 如果有缓存数据,标记为已处理 + 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); + } + } + // 打印标签(优化版:使用模板打印) if (allPrintList.length > 0) { await this.printLabelsWithTemplate(allPrintList)