From 2db8e39666af767d1e0a04298c6efebbd0a7847f Mon Sep 17 00:00:00 2001 From: WuYongJie Date: Tue, 18 Aug 2026 16:39:30 +0800 Subject: [PATCH] fix(oa): keep page module exports Next-compatible --- .../intake/oa-board/OaBoardPageContent.tsx | 167 ++++++++++++++++++ .../src/app/intake/oa-board/page.tsx | 160 +---------------- .../new-products/unified-table/page.tsx | 2 +- 3 files changed, 169 insertions(+), 160 deletions(-) create mode 100644 furniture-3d-system/src/app/intake/oa-board/OaBoardPageContent.tsx diff --git a/furniture-3d-system/src/app/intake/oa-board/OaBoardPageContent.tsx b/furniture-3d-system/src/app/intake/oa-board/OaBoardPageContent.tsx new file mode 100644 index 00000000..f0a8810d --- /dev/null +++ b/furniture-3d-system/src/app/intake/oa-board/OaBoardPageContent.tsx @@ -0,0 +1,167 @@ +import { requireSession } from '@/lib/server-session' +import { + createEmptyOaBoardDashboard, + createMockOaBoardDashboard, + oaBoardService, +} from '@/server/services/oa-board.service' +import { OA_BOARD_DEFAULT_TRACKED_STATUSES } from '@/server/services/oa-board.constants' +import { canViewOaBoardDailyReport } from '@/server/services/oa-board-daily-report-access' +import { readOaBoardLocalPreviewDashboard } from '@/server/services/oa-board-local-preview.service' +import { sampleProgressService } from '@/server/services/sample-progress.service' +import OaBoardClient from './OaBoardClient' + +export type OaBoardPageProps = { + searchParams?: Promise> +} + +type OaBoardPageContentProps = OaBoardPageProps & { + embeddedTab?: 'detail' + embeddedTitle?: string +} + +export async function OaBoardPageContent({ + searchParams, + embeddedTab, + embeddedTitle, +}: OaBoardPageContentProps) { + const allowLocalPreview = process.env.OA_BOARD_LOCAL_PREVIEW === '1' + const session = allowLocalPreview ? null : await requireSession('/login') + const canViewDailyReport = canViewOaBoardDailyReport(session?.authUser) + const params = searchParams ? await searchParams : {} + + const readSingleParam = (value: string | string[] | undefined) => + typeof value === 'string' ? value : '' + const readMultiParam = (value: string | string[] | undefined) => + (Array.isArray(value) ? value : [value]) + .flatMap((entry) => String(entry ?? '').split(',')) + .map((entry) => entry.trim()) + .filter(Boolean) + + const keyword = readSingleParam(params.keyword) + const approvalNumber = readSingleParam(params.approvalNumber) + const overallStatus = readMultiParam(params.overallStatus) + const createdDateStart = readSingleParam(params.createdDateStart) + const createdDateEnd = readSingleParam(params.createdDateEnd) + const productType = readSingleParam(params.productType) + const approvalStage = readSingleParam(params.approvalStage) + const developmentPlan = readSingleParam(params.developmentPlan) + const productPlanner = readSingleParam(params.productPlanner) + const structureDesigner = readSingleParam(params.structureDesigner) + const appearanceDesigner = readSingleParam(params.appearanceDesigner) + const purchaseOwner = readSingleParam(params.purchaseOwner) + const spuOwner = readSingleParam(params.spuOwner) + const owner = readSingleParam(params.owner) + const nodeName = readSingleParam(params.nodeName) + const timeoutOnly = params.timeoutOnly === '1' + const timeoutStatus = readSingleParam(params.timeoutStatus) + const reportDate = readSingleParam(params.reportDate) + const reportMonth = readSingleParam(params.reportMonth) + + const loadLiveDashboard = () => + oaBoardService.getDashboard( + { + keyword: keyword || undefined, + approvalNumber: approvalNumber || undefined, + overallStatus: + overallStatus.length > 0 + ? overallStatus + : [...OA_BOARD_DEFAULT_TRACKED_STATUSES], + createdDateStart: createdDateStart || undefined, + createdDateEnd: createdDateEnd || undefined, + productType: productType || undefined, + approvalStage: approvalStage || undefined, + developmentPlan: developmentPlan || undefined, + productPlanner: productPlanner || undefined, + structureDesigner: structureDesigner || undefined, + appearanceDesigner: appearanceDesigner || undefined, + purchaseOwner: purchaseOwner || undefined, + spuOwner: spuOwner || undefined, + owner: owner || undefined, + nodeName: nodeName || undefined, + timeoutOnly, + timeoutStatus: + timeoutStatus === 'YES' || timeoutStatus === 'NO' + ? timeoutStatus + : undefined, + }, + canViewDailyReport ? reportDate || undefined : undefined, + canViewDailyReport ? reportMonth || undefined : undefined, + canViewDailyReport, + ) + + const resolveDashboard = () => + loadLiveDashboard() + .then((dashboard) => ({ dashboard, loadErrorMessage: null as string | null })) + .catch((error) => { + const fallbackMessage = + error instanceof Error + ? `页面骨架已生成,但读取企划库流程数据失败:${error.message}` + : '页面骨架已生成,但读取企划库流程数据失败。' + + const useMockDashboard = + process.env.NODE_ENV !== 'production' || + process.env.OA_BOARD_LOCAL_PREVIEW === '1' + + return { + dashboard: useMockDashboard + ? createMockOaBoardDashboard() + : createEmptyOaBoardDashboard(), + loadErrorMessage: useMockDashboard + ? `${fallbackMessage} 当前已切换为本地人工验证数据,方便验证流程明细进度。` + : fallbackMessage, + } + }) + + const result = allowLocalPreview + ? await readOaBoardLocalPreviewDashboard() + .then((dashboard) => ({ dashboard, loadErrorMessage: null as string | null })) + .catch(resolveDashboard) + : await resolveDashboard() + + const pageStateKey = JSON.stringify({ + embeddedTab, + keyword, + approvalNumber, + overallStatus, + createdDateStart, + createdDateEnd, + productType, + approvalStage, + developmentPlan, + productPlanner, + structureDesigner, + appearanceDesigner, + purchaseOwner, + spuOwner, + owner, + nodeName, + timeoutOnly, + timeoutStatus, + reportDate: canViewDailyReport ? reportDate : '', + }) + const dashboard = canViewDailyReport + ? result.dashboard + : { ...result.dashboard, dailyReport: undefined } + if (!embeddedTab) { + await sampleProgressService.syncFromOaDashboard() + } + const sampleProgressItems = embeddedTab + ? [] + : await sampleProgressService.listStored() + const currentSampleStageOpeningCodes = embeddedTab + ? [] + : await sampleProgressService.listCurrentSampleStageOpeningCodes() + + return ( + + ) +} diff --git a/furniture-3d-system/src/app/intake/oa-board/page.tsx b/furniture-3d-system/src/app/intake/oa-board/page.tsx index 851b8929..8d26dbac 100644 --- a/furniture-3d-system/src/app/intake/oa-board/page.tsx +++ b/furniture-3d-system/src/app/intake/oa-board/page.tsx @@ -1,165 +1,7 @@ -import { requireSession } from '@/lib/server-session' -import { - createEmptyOaBoardDashboard, - createMockOaBoardDashboard, - oaBoardService, -} from '@/server/services/oa-board.service' -import { OA_BOARD_DEFAULT_TRACKED_STATUSES } from '@/server/services/oa-board.constants' -import { canViewOaBoardDailyReport } from '@/server/services/oa-board-daily-report-access' -import { readOaBoardLocalPreviewDashboard } from '@/server/services/oa-board-local-preview.service' -import OaBoardClient from './OaBoardClient' -import { sampleProgressService } from '@/server/services/sample-progress.service' +import { OaBoardPageContent, type OaBoardPageProps } from './OaBoardPageContent' export const dynamic = 'force-dynamic' -type OaBoardPageProps = { - searchParams?: Promise> -} - -type OaBoardPageContentProps = OaBoardPageProps & { - embeddedTab?: 'detail' - embeddedTitle?: string -} - -export async function OaBoardPageContent({ - searchParams, - embeddedTab, - embeddedTitle, -}: OaBoardPageContentProps) { - const allowLocalPreview = process.env.OA_BOARD_LOCAL_PREVIEW === '1' - const session = allowLocalPreview ? null : await requireSession('/login') - const canViewDailyReport = canViewOaBoardDailyReport(session?.authUser) - const params = searchParams ? await searchParams : {} - - const readSingleParam = (value: string | string[] | undefined) => - typeof value === 'string' ? value : '' - const readMultiParam = (value: string | string[] | undefined) => - (Array.isArray(value) ? value : [value]) - .flatMap((entry) => String(entry ?? '').split(',')) - .map((entry) => entry.trim()) - .filter(Boolean) - - const keyword = readSingleParam(params.keyword) - const approvalNumber = readSingleParam(params.approvalNumber) - const overallStatus = readMultiParam(params.overallStatus) - const createdDateStart = readSingleParam(params.createdDateStart) - const createdDateEnd = readSingleParam(params.createdDateEnd) - const productType = readSingleParam(params.productType) - const approvalStage = readSingleParam(params.approvalStage) - const developmentPlan = readSingleParam(params.developmentPlan) - const productPlanner = readSingleParam(params.productPlanner) - const structureDesigner = readSingleParam(params.structureDesigner) - const appearanceDesigner = readSingleParam(params.appearanceDesigner) - const purchaseOwner = readSingleParam(params.purchaseOwner) - const spuOwner = readSingleParam(params.spuOwner) - const owner = readSingleParam(params.owner) - const nodeName = readSingleParam(params.nodeName) - const timeoutOnly = params.timeoutOnly === '1' - const timeoutStatus = readSingleParam(params.timeoutStatus) - const reportDate = readSingleParam(params.reportDate) - const reportMonth = readSingleParam(params.reportMonth) - - const loadLiveDashboard = () => - oaBoardService.getDashboard( - { - keyword: keyword || undefined, - approvalNumber: approvalNumber || undefined, - overallStatus: - overallStatus.length > 0 - ? overallStatus - : [...OA_BOARD_DEFAULT_TRACKED_STATUSES], - createdDateStart: createdDateStart || undefined, - createdDateEnd: createdDateEnd || undefined, - productType: productType || undefined, - approvalStage: approvalStage || undefined, - developmentPlan: developmentPlan || undefined, - productPlanner: productPlanner || undefined, - structureDesigner: structureDesigner || undefined, - appearanceDesigner: appearanceDesigner || undefined, - purchaseOwner: purchaseOwner || undefined, - spuOwner: spuOwner || undefined, - owner: owner || undefined, - nodeName: nodeName || undefined, - timeoutOnly, - timeoutStatus: timeoutStatus === 'YES' || timeoutStatus === 'NO' ? timeoutStatus : undefined, - }, - canViewDailyReport ? reportDate || undefined : undefined, - canViewDailyReport ? reportMonth || undefined : undefined, - canViewDailyReport, - ) - - const resolveDashboard = () => - loadLiveDashboard() - .then((dashboard) => ({ dashboard, loadErrorMessage: null as string | null })) - .catch((error) => { - const fallbackMessage = - error instanceof Error - ? `页面骨架已生成,但读取企划库流程数据失败:${error.message}` - : '页面骨架已生成,但读取企划库流程数据失败。' - - const useMockDashboard = - process.env.NODE_ENV !== 'production' || process.env.OA_BOARD_LOCAL_PREVIEW === '1' - - return { - dashboard: useMockDashboard ? createMockOaBoardDashboard() : createEmptyOaBoardDashboard(), - loadErrorMessage: useMockDashboard - ? `${fallbackMessage} 当前已切换为本地人工验证数据,方便验证流程明细进度。` - : fallbackMessage, - } - }) - - const result = allowLocalPreview - ? await readOaBoardLocalPreviewDashboard() - .then((dashboard) => ({ dashboard, loadErrorMessage: null as string | null })) - .catch(resolveDashboard) - : await resolveDashboard() - - const pageStateKey = JSON.stringify({ - embeddedTab, - keyword, - approvalNumber, - overallStatus, - createdDateStart, - createdDateEnd, - productType, - approvalStage, - developmentPlan, - productPlanner, - structureDesigner, - appearanceDesigner, - purchaseOwner, - spuOwner, - owner, - nodeName, - timeoutOnly, - timeoutStatus, - reportDate: canViewDailyReport ? reportDate : '', - }) - const dashboard = canViewDailyReport - ? result.dashboard - : { ...result.dashboard, dailyReport: undefined } - if (!embeddedTab) { - await sampleProgressService.syncFromOaDashboard() - } - const sampleProgressItems = embeddedTab ? [] : await sampleProgressService.listStored() - const currentSampleStageOpeningCodes = embeddedTab - ? [] - : await sampleProgressService.listCurrentSampleStageOpeningCodes() - - return ( - - ) -} - export default async function OaBoardPage(props: OaBoardPageProps) { return OaBoardPageContent(props) } diff --git a/furniture-3d-system/src/app/supply-chain/new-products/unified-table/page.tsx b/furniture-3d-system/src/app/supply-chain/new-products/unified-table/page.tsx index ba3201b1..f6731e10 100644 --- a/furniture-3d-system/src/app/supply-chain/new-products/unified-table/page.tsx +++ b/furniture-3d-system/src/app/supply-chain/new-products/unified-table/page.tsx @@ -1,5 +1,5 @@ import { redirect } from 'next/navigation' -import { OaBoardPageContent } from '@/app/intake/oa-board/page' +import { OaBoardPageContent } from '@/app/intake/oa-board/OaBoardPageContent' import { requireSession } from '@/lib/server-session' import { supplyChainPermissionSettingsService } from '@/server/services/supply-chain-permission-settings.service'