1
1
This commit is contained in:
44
src/App.tsx
44
src/App.tsx
@ -2712,6 +2712,50 @@ export default function App() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isBackward && mode === 'generate' && showUI && currentExpectedDate && !isNaN(currentExpectedDate.getTime()) && results.length > 0) {
|
||||
const findLastCompletionDate = (): Date | null => {
|
||||
for (let i = results.length - 1; i >= 0; i--) {
|
||||
const endStr = results[i]?.estimatedEnd;
|
||||
if (typeof endStr !== 'string' || endStr.trim() === '' || endStr.includes('未找到') || endStr.includes('时效值为0')) continue;
|
||||
const d = parseDate(endStr);
|
||||
if (d && !isNaN(d.getTime())) return d;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
const lastCompletionDate = findLastCompletionDate();
|
||||
if (lastCompletionDate) {
|
||||
const deliveryDate = new Date(lastCompletionDate);
|
||||
deliveryDate.setDate(deliveryDate.getDate() + Math.max(0, Math.ceil(baseBufferDays)));
|
||||
const increaseDays = differenceInCalendarDays(currentExpectedDate, deliveryDate);
|
||||
|
||||
if (increaseDays > 0) {
|
||||
const shouldApply = await new Promise<boolean>((resolve) => {
|
||||
Modal.confirm({
|
||||
title: '是否增加缓冲期使其一致?',
|
||||
content: `请业务确认:OMS 获取小ERP的预计交付日期。\n当前预计交付日期:${formatDate(deliveryDate, 'CHINESE_DATE')}\n客户期望日期:${formatDate(currentExpectedDate, 'CHINESE_DATE')}\n是否增加缓冲期 +${increaseDays} 天使其一致?`,
|
||||
okText: '确认增加',
|
||||
cancelText: '不调整',
|
||||
onOk: () => resolve(true),
|
||||
onCancel: () => resolve(false),
|
||||
});
|
||||
});
|
||||
|
||||
if (shouldApply) {
|
||||
setBaseBufferDays((prev) => Math.max(0, Math.ceil(prev) + increaseDays));
|
||||
setHasAppliedSuggestedBuffer(true);
|
||||
setLastSuggestedApplied(increaseDays);
|
||||
if (bitable.ui.showToast) {
|
||||
await bitable.ui.showToast({
|
||||
toastType: ToastType.success,
|
||||
message: `已自动增加缓冲期 +${increaseDays} 天,使预计交付日期对齐客户期望日期`,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setTimelineResults(results);
|
||||
if (showUI && !delayShowTimelineModal) {
|
||||
|
||||
Reference in New Issue
Block a user