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_ROW_NUMBER_FIELD_ID = 'fldiqlTVsU';
|
||||||
const BATCH_LABEL11_FIELD_ID = 'fld4BZHtBV';
|
const BATCH_LABEL11_FIELD_ID = 'fld4BZHtBV';
|
||||||
const BATCH_LABEL12_FIELD_ID = 'fldnRlMeaD';
|
const BATCH_LABEL12_FIELD_ID = 'fldnRlMeaD';
|
||||||
|
const BATCH_BUFFER_FIELD_ID = 'fldLBXEAo0';
|
||||||
|
|
||||||
const activateTableForPaging = async (table: any) => {
|
const activateTableForPaging = async (table: any) => {
|
||||||
try {
|
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);
|
const nextAdjustments = remapTimelineAdjustmentsToNewResults(timelineResults, results);
|
||||||
setTimelineAdjustments(nextAdjustments);
|
setTimelineAdjustments(nextAdjustments);
|
||||||
pendingRecalculateAfterCalculateAdjustmentsRef.current = nextAdjustments;
|
pendingRecalculateAfterCalculateAdjustmentsRef.current = nextAdjustments;
|
||||||
@ -4090,6 +4098,20 @@ export default function App() {
|
|||||||
return adjusted;
|
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 = (
|
const computeAutoBufferDaysUsingExpectedDate = (
|
||||||
results: any[],
|
results: any[],
|
||||||
expectedDateOverride?: Date | null,
|
expectedDateOverride?: Date | null,
|
||||||
@ -5455,6 +5477,7 @@ export default function App() {
|
|||||||
const colorText = getText('colorText');
|
const colorText = getText('colorText');
|
||||||
const rawStart = f[nameToId.get('startTimestamp') || ''];
|
const rawStart = f[nameToId.get('startTimestamp') || ''];
|
||||||
const rawExpected = f[nameToId.get('expectedDateTimestamp') || ''];
|
const rawExpected = f[nameToId.get('expectedDateTimestamp') || ''];
|
||||||
|
const rawBufferDays = f[nameToId.get('缓冲期') || BATCH_BUFFER_FIELD_ID || ''];
|
||||||
let startDate: Date | null = null;
|
let startDate: Date | null = null;
|
||||||
let expectedDateObj: Date | null = null;
|
let expectedDateObj: Date | null = null;
|
||||||
if (typeof rawStart === 'number') startDate = new Date(rawStart);
|
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);
|
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 normalizeExcludedDates = (raw: any): string[] => {
|
||||||
const out: string[] = [];
|
const out: string[] = [];
|
||||||
const pushToken = (token: any) => {
|
const pushToken = (token: any) => {
|
||||||
@ -5565,6 +5610,16 @@ export default function App() {
|
|||||||
try {
|
try {
|
||||||
const results = await handleCalculateTimeline(true, { selectedLabels: labels, expectedDate: expectedDateObj || null, startTime: startDate || null, excludedDates: batchExcludedDates }, false);
|
const results = await handleCalculateTimeline(true, { selectedLabels: labels, expectedDate: expectedDateObj || null, startTime: startDate || null, excludedDates: batchExcludedDates }, false);
|
||||||
if (results && results.length > 0) {
|
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 processRecordIds = await writeToProcessDataTable(results, { foreignId, style: styleText, color: colorText });
|
||||||
const deliveryRecordId = await writeToDeliveryRecordTable(
|
const deliveryRecordId = await writeToDeliveryRecordTable(
|
||||||
results,
|
results,
|
||||||
@ -5574,7 +5629,7 @@ export default function App() {
|
|||||||
foreignId,
|
foreignId,
|
||||||
style: styleText,
|
style: styleText,
|
||||||
color: colorText,
|
color: colorText,
|
||||||
expectedDate: expectedDateObj || null,
|
expectedDate: effectiveExpectedDate,
|
||||||
startTime: startDate || null,
|
startTime: startDate || null,
|
||||||
selectedLabels: labels
|
selectedLabels: labels
|
||||||
}
|
}
|
||||||
@ -6947,14 +7002,6 @@ export default function App() {
|
|||||||
>
|
>
|
||||||
<span style={{ fontSize: 14, lineHeight: 1 }}>✏️</span>
|
<span style={{ fontSize: 14, lineHeight: 1 }}>✏️</span>
|
||||||
</Button>
|
</Button>
|
||||||
<>
|
|
||||||
<Text type="tertiary" style={{ marginLeft: 8 }}>锁交付</Text>
|
|
||||||
<Switch
|
|
||||||
checked={isExpectedDeliveryDateLocked}
|
|
||||||
onChange={handleExpectedDeliveryDateLockChange}
|
|
||||||
style={{ marginLeft: 4 }}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user