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 {
const deliverySnapVal = deliveryFields?.[DELIVERY_SNAPSHOT_JSON_FIELD_ID];
let deliverySnapStr: string | null = null;
if (typeof deliverySnapVal === 'string') {
deliverySnapStr = deliverySnapVal;
} else if (Array.isArray(deliverySnapVal)) {
const texts = deliverySnapVal
.filter((el: any) => el && el.type === 'text' && typeof el.text === 'string')
.map((el: any) => el.text);
deliverySnapStr = texts.length > 0 ? texts.join('') : null;
} else if (deliverySnapVal && typeof deliverySnapVal === 'object') {
if ((deliverySnapVal as any).text && typeof (deliverySnapVal as any).text === 'string') {
deliverySnapStr = (deliverySnapVal as any).text;
} else if ((deliverySnapVal as any).type === 'text' && typeof (deliverySnapVal as any).text === 'string') {
deliverySnapStr = (deliverySnapVal as any).text;
const extractAllText = (val: any): string => {
if (val === null || val === undefined) return '';
if (typeof val === 'string') return val;
if (typeof val === 'number') return String(val);
if (Array.isArray(val)) {
return val
.map((el: any) => {
if (el === null || el === undefined) return '';
if (typeof el === 'string') return el;
if (typeof el === 'number') return String(el);
if (typeof el === 'object') return el.text || el.name || el.value?.toString?.() || '';
return '';
})
.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() !== '') {
setIsRestoringSnapshot(true);
@ -1868,6 +1874,7 @@ export default function App() {
const DELIVERY_ADJUSTMENT_INFO_FIELD_ID = 'fldNc6nNsz'; // 货期调整信息字段需要替换为实际字段ID
const DELIVERY_VERSION_FIELD_ID = 'fld5OmvZrn'; // 版本字段(新增)
const DELIVERY_SNAPSHOT_JSON_FIELD_ID = 'fldEYIvHeP'; // 货期记录表:完整快照(JSON)
const DELIVERY_SNAPSHOT_JSON_2_FIELD_ID = 'fldFr999QY';
// 起始时间字段(货期记录表新增)
const DELIVERY_START_TIME_FIELD_ID = 'fld727qCAv';
// 文本2字段货期记录表新增
@ -4526,7 +4533,9 @@ export default function App() {
DELIVERY_NODE_DETAILS_FIELD_ID,
DELIVERY_ADJUSTMENT_INFO_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);
@ -4546,6 +4555,7 @@ export default function App() {
versionField,
startTimeField,
snapshotField,
snapshot2Field,
recordIdsTextField,
factoryDepartureDateField
] = await Promise.all([
@ -4562,6 +4572,7 @@ export default function App() {
deliveryRecordTable.getField(DELIVERY_VERSION_FIELD_ID),
deliveryRecordTable.getField(DELIVERY_START_TIME_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_FACTORY_DEPARTURE_DATE_FIELD_ID)
]);
@ -4879,6 +4890,9 @@ export default function App() {
snapshotType: 'complete'
};
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
const startTimestamp = currentStartTime ? currentStartTime.getTime() : currentTime;
@ -4896,6 +4910,7 @@ export default function App() {
createTimeCell,
startTimeCell,
snapshotCell,
snapshot2Cell,
expectedDateCell,
customerExpectedDateCell,
factoryDepartureDateCell,
@ -4911,7 +4926,8 @@ export default function App() {
text2Field.createCell(text2),
createTimeField.createCell(currentTime),
startTimeField.createCell(startTimestamp),
snapshotField.createCell(snapshotJson),
snapshotField.createCell(snapshotJson1),
snapshotJson2 ? snapshot2Field.createCell(snapshotJson2) : Promise.resolve(null),
expectedDeliveryDate ? expectedDateField.createCell(expectedDeliveryDate) : Promise.resolve(null),
customerExpectedDate ? customerExpectedDateField.createCell(customerExpectedDate) : Promise.resolve(null),
factoryDepartureDate ? factoryDepartureDateField.createCell(factoryDepartureDate) : Promise.resolve(null),
@ -4922,7 +4938,9 @@ export default function App() {
]);
// 组合所有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
if (labelsCell) recordCells.push(labelsCell);