Browse Source

2025-12-03

1、增加"换班结转"按钮:产量报告、换班结转、关闭
        1.1   只保存到shift_change_production_report,不走之前的保存逻辑
2、每次点击创建分卷时,根据site+order_no + seq_no查询出is_processed = 0的,将对应数据并赋值到前台界面
3、保存前校验这些数据填写的数据必须大于等于shift_change_production_report表中的数据
4、保存通过后,根据条件更新shift_change_production_report表中is_processed = 1
master
fengyuan_yang 1 month ago
parent
commit
b01d5293b7
  1. 14
      src/api/yieldReport/com_separate_roll.js
  2. 198
      src/views/modules/yieldReport/com_separate_roll.vue

14
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)

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

@ -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)

Loading…
Cancel
Save