油漆实验室

This commit is contained in:
卢江海
2025-04-01 15:27:17 +08:00
parent c90ed71ae5
commit 2ee698d264

View File

@@ -414,9 +414,10 @@ export default {
const rowIndex = this.qualityStatistics.findIndex( const rowIndex = this.qualityStatistics.findIndex(
(r) => r.id === row.id (r) => r.id === row.id
); );
// 计算所属分组的起始索引每6行一组
const groupIndex = Math.floor(rowIndex / 6) * 6; // 计算所属分组的起始索引每5行一组
const groupIndex = Math.floor(rowIndex / 5) * 5;
// 如果该组还未创建,初始化分组 // 如果该组还未创建,初始化分组
if (!groupMap.has(groupIndex)) { if (!groupMap.has(groupIndex)) {
groupMap.set(groupIndex, { groupMap.set(groupIndex, {
@@ -427,19 +428,18 @@ export default {
// 将修改行添加到对应分组 // 将修改行添加到对应分组
const group = groupMap.get(groupIndex); const group = groupMap.get(groupIndex);
group.modifiedRows.add(rowIndex % 6); // 记录组内修改的位置 group.modifiedRows.add(rowIndex % 5); // 记录组内修改的位置
}); });
// 构建最终更新数据 // 构建最终更新数据
const updateList = []; const updateList = [];
groupMap.forEach((group, groupIndex) => { groupMap.forEach((group, groupIndex) => {
const groupRows = this.qualityStatistics.slice( const groupRows = this.qualityStatistics.slice(
groupIndex, groupIndex,
groupIndex + 6 groupIndex + 5
); );
// 生成6条更新记录即使部分未修改 // 生成6条更新记录即使部分未修改
Array.from({ length: 6 }).forEach((_, i) => { Array.from({ length: 5 }).forEach((_, i) => {
const row = groupRows[i] || {}; const row = groupRows[i] || {};
if (group.baseRow == undefined) { if (group.baseRow == undefined) {
throw new Error("需要保存的数据不在当前页"); throw new Error("需要保存的数据不在当前页");
@@ -456,11 +456,11 @@ export default {
plValue04: row.value04, plValue04: row.value04,
plValue05: row.value05, plValue05: row.value05,
plValue06: group.baseRow.value06, plValue06: group.baseRow.value06,
plValue07: group.baseRow.value07, plValue07: row.value07,
plValue08: group.baseRow.value08, plValue08: row.value08,
plValue09: row.value09, plValue09: group.baseRow.value09,
plValue10: row.value10, plValue10: group.baseRow.value10,
plValue11: row.value11, plValue11: group.baseRow.value11,
plCreatedBy: row.createdBy, plCreatedBy: row.createdBy,
plCreatedTime: row.createdTime, plCreatedTime: row.createdTime,
plUpdatedBy: row.updatedBy, plUpdatedBy: row.updatedBy,
@@ -468,14 +468,13 @@ export default {
}); });
}); });
}); });
const { code, data } = await UpdateRawMateriallist(updateList); const { code, data } = await UpdateRawMateriallist(updateList);
if (code === 200) { if (code === 200) {
this.$message.success(`成功保存${data}条记录`); this.$message.success(`成功保存${data}条记录`);
this.modifiedRows = {}; this.modifiedRows = {};
await this.fetchData(); await this.fetchData();
// 保持合并单元格状态 // 保持合并单元格状态
this.mergeTableRows(6); this.mergeTableRows(5);
} }
} catch (error) { } catch (error) {
console.error("保存失败:", error); console.error("保存失败:", error);
@@ -643,37 +642,37 @@ export default {
}); });
}, },
// updateRow(row) { updateRow(row) {
// const baseIndex = Math.floor(this.qualityStatistics.indexOf(row) / 5) * 5; const baseIndex = Math.floor(this.qualityStatistics.indexOf(row) / 5) * 5;
// const updatedData = Array.from({ length: 5 }, (_, i) => ({ const updatedData = Array.from({ length: 5 }, (_, i) => ({
// id: this.qualityStatistics[baseIndex + i].id, id: this.qualityStatistics[baseIndex + i].id,
// plIdGroup: this.qualityStatistics[baseIndex + i].idGroup, plIdGroup: this.qualityStatistics[baseIndex + i].idGroup,
// description: this.qualityStatistics[baseIndex].description, description: this.qualityStatistics[baseIndex].description,
// plCode: this.qualityStatistics[baseIndex].code, plCode: this.qualityStatistics[baseIndex].code,
// plPci: this.qualityStatistics[baseIndex].pci, plPci: this.qualityStatistics[baseIndex].pci,
// plValue01: this.qualityStatistics[baseIndex + i].value01, plValue01: this.qualityStatistics[baseIndex + i].value01,
// plValue02: this.qualityStatistics[baseIndex + i].value02, plValue02: this.qualityStatistics[baseIndex + i].value02,
// plValue03: this.qualityStatistics[baseIndex + i].value03, plValue03: this.qualityStatistics[baseIndex + i].value03,
// plValue04: this.qualityStatistics[baseIndex + i].value04, plValue04: this.qualityStatistics[baseIndex + i].value04,
// plValue05: this.qualityStatistics[baseIndex + i].value05, plValue05: this.qualityStatistics[baseIndex + i].value05,
// plValue06: this.qualityStatistics[baseIndex].value06, plValue06: this.qualityStatistics[baseIndex].value06,
// plValue07: this.qualityStatistics[baseIndex + i].value07, plValue07: this.qualityStatistics[baseIndex + i].value07,
// plValue08: this.qualityStatistics[baseIndex + i].value08, plValue08: this.qualityStatistics[baseIndex + i].value08,
// plValue09: this.qualityStatistics[baseIndex].value09, plValue09: this.qualityStatistics[baseIndex].value09,
// plValue10: this.qualityStatistics[baseIndex].value10, plValue10: this.qualityStatistics[baseIndex].value10,
// plValue11: this.qualityStatistics[baseIndex].value11, plValue11: this.qualityStatistics[baseIndex].value11,
// plCreatedBy: this.qualityStatistics[baseIndex + i].createdBy, plCreatedBy: this.qualityStatistics[baseIndex + i].createdBy,
// plCreatedTime: this.qualityStatistics[baseIndex + i].createdTime, plCreatedTime: this.qualityStatistics[baseIndex + i].createdTime,
// plUpdatedBy: this.qualityStatistics[baseIndex + i].updatedBy, plUpdatedBy: this.qualityStatistics[baseIndex + i].updatedBy,
// plUpdatedTime: this.qualityStatistics[baseIndex + i].updatedTime, plUpdatedTime: this.qualityStatistics[baseIndex + i].updatedTime,
// })); }));
// UpdateRawMateriallist(updatedData).then((res) => { UpdateRawMateriallist(updatedData).then((res) => {
// if (res.code === 200) { if (res.code === 200) {
// this.$message.success(`更新成功-${res.data}`); this.$message.success(`更新成功-${res.data}`);
// } }
// }); });
// }, },
mergeTableRows(rowsPerGroup) { mergeTableRows(rowsPerGroup) {
this.mergedCells = []; this.mergedCells = [];