This commit is contained in:
2026-03-03 09:40:16 +08:00
parent e337e74edb
commit b8b65e684a

View File

@ -998,22 +998,28 @@ export default function App() {
// 优先使用货期记录表中的快照字段进行一键还原(新方案) // 优先使用货期记录表中的快照字段进行一键还原(新方案)
try { try {
const deliverySnapVal = deliveryFields?.[DELIVERY_SNAPSHOT_JSON_FIELD_ID]; const extractAllText = (val: any): string => {
let deliverySnapStr: string | null = null; if (val === null || val === undefined) return '';
if (typeof deliverySnapVal === 'string') { if (typeof val === 'string') return val;
deliverySnapStr = deliverySnapVal; if (typeof val === 'number') return String(val);
} else if (Array.isArray(deliverySnapVal)) { if (Array.isArray(val)) {
const texts = deliverySnapVal return val
.filter((el: any) => el && el.type === 'text' && typeof el.text === 'string') .map((el: any) => {
.map((el: any) => el.text); if (el === null || el === undefined) return '';
deliverySnapStr = texts.length > 0 ? texts.join('') : null; if (typeof el === 'string') return el;
} else if (deliverySnapVal && typeof deliverySnapVal === 'object') { if (typeof el === 'number') return String(el);
if ((deliverySnapVal as any).text && typeof (deliverySnapVal as any).text === 'string') { if (typeof el === 'object') return el.text || el.name || el.value?.toString?.() || '';
deliverySnapStr = (deliverySnapVal as any).text; return '';
} else if ((deliverySnapVal as any).type === 'text' && typeof (deliverySnapVal as any).text === 'string') { })
deliverySnapStr = (deliverySnapVal as any).text; .join('');
} }
} if (typeof val === 'object') return (val as any).text || (val as any).name || (val as any).value?.toString?.() || '';
return '';
};
const snapPart1 = extractAllText(deliveryFields?.[DELIVERY_SNAPSHOT_JSON_FIELD_ID]);
const snapPart2 = extractAllText(deliveryFields?.[DELIVERY_SNAPSHOT_JSON_2_FIELD_ID]);
const deliverySnapStr = `${snapPart1 || ''}${snapPart2 || ''}`;
if (deliverySnapStr && deliverySnapStr.trim() !== '') { if (deliverySnapStr && deliverySnapStr.trim() !== '') {
setIsRestoringSnapshot(true); setIsRestoringSnapshot(true);
@ -1868,6 +1874,7 @@ export default function App() {
const DELIVERY_ADJUSTMENT_INFO_FIELD_ID = 'fldNc6nNsz'; // 货期调整信息字段需要替换为实际字段ID const DELIVERY_ADJUSTMENT_INFO_FIELD_ID = 'fldNc6nNsz'; // 货期调整信息字段需要替换为实际字段ID
const DELIVERY_VERSION_FIELD_ID = 'fld5OmvZrn'; // 版本字段(新增) const DELIVERY_VERSION_FIELD_ID = 'fld5OmvZrn'; // 版本字段(新增)
const DELIVERY_SNAPSHOT_JSON_FIELD_ID = 'fldEYIvHeP'; // 货期记录表:完整快照(JSON) const DELIVERY_SNAPSHOT_JSON_FIELD_ID = 'fldEYIvHeP'; // 货期记录表:完整快照(JSON)
const DELIVERY_SNAPSHOT_JSON_2_FIELD_ID = 'fldFr999QY';
// 起始时间字段(货期记录表新增) // 起始时间字段(货期记录表新增)
const DELIVERY_START_TIME_FIELD_ID = 'fld727qCAv'; const DELIVERY_START_TIME_FIELD_ID = 'fld727qCAv';
// 文本2字段货期记录表新增 // 文本2字段货期记录表新增
@ -4526,7 +4533,9 @@ export default function App() {
DELIVERY_NODE_DETAILS_FIELD_ID, DELIVERY_NODE_DETAILS_FIELD_ID,
DELIVERY_ADJUSTMENT_INFO_FIELD_ID, // 添加货期调整信息字段 DELIVERY_ADJUSTMENT_INFO_FIELD_ID, // 添加货期调整信息字段
DELIVERY_START_TIME_FIELD_ID, // 新增:起始时间字段 DELIVERY_START_TIME_FIELD_ID, // 新增:起始时间字段
DELIVERY_FACTORY_DEPARTURE_DATE_FIELD_ID DELIVERY_FACTORY_DEPARTURE_DATE_FIELD_ID,
DELIVERY_SNAPSHOT_JSON_FIELD_ID,
DELIVERY_SNAPSHOT_JSON_2_FIELD_ID
]; ];
console.log('需要检查的字段ID列表:', fieldsToCheck); console.log('需要检查的字段ID列表:', fieldsToCheck);
@ -4546,6 +4555,7 @@ export default function App() {
versionField, versionField,
startTimeField, startTimeField,
snapshotField, snapshotField,
snapshot2Field,
recordIdsTextField, recordIdsTextField,
factoryDepartureDateField factoryDepartureDateField
] = await Promise.all([ ] = await Promise.all([
@ -4562,6 +4572,7 @@ export default function App() {
deliveryRecordTable.getField(DELIVERY_VERSION_FIELD_ID), deliveryRecordTable.getField(DELIVERY_VERSION_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_START_TIME_FIELD_ID), deliveryRecordTable.getField(DELIVERY_START_TIME_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_SNAPSHOT_JSON_FIELD_ID), deliveryRecordTable.getField(DELIVERY_SNAPSHOT_JSON_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_SNAPSHOT_JSON_2_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_RECORD_IDS_FIELD_ID), deliveryRecordTable.getField(DELIVERY_RECORD_IDS_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_FACTORY_DEPARTURE_DATE_FIELD_ID) deliveryRecordTable.getField(DELIVERY_FACTORY_DEPARTURE_DATE_FIELD_ID)
]); ]);
@ -4879,6 +4890,9 @@ export default function App() {
snapshotType: 'complete' snapshotType: 'complete'
}; };
const snapshotJson = JSON.stringify(completeSnapshot); const snapshotJson = JSON.stringify(completeSnapshot);
const snapshotPart1MaxLen = 80000;
const snapshotJson1 = snapshotJson.length > snapshotPart1MaxLen ? snapshotJson.slice(0, snapshotPart1MaxLen) : snapshotJson;
const snapshotJson2 = snapshotJson.length > snapshotPart1MaxLen ? snapshotJson.slice(snapshotPart1MaxLen) : '';
// 使用createCell方法创建各个字段的Cell // 使用createCell方法创建各个字段的Cell
const startTimestamp = currentStartTime ? currentStartTime.getTime() : currentTime; const startTimestamp = currentStartTime ? currentStartTime.getTime() : currentTime;
@ -4896,6 +4910,7 @@ export default function App() {
createTimeCell, createTimeCell,
startTimeCell, startTimeCell,
snapshotCell, snapshotCell,
snapshot2Cell,
expectedDateCell, expectedDateCell,
customerExpectedDateCell, customerExpectedDateCell,
factoryDepartureDateCell, factoryDepartureDateCell,
@ -4911,7 +4926,8 @@ export default function App() {
text2Field.createCell(text2), text2Field.createCell(text2),
createTimeField.createCell(currentTime), createTimeField.createCell(currentTime),
startTimeField.createCell(startTimestamp), startTimeField.createCell(startTimestamp),
snapshotField.createCell(snapshotJson), snapshotField.createCell(snapshotJson1),
snapshotJson2 ? snapshot2Field.createCell(snapshotJson2) : Promise.resolve(null),
expectedDeliveryDate ? expectedDateField.createCell(expectedDeliveryDate) : Promise.resolve(null), expectedDeliveryDate ? expectedDateField.createCell(expectedDeliveryDate) : Promise.resolve(null),
customerExpectedDate ? customerExpectedDateField.createCell(customerExpectedDate) : Promise.resolve(null), customerExpectedDate ? customerExpectedDateField.createCell(customerExpectedDate) : Promise.resolve(null),
factoryDepartureDate ? factoryDepartureDateField.createCell(factoryDepartureDate) : Promise.resolve(null), factoryDepartureDate ? factoryDepartureDateField.createCell(factoryDepartureDate) : Promise.resolve(null),
@ -4922,7 +4938,9 @@ export default function App() {
]); ]);
// 组合所有Cell到一个记录中 // 组合所有Cell到一个记录中
recordCells = [foreignIdCell, styleCell, colorCell, text2Cell, createTimeCell, startTimeCell, versionCell, snapshotCell, recordIdsCell]; recordCells = [foreignIdCell, styleCell, colorCell, text2Cell, createTimeCell, startTimeCell, versionCell, snapshotCell];
if (snapshot2Cell) recordCells.push(snapshot2Cell);
recordCells.push(recordIdsCell);
// 只有当数据存在时才添加对应的Cell // 只有当数据存在时才添加对应的Cell
if (labelsCell) recordCells.push(labelsCell); if (labelsCell) recordCells.push(labelsCell);