3
This commit is contained in:
2025-10-29 16:44:30 +08:00
parent 96e5edd283
commit ac347d6f6e

View File

@ -328,6 +328,11 @@ export default function App() {
const DELIVERY_VERSION_FIELD_ID = 'fld5OmvZrn'; // 版本字段(新增) const DELIVERY_VERSION_FIELD_ID = 'fld5OmvZrn'; // 版本字段(新增)
// 起始时间字段(货期记录表新增) // 起始时间字段(货期记录表新增)
const DELIVERY_START_TIME_FIELD_ID = 'fld727qCAv'; const DELIVERY_START_TIME_FIELD_ID = 'fld727qCAv';
// 文本2字段货期记录表
const DELIVERY_TEXT2_FIELD_ID = 'fldG6LZnmU';
// 待批量生成表的文本2字段
const BATCH_TEXT2_FIELD_ID = 'fldlaYgpYO';
// 已移除中国法定节假日相关常量和配置 // 已移除中国法定节假日相关常量和配置
@ -1992,6 +1997,7 @@ export default function App() {
if (customerExpectedDateCell) recordCells.push(customerExpectedDateCell); if (customerExpectedDateCell) recordCells.push(customerExpectedDateCell);
if (nodeDetailsCell) recordCells.push(nodeDetailsCell); if (nodeDetailsCell) recordCells.push(nodeDetailsCell);
if (adjustmentInfoCell) recordCells.push(adjustmentInfoCell); if (adjustmentInfoCell) recordCells.push(adjustmentInfoCell);
if (text2Cell) recordCells.push(text2Cell);
// 添加记录到货期记录表 // 添加记录到货期记录表
const addedRecord = await deliveryRecordTable.addRecord(recordCells); const addedRecord = await deliveryRecordTable.addRecord(recordCells);
@ -2556,10 +2562,11 @@ export default function App() {
} }
} }
// 提取款式、颜色、foreign_id字段 // 提取款式、颜色、foreign_id、文本2字段
let extractedStyle: any = null; let extractedStyle: any = null;
let extractedColor: any = null; let extractedColor: any = null;
let extractedForeignId: any = null; let extractedForeignId: any = null;
let extractedText2: string | null = null;
// 提取款式字段 // 提取款式字段
const styleFieldId = fieldMapping['款式']; const styleFieldId = fieldMapping['款式'];
@ -2618,13 +2625,32 @@ export default function App() {
} }
} }
// 提取文本2字段
const text2FieldId = BATCH_TEXT2_FIELD_ID;
if (text2FieldId && recordFields[text2FieldId]) {
const text2Value = recordFields[text2FieldId];
if (typeof text2Value === 'string') {
extractedText2 = text2Value;
} else if (text2Value && text2Value.text) {
extractedText2 = text2Value.text;
} else if (Array.isArray(text2Value) && text2Value.length > 0) {
const firstValue = text2Value[0];
if (typeof firstValue === 'string') {
extractedText2 = firstValue;
} else if (firstValue && firstValue.text) {
extractedText2 = firstValue.text;
}
}
}
console.log(`记录 ${i + 1} 提取的数据:`, { console.log(`记录 ${i + 1} 提取的数据:`, {
labels: extractedLabels, labels: extractedLabels,
startTime: extractedStartTime, startTime: extractedStartTime,
expectedDate: extractedExpectedDate, expectedDate: extractedExpectedDate,
style: extractedStyle, style: extractedStyle,
color: extractedColor, color: extractedColor,
foreignId: extractedForeignId foreignId: extractedForeignId,
text2: extractedText2
}); });
console.log(`记录 ${i + 1} 字段映射:`, fieldMapping); console.log(`记录 ${i + 1} 字段映射:`, fieldMapping);
@ -2639,7 +2665,7 @@ export default function App() {
} }
// 使用提取的数据进行时效计算 // 使用提取的数据进行时效计算
await calculateTimelineForBatch(extractedLabels, extractedStartTime, extractedExpectedDate, record.id, extractedStyle, extractedColor, extractedForeignId); await calculateTimelineForBatch(extractedLabels, extractedStartTime, extractedExpectedDate, record.id, extractedStyle, extractedColor, extractedForeignId, extractedText2);
successCount++; successCount++;
@ -2689,7 +2715,8 @@ export default function App() {
sourceRecordId: string, sourceRecordId: string,
style?: any, style?: any,
color?: any, color?: any,
foreignId?: any foreignId?: any,
text2Value?: string
) => { ) => {
try { try {
// 1. 获取流程配置表数据 // 1. 获取流程配置表数据
@ -2917,7 +2944,7 @@ export default function App() {
const processRecordIds = await writeToProcessDataTableForBatch(results, sourceRecordId, labels, style, color, foreignId); const processRecordIds = await writeToProcessDataTableForBatch(results, sourceRecordId, labels, style, color, foreignId);
// 写入货期记录表 // 写入货期记录表
await writeToDeliveryRecordTableForBatch(results, processRecordIds, {}, sourceRecordId, labels, startTime, expectedDate, style, color, foreignId); await writeToDeliveryRecordTableForBatch(results, processRecordIds, {}, sourceRecordId, labels, startTime, expectedDate, style, color, foreignId, text2Value);
} }
} catch (error) { } catch (error) {
@ -3089,7 +3116,8 @@ export default function App() {
expectedDate: Date | null, expectedDate: Date | null,
style?: any, style?: any,
color?: any, color?: any,
foreignId?: any foreignId?: any,
text2Value?: string
) => { ) => {
try { try {
// 获取货期记录表 // 获取货期记录表
@ -3107,6 +3135,7 @@ export default function App() {
const adjustmentInfoField = await deliveryRecordTable.getField(DELIVERY_ADJUSTMENT_INFO_FIELD_ID); const adjustmentInfoField = await deliveryRecordTable.getField(DELIVERY_ADJUSTMENT_INFO_FIELD_ID);
const versionField = await deliveryRecordTable.getField(DELIVERY_VERSION_FIELD_ID); const versionField = await deliveryRecordTable.getField(DELIVERY_VERSION_FIELD_ID);
const startTimeField = await deliveryRecordTable.getField(DELIVERY_START_TIME_FIELD_ID); const startTimeField = await deliveryRecordTable.getField(DELIVERY_START_TIME_FIELD_ID);
const text2Field = await deliveryRecordTable.getField(DELIVERY_TEXT2_FIELD_ID);
// 使用传入的foreignId参数如果没有则使用sourceRecordId作为foreign_id // 使用传入的foreignId参数如果没有则使用sourceRecordId作为foreign_id
const actualForeignId = foreignId || sourceRecordId; const actualForeignId = foreignId || sourceRecordId;
@ -3207,6 +3236,10 @@ export default function App() {
const customerExpectedDateCell = customerExpectedDate ? await customerExpectedDateField.createCell(customerExpectedDate) : null; const customerExpectedDateCell = customerExpectedDate ? await customerExpectedDateField.createCell(customerExpectedDate) : null;
const nodeDetailsCell = processRecordIds.length > 0 ? await nodeDetailsField.createCell({ recordIds: processRecordIds }) : null; const nodeDetailsCell = processRecordIds.length > 0 ? await nodeDetailsField.createCell({ recordIds: processRecordIds }) : null;
const adjustmentInfoCell = adjustmentInfo ? await adjustmentInfoField.createCell(adjustmentInfo) : null; const adjustmentInfoCell = adjustmentInfo ? await adjustmentInfoField.createCell(adjustmentInfo) : null;
const text2Cell = text2Value && text2Value.trim() ? await text2Field.createCell(text2Value) : null;
console.log('文本2字段值:', text2Value);
console.log('文本2字段Cell创建结果:', !!text2Cell);
// 只有当数据存在时才添加对应的Cell // 只有当数据存在时才添加对应的Cell
console.log('uniqueLabelValues长度:', uniqueLabelValues.length); console.log('uniqueLabelValues长度:', uniqueLabelValues.length);
@ -3230,9 +3263,11 @@ export default function App() {
if (customerExpectedDateCell) recordCells.push(customerExpectedDateCell); if (customerExpectedDateCell) recordCells.push(customerExpectedDateCell);
if (nodeDetailsCell) recordCells.push(nodeDetailsCell); if (nodeDetailsCell) recordCells.push(nodeDetailsCell);
if (adjustmentInfoCell) recordCells.push(adjustmentInfoCell); if (adjustmentInfoCell) recordCells.push(adjustmentInfoCell);
if (text2Cell) recordCells.push(text2Cell);
console.log('准备写入的RecordCells数量:', recordCells.length); console.log('准备写入的RecordCells数量:', recordCells.length);
console.log('标签汇总字段Cell是否存在:', !!labelsCell); console.log('标签汇总字段Cell是否存在:', !!labelsCell);
console.log('文本2字段Cell是否存在:', !!text2Cell);
// 使用Cell数组格式添加记录与正常模式相同 // 使用Cell数组格式添加记录与正常模式相同
console.log('即将调用 deliveryRecordTable.addRecord...'); console.log('即将调用 deliveryRecordTable.addRecord...');
@ -3246,6 +3281,7 @@ export default function App() {
const writtenRecord = await deliveryRecordTable.getRecordById(addedRecord); const writtenRecord = await deliveryRecordTable.getRecordById(addedRecord);
console.log('写入后的记录验证:', writtenRecord); console.log('写入后的记录验证:', writtenRecord);
console.log('写入后的标签汇总字段:', writtenRecord.fields[DELIVERY_LABELS_FIELD_ID]); console.log('写入后的标签汇总字段:', writtenRecord.fields[DELIVERY_LABELS_FIELD_ID]);
console.log('写入后的文本2字段:', writtenRecord.fields[DELIVERY_TEXT2_FIELD_ID]);
// 检查标签汇总字段是否为空 // 检查标签汇总字段是否为空
const labelsFieldValue = writtenRecord.fields[DELIVERY_LABELS_FIELD_ID]; const labelsFieldValue = writtenRecord.fields[DELIVERY_LABELS_FIELD_ID];
@ -3256,6 +3292,18 @@ export default function App() {
} else { } else {
console.log('标签汇总字段写入成功,包含', Array.isArray(labelsFieldValue) ? labelsFieldValue.length : 1, '个值'); console.log('标签汇总字段写入成功,包含', Array.isArray(labelsFieldValue) ? labelsFieldValue.length : 1, '个值');
} }
// 检查文本2字段是否正确写入
const text2FieldValue = writtenRecord.fields[DELIVERY_TEXT2_FIELD_ID];
if (text2Value && text2Value.trim()) {
if (!text2FieldValue) {
console.error('警告文本2字段写入后为空');
console.error('原始数据:', text2Value);
console.error('字段ID:', DELIVERY_TEXT2_FIELD_ID);
} else {
console.log('文本2字段写入成功值为:', text2FieldValue);
}
}
} catch (verifyError) { } catch (verifyError) {
console.error('验证写入记录失败:', verifyError); console.error('验证写入记录失败:', verifyError);
} }