|
|
|
@ -120,7 +120,8 @@ |
|
|
|
</div> |
|
|
|
</el-form> |
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
<el-button type="primary" @click="checkCreateSeparateRolllBun">保存</el-button> |
|
|
|
<el-button type="primary" @click="checkCreateSeparateRolllBun">产量报告</el-button> |
|
|
|
<el-button type="success" @click="saveShiftChangeTransfer">换班结转</el-button> |
|
|
|
<el-button @click="closeDialog">{{ buttons.closeButton }}</el-button> |
|
|
|
</span> |
|
|
|
</el-dialog> |
|
|
|
@ -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) |
|
|
|
|