油漆实验室
This commit is contained in:
parent
c90ed71ae5
commit
2ee698d264
@ -414,9 +414,10 @@ export default {
|
||||
const rowIndex = this.qualityStatistics.findIndex(
|
||||
(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)) {
|
||||
groupMap.set(groupIndex, {
|
||||
@ -427,19 +428,18 @@ export default {
|
||||
|
||||
// 将修改行添加到对应分组
|
||||
const group = groupMap.get(groupIndex);
|
||||
group.modifiedRows.add(rowIndex % 6); // 记录组内修改的位置
|
||||
group.modifiedRows.add(rowIndex % 5); // 记录组内修改的位置
|
||||
});
|
||||
|
||||
|
||||
// 构建最终更新数据
|
||||
const updateList = [];
|
||||
groupMap.forEach((group, groupIndex) => {
|
||||
const groupRows = this.qualityStatistics.slice(
|
||||
groupIndex,
|
||||
groupIndex + 6
|
||||
groupIndex + 5
|
||||
);
|
||||
|
||||
// 生成6条更新记录(即使部分未修改)
|
||||
Array.from({ length: 6 }).forEach((_, i) => {
|
||||
Array.from({ length: 5 }).forEach((_, i) => {
|
||||
const row = groupRows[i] || {};
|
||||
if (group.baseRow == undefined) {
|
||||
throw new Error("需要保存的数据不在当前页");
|
||||
@ -456,11 +456,11 @@ export default {
|
||||
plValue04: row.value04,
|
||||
plValue05: row.value05,
|
||||
plValue06: group.baseRow.value06,
|
||||
plValue07: group.baseRow.value07,
|
||||
plValue08: group.baseRow.value08,
|
||||
plValue09: row.value09,
|
||||
plValue10: row.value10,
|
||||
plValue11: row.value11,
|
||||
plValue07: row.value07,
|
||||
plValue08: row.value08,
|
||||
plValue09: group.baseRow.value09,
|
||||
plValue10: group.baseRow.value10,
|
||||
plValue11: group.baseRow.value11,
|
||||
plCreatedBy: row.createdBy,
|
||||
plCreatedTime: row.createdTime,
|
||||
plUpdatedBy: row.updatedBy,
|
||||
@ -468,14 +468,13 @@ export default {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
const { code, data } = await UpdateRawMateriallist(updateList);
|
||||
if (code === 200) {
|
||||
this.$message.success(`成功保存${data}条记录`);
|
||||
this.modifiedRows = {};
|
||||
await this.fetchData();
|
||||
// 保持合并单元格状态
|
||||
this.mergeTableRows(6);
|
||||
this.mergeTableRows(5);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("保存失败:", error);
|
||||
@ -643,37 +642,37 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// updateRow(row) {
|
||||
// const baseIndex = Math.floor(this.qualityStatistics.indexOf(row) / 5) * 5;
|
||||
// const updatedData = Array.from({ length: 5 }, (_, i) => ({
|
||||
// id: this.qualityStatistics[baseIndex + i].id,
|
||||
// plIdGroup: this.qualityStatistics[baseIndex + i].idGroup,
|
||||
// description: this.qualityStatistics[baseIndex].description,
|
||||
// plCode: this.qualityStatistics[baseIndex].code,
|
||||
// plPci: this.qualityStatistics[baseIndex].pci,
|
||||
// plValue01: this.qualityStatistics[baseIndex + i].value01,
|
||||
// plValue02: this.qualityStatistics[baseIndex + i].value02,
|
||||
// plValue03: this.qualityStatistics[baseIndex + i].value03,
|
||||
// plValue04: this.qualityStatistics[baseIndex + i].value04,
|
||||
// plValue05: this.qualityStatistics[baseIndex + i].value05,
|
||||
// plValue06: this.qualityStatistics[baseIndex].value06,
|
||||
// plValue07: this.qualityStatistics[baseIndex + i].value07,
|
||||
// plValue08: this.qualityStatistics[baseIndex + i].value08,
|
||||
// plValue09: this.qualityStatistics[baseIndex].value09,
|
||||
// plValue10: this.qualityStatistics[baseIndex].value10,
|
||||
// plValue11: this.qualityStatistics[baseIndex].value11,
|
||||
// plCreatedBy: this.qualityStatistics[baseIndex + i].createdBy,
|
||||
// plCreatedTime: this.qualityStatistics[baseIndex + i].createdTime,
|
||||
// plUpdatedBy: this.qualityStatistics[baseIndex + i].updatedBy,
|
||||
// plUpdatedTime: this.qualityStatistics[baseIndex + i].updatedTime,
|
||||
// }));
|
||||
updateRow(row) {
|
||||
const baseIndex = Math.floor(this.qualityStatistics.indexOf(row) / 5) * 5;
|
||||
const updatedData = Array.from({ length: 5 }, (_, i) => ({
|
||||
id: this.qualityStatistics[baseIndex + i].id,
|
||||
plIdGroup: this.qualityStatistics[baseIndex + i].idGroup,
|
||||
description: this.qualityStatistics[baseIndex].description,
|
||||
plCode: this.qualityStatistics[baseIndex].code,
|
||||
plPci: this.qualityStatistics[baseIndex].pci,
|
||||
plValue01: this.qualityStatistics[baseIndex + i].value01,
|
||||
plValue02: this.qualityStatistics[baseIndex + i].value02,
|
||||
plValue03: this.qualityStatistics[baseIndex + i].value03,
|
||||
plValue04: this.qualityStatistics[baseIndex + i].value04,
|
||||
plValue05: this.qualityStatistics[baseIndex + i].value05,
|
||||
plValue06: this.qualityStatistics[baseIndex].value06,
|
||||
plValue07: this.qualityStatistics[baseIndex + i].value07,
|
||||
plValue08: this.qualityStatistics[baseIndex + i].value08,
|
||||
plValue09: this.qualityStatistics[baseIndex].value09,
|
||||
plValue10: this.qualityStatistics[baseIndex].value10,
|
||||
plValue11: this.qualityStatistics[baseIndex].value11,
|
||||
plCreatedBy: this.qualityStatistics[baseIndex + i].createdBy,
|
||||
plCreatedTime: this.qualityStatistics[baseIndex + i].createdTime,
|
||||
plUpdatedBy: this.qualityStatistics[baseIndex + i].updatedBy,
|
||||
plUpdatedTime: this.qualityStatistics[baseIndex + i].updatedTime,
|
||||
}));
|
||||
|
||||
// UpdateRawMateriallist(updatedData).then((res) => {
|
||||
// if (res.code === 200) {
|
||||
// this.$message.success(`更新成功-${res.data}`);
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
UpdateRawMateriallist(updatedData).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.$message.success(`更新成功-${res.data}`);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
mergeTableRows(rowsPerGroup) {
|
||||
this.mergedCells = [];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user