6
6
This commit is contained in:
65
src/App.tsx
65
src/App.tsx
@ -403,6 +403,7 @@ export default function App() {
|
||||
const BATCH_ROW_NUMBER_FIELD_ID = 'fldiqlTVsU';
|
||||
const BATCH_LABEL11_FIELD_ID = 'fld4BZHtBV';
|
||||
const BATCH_LABEL12_FIELD_ID = 'fldnRlMeaD';
|
||||
const BATCH_BUFFER_FIELD_ID = 'fldLBXEAo0';
|
||||
|
||||
const activateTableForPaging = async (table: any) => {
|
||||
try {
|
||||
@ -3685,6 +3686,13 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!isBackward && showUI && mode === 'generate' && (!currentExpectedDate || isNaN(currentExpectedDate.getTime()))) {
|
||||
const autoExpected = computeExpectedDateByBufferDays(results, 14, completionDateAdjustment);
|
||||
if (autoExpected) {
|
||||
setExpectedDate(autoExpected);
|
||||
}
|
||||
}
|
||||
|
||||
const nextAdjustments = remapTimelineAdjustmentsToNewResults(timelineResults, results);
|
||||
setTimelineAdjustments(nextAdjustments);
|
||||
pendingRecalculateAfterCalculateAdjustmentsRef.current = nextAdjustments;
|
||||
@ -4090,6 +4098,20 @@ export default function App() {
|
||||
return adjusted;
|
||||
};
|
||||
|
||||
const computeExpectedDateByBufferDays = (
|
||||
results: any[],
|
||||
bufferDays: number,
|
||||
completionAdjustmentOverride?: number
|
||||
): Date | null => {
|
||||
if (timelineDirection === 'backward') return null;
|
||||
if (!Number.isFinite(bufferDays)) return null;
|
||||
const adjustedCompletionDate = getAdjustedLastCompletionDate(results, completionAdjustmentOverride);
|
||||
if (!adjustedCompletionDate) return null;
|
||||
const next = new Date(adjustedCompletionDate);
|
||||
next.setDate(next.getDate() + Math.round(bufferDays));
|
||||
return next;
|
||||
};
|
||||
|
||||
const computeAutoBufferDaysUsingExpectedDate = (
|
||||
results: any[],
|
||||
expectedDateOverride?: Date | null,
|
||||
@ -5455,6 +5477,7 @@ export default function App() {
|
||||
const colorText = getText('colorText');
|
||||
const rawStart = f[nameToId.get('startTimestamp') || ''];
|
||||
const rawExpected = f[nameToId.get('expectedDateTimestamp') || ''];
|
||||
const rawBufferDays = f[nameToId.get('缓冲期') || BATCH_BUFFER_FIELD_ID || ''];
|
||||
let startDate: Date | null = null;
|
||||
let expectedDateObj: Date | null = null;
|
||||
if (typeof rawStart === 'number') startDate = new Date(rawStart);
|
||||
@ -5478,6 +5501,28 @@ export default function App() {
|
||||
if (typeof v === 'number') expectedDateObj = new Date(v); else expectedDateObj = parseDate(v);
|
||||
}
|
||||
|
||||
const parseBufferDays = (raw: any): number | null => {
|
||||
if (raw == null) return null;
|
||||
if (typeof raw === 'number' && Number.isFinite(raw)) return raw;
|
||||
if (Array.isArray(raw) && raw.length > 0) {
|
||||
const item = raw[0];
|
||||
if (typeof item === 'number' && Number.isFinite(item)) return item;
|
||||
const text = extractText(item);
|
||||
const n = Number(text);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
if (typeof raw === 'string') {
|
||||
const n = Number(raw);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
if (raw && typeof raw === 'object') {
|
||||
const v = (raw as any).value || (raw as any).text || (raw as any).name || '';
|
||||
const n = Number(v);
|
||||
return Number.isFinite(n) ? n : null;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const normalizeExcludedDates = (raw: any): string[] => {
|
||||
const out: string[] = [];
|
||||
const pushToken = (token: any) => {
|
||||
@ -5565,6 +5610,16 @@ export default function App() {
|
||||
try {
|
||||
const results = await handleCalculateTimeline(true, { selectedLabels: labels, expectedDate: expectedDateObj || null, startTime: startDate || null, excludedDates: batchExcludedDates }, false);
|
||||
if (results && results.length > 0) {
|
||||
let effectiveExpectedDate = expectedDateObj || null;
|
||||
if (!effectiveExpectedDate) {
|
||||
const bufferDays = parseBufferDays(rawBufferDays);
|
||||
const fallbackDays = Number.isFinite(bufferDays as number) ? (bufferDays as number) : 14;
|
||||
const autoExpected = computeExpectedDateByBufferDays(results, fallbackDays, completionDateAdjustment);
|
||||
if (autoExpected) {
|
||||
effectiveExpectedDate = autoExpected;
|
||||
setExpectedDate(autoExpected);
|
||||
}
|
||||
}
|
||||
const processRecordIds = await writeToProcessDataTable(results, { foreignId, style: styleText, color: colorText });
|
||||
const deliveryRecordId = await writeToDeliveryRecordTable(
|
||||
results,
|
||||
@ -5574,7 +5629,7 @@ export default function App() {
|
||||
foreignId,
|
||||
style: styleText,
|
||||
color: colorText,
|
||||
expectedDate: expectedDateObj || null,
|
||||
expectedDate: effectiveExpectedDate,
|
||||
startTime: startDate || null,
|
||||
selectedLabels: labels
|
||||
}
|
||||
@ -6947,14 +7002,6 @@ export default function App() {
|
||||
>
|
||||
<span style={{ fontSize: 14, lineHeight: 1 }}>✏️</span>
|
||||
</Button>
|
||||
<>
|
||||
<Text type="tertiary" style={{ marginLeft: 8 }}>锁交付</Text>
|
||||
<Switch
|
||||
checked={isExpectedDeliveryDateLocked}
|
||||
onChange={handleExpectedDeliveryDateLockChange}
|
||||
style={{ marginLeft: 4 }}
|
||||
/>
|
||||
</>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user