feat(workbench): 拆分数据库与预估成本测算入口并共享页签

(cherry picked from commit d1c2584edee2ee57430a3f7310aa510ba489b785)
This commit is contained in:
WuYongJie 2026-11-24 15:53:15 +08:00
parent 8176184726
commit a8c2a6735b
129 changed files with 553 additions and 1080 deletions

View File

@ -0,0 +1,32 @@
import type { ComponentProps } from 'react'
import { assetCenterService } from '@/server/services/asset-center.service'
import { materialService } from '@/server/services/material.service'
import { BomLibraryDomain, type BomLibraryKey } from './bom-library/BomLibraryDomain'
export async function BomDatabaseWorkspace({
library, user, canEdit,
}: {
library: BomLibraryKey
user: ComponentProps<typeof BomLibraryDomain>['user']
canEdit: boolean
}) {
const usesMaterialCatalog = library === 'materialLibrary' || library === 'finishLibrary'
const [substrates, finishes, categories, dictionaries] = await Promise.all([
usesMaterialCatalog ? assetCenterService.listSubstrates() : [],
usesMaterialCatalog ? materialService.findAll({ limit: 500 }) : [],
usesMaterialCatalog ? materialService.findAllCategories() : [],
usesMaterialCatalog ? assetCenterService.getSubstrateDictionaryBundle() : undefined,
])
return (
<BomLibraryDomain
user={user}
activeBomLibrary={library}
canEditLibraries={canEdit}
materialLibrarySubstrates={substrates}
materialLibraryFinishes={finishes}
materialLibraryCategories={categories}
materialLibraryDictionaries={dictionaries}
/>
)
}

View File

@ -0,0 +1,42 @@
import { notFound, redirect } from 'next/navigation'
import { DATABASE_LIBRARIES } from '@/config/intake-library-navigation'
import { getIntakeLibraryAccess } from '@/lib/intake-library-access'
import { requireSession } from '@/lib/server-session'
import { intakeNodePermissionSettingsService } from '@/server/services/intake-node-permission-settings.service'
import { BomDatabaseWorkspace } from '../BomDatabaseWorkspace'
import { RawMaterialLibraryDomain } from '../raw-material-library/RawMaterialLibraryDomain'
type DatabasePageProps = {
params: Promise<{ library: string }>
searchParams: Promise<{ material?: string | string[] }>
}
export async function generateMetadata({ params }: DatabasePageProps) {
const { library } = await params
return { title: DATABASE_LIBRARIES.find((item) => item.slug === library)?.label ?? '数据库' }
}
export default async function DatabaseLibraryPage({ params, searchParams }: DatabasePageProps) {
const { library: slug } = await params
const library = DATABASE_LIBRARIES.find((item) => item.slug === slug)
if (!library) notFound()
const { user, authUser } = await requireSession()
const { overrides } = await intakeNodePermissionSettingsService.getSettings()
const access = getIntakeLibraryAccess(authUser, overrides, library.targetKey)
if (!access.canView) redirect('/intake')
const { material } = await searchParams
return (
<section aria-label={library.label} className="h-full min-h-0 p-3 md:p-4">
{library.targetKey === 'bomLibrary' ? (
<BomDatabaseWorkspace library={library.key} user={user} canEdit={access.canEdit} />
) : (
<RawMaterialLibraryDomain
activeRawMaterialLibrary={library.key}
selectedMaterialName={typeof material === 'string' ? material : undefined}
/>
)}
</section>
)
}

View File

@ -1,7 +1,7 @@
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import AccessoryLibraryPanel from '@/app/intake/bom-library/AccessoryLibraryPanel'
import PackagingMaterialLibraryPanel from '@/app/intake/bom-library/PackagingMaterialLibraryPanel'
import AccessoryLibraryPanel from '@/app/database/bom-library/AccessoryLibraryPanel'
import PackagingMaterialLibraryPanel from '@/app/database/bom-library/PackagingMaterialLibraryPanel'
const LEGACY_PACKAGING_MATERIAL_LIBRARY_STORAGE_KEY =
'formal-intake-packaging-material-library-items'

View File

@ -36,7 +36,7 @@ type BomLibraryDomainProps = {
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
materialLibraryDictionaries?: SubstrateDictionaryBundleDTO;
onMaterialLibraryFinishesChange?: (finishes: MaterialDTO[]) => void;
};
@ -57,6 +57,9 @@ export function BomLibraryDomain({
isIntakeNonIntegratedDesignDepartmentUser(user));
if (activeBomLibrary === "materialLibrary" || activeBomLibrary === "finishLibrary") {
if (!materialLibraryDictionaries) {
throw new Error("板材与花色资料需要基础字典");
}
const visibleTab = activeBomLibrary === "materialLibrary" ? "substrate" : "finish";
return (
<div className="flex h-full min-h-0 flex-col overflow-hidden rounded-apple-xl border border-apple-separator bg-apple-bg-primary shadow-apple-xs">

View File

@ -1,6 +1,6 @@
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import EdgeBandingLibraryPanel from '@/app/intake/bom-library/EdgeBandingLibraryPanel'
import EdgeBandingLibraryPanel from '@/app/database/bom-library/EdgeBandingLibraryPanel'
import { createEdgeBandingLibraryItem } from '@/lib/edge-banding-library'
const LEGACY_EDGE_BANDING_LIBRARY_STORAGE_KEY =

View File

@ -1,13 +1,15 @@
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import type { BomLibraryKey } from "@/app/database/bom-library/BomLibraryDomain";
export const BOM_LIBRARY_OPTIONS: {
key: BomLibraryKey;
slug: string;
label: string;
description: string;
helper: string;
}[] = [
{
key: "materialLibrary",
slug: "boards",
label: "板材资料库",
description:
"只展示板材基材,方便在产品资料 BOM 下维护板材本体资料。",
@ -16,6 +18,7 @@ export const BOM_LIBRARY_OPTIONS: {
},
{
key: "finishLibrary",
slug: "finishes",
label: "花色资料库",
description:
"只展示饰面花色,方便在产品资料 BOM 下维护花色、贴图和参数。",
@ -24,6 +27,7 @@ export const BOM_LIBRARY_OPTIONS: {
},
{
key: "edgeBandingLibrary",
slug: "edge-banding",
label: "封边资料库",
description:
"按板材厚度维护封边条,细节资料里的封边自动项会按对应厚度筛选并带出单价。",
@ -32,6 +36,7 @@ export const BOM_LIBRARY_OPTIONS: {
},
{
key: "steelFrameLibrary",
slug: "steel-frames",
label: "钢架资料库",
description:
"不再预置系统钢架规格,只保留每吨钢价与人工新建规格,系统会自动重算重量、支数和每米单价。",
@ -40,6 +45,7 @@ export const BOM_LIBRARY_OPTIONS: {
},
{
key: "packagingLibrary",
slug: "accessories",
label: "配件资料库",
description:
"产品资料下独立维护的配件资料区,按新的业务口径重新配置,不复用原包材资料逻辑。",
@ -47,6 +53,7 @@ export const BOM_LIBRARY_OPTIONS: {
},
{
key: "packagingMaterialLibrary",
slug: "packaging-materials",
label: "包材资料库",
description:
"产品资料下独立维护的包材资料区,沿用和配件资料库相同的字母分组逻辑,但单独保存数据。",

View File

@ -1,7 +1,7 @@
"use client";
import type { IntakeWorkspaceTab } from "@/app/intake/intakeWorkspaceTypes";
import { RawMaterialLibraryDomain } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import { RawMaterialLibraryDomain } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
type RawMaterialLibraryWorkspaceTab = Extract<
IntakeWorkspaceTab,

View File

@ -1,17 +1,20 @@
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
export const RAW_MATERIAL_LIBRARY_OPTIONS: {
key: RawMaterialLibraryKey;
slug: string;
label: string;
description: string;
}[] = [
{
key: "processConfig",
slug: "material-processes",
label: "材质工艺配置",
description: "表格类信息和工艺规则占位",
},
{
key: "detailArchive",
slug: "material-archive",
label: "材质详情档案",
description: "材质百科式详情页占位",
},

View File

@ -3,10 +3,6 @@
import { type ReactNode } from "react";
import { BarcodePrintWorkspace } from "@/app/intake/barcode-print/BarcodePrintWorkspace";
import { BrandFilingWorkspace } from "@/app/intake/brand-filing/BrandFilingWorkspace";
import {
BomLibraryWorkspaceContent,
isBomLibraryWorkspaceTab,
} from "@/app/intake/bom-library/BomLibraryWorkspaceContent";
import type {
IntakeEntryTab,
IntakeWorkspaceTab,
@ -32,11 +28,7 @@ import {
import {
isRawMaterialLibraryWorkspaceTab,
RawMaterialLibraryWorkspaceContent,
} from "@/app/intake/raw-material-library/RawMaterialLibraryWorkspaceContent";
import {
isReferenceEstimatorWorkspaceTab,
ReferenceEstimatorWorkspaceContent,
} from "@/app/intake/reference-estimator/ReferenceEstimatorWorkspaceContent";
} from "@/app/database/raw-material-library/RawMaterialLibraryWorkspaceContent";
import { WorkRecordWorkspace } from "@/app/intake/work-record/WorkRecordWorkspace";
import { WorkRecordMonthlyArchiveWorkspace } from "@/app/intake/work-record/WorkRecordMonthlyArchiveWorkspace";
import { WorkRecordMonthlyArchiveDetailWorkspace } from "@/app/intake/work-record/WorkRecordMonthlyArchiveDetailWorkspace";
@ -47,10 +39,7 @@ import {
canManageWorkRecordScores,
} from "@/app/intake/work-record/workRecordPermissions";
import type {
MaterialCategoryDTO,
MaterialDTO,
SubstrateDictionaryBundleDTO,
SubstrateDTO,
} from "@/server/services";
type IntakeWorkspaceUser = {
@ -69,7 +58,6 @@ type IntakeActiveWorkspaceContentProps = {
fallback: ReactNode;
currentUser: IntakeWorkspaceUser;
canManageSpuRuleLibrary: boolean;
canEditBomLibrary: boolean;
canViewWorkRecordArchives: boolean;
canEditWorkRecordArchives: boolean;
canDownloadWorkRecordArchives: boolean;
@ -83,10 +71,7 @@ type IntakeActiveWorkspaceContentProps = {
existingSeriesNames: string[];
existingSeriesComponentDetailNames: string[];
seriesDraftSkuOptions: WorkbenchSku[];
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
selectedRawMaterialName?: string;
nonIntegratedProducts: NonIntegratedProductRecord[];
productDevelopmentProgressProducts: NonIntegratedProductRecord[];
@ -106,7 +91,6 @@ type IntakeActiveWorkspaceContentProps = {
entryTabOverride?: IntakeEntryTab,
) => void;
onCloseNewProductWorkspace: (tabId: string) => void;
onMaterialLibraryFinishesChange: (finishes: MaterialDTO[]) => void;
onOpenWorkRecordArchiveDetailWorkspace: (monthKey: string, label?: string) => void;
};
@ -115,7 +99,6 @@ export function IntakeActiveWorkspaceContent({
fallback,
currentUser,
canManageSpuRuleLibrary,
canEditBomLibrary,
canViewWorkRecordArchives,
canEditWorkRecordArchives,
canDownloadWorkRecordArchives,
@ -129,10 +112,7 @@ export function IntakeActiveWorkspaceContent({
existingSeriesNames,
existingSeriesComponentDetailNames,
seriesDraftSkuOptions,
materialLibrarySubstrates,
materialLibraryFinishes,
materialLibraryCategories,
materialLibraryDictionaries,
selectedRawMaterialName,
nonIntegratedProducts,
productDevelopmentProgressProducts,
@ -144,7 +124,6 @@ export function IntakeActiveWorkspaceContent({
onOpenRawMaterialProcessConfig,
onActivatePendingEntryListWorkspace,
onCloseNewProductWorkspace,
onMaterialLibraryFinishesChange,
onOpenWorkRecordArchiveDetailWorkspace,
}: IntakeActiveWorkspaceContentProps) {
if (!activeWorkspaceTab) return <>{fallback}</>;
@ -180,21 +159,6 @@ export function IntakeActiveWorkspaceContent({
);
}
if (isBomLibraryWorkspaceTab(activeWorkspaceTab)) {
return (
<BomLibraryWorkspaceContent
activeWorkspaceTab={activeWorkspaceTab}
currentUser={currentUser}
canEditBomLibrary={canEditBomLibrary}
materialLibrarySubstrates={materialLibrarySubstrates}
materialLibraryFinishes={materialLibraryFinishes}
materialLibraryCategories={materialLibraryCategories}
materialLibraryDictionaries={materialLibraryDictionaries}
onMaterialLibraryFinishesChange={onMaterialLibraryFinishesChange}
/>
);
}
if (isRawMaterialLibraryWorkspaceTab(activeWorkspaceTab)) {
return (
<RawMaterialLibraryWorkspaceContent
@ -204,16 +168,6 @@ export function IntakeActiveWorkspaceContent({
);
}
if (isReferenceEstimatorWorkspaceTab(activeWorkspaceTab)) {
return (
<ReferenceEstimatorWorkspaceContent
activeWorkspaceTab={activeWorkspaceTab}
materialLibrarySubstrates={materialLibrarySubstrates}
userId={currentUser.id}
/>
);
}
if (isProductPatentWorkspaceTab(activeWorkspaceTab)) {
return (
<ProductPatentWorkspaceContent

View File

@ -28,6 +28,7 @@ import {
const push = jest.fn()
jest.mock('next/navigation', () => ({
usePathname: () => '/intake',
useRouter: () => ({ push }),
}))
@ -93,32 +94,6 @@ jest.mock('@/components/platform/AccordionSection', () => ({
),
}))
jest.mock('@/app/asset-center/material-library/MaterialLibraryClient', () => ({
__esModule: true,
default: ({
initialActiveTab,
visibleTabs,
canEditOverride,
}: {
initialActiveTab?: string
visibleTabs?: string[]
canEditOverride?: boolean
}) => (
<div>
material-library-copy
<span data-testid="material-library-active-tab">
{initialActiveTab ?? 'finish'}
</span>
<span data-testid="material-library-visible-tabs">
{(visibleTabs ?? []).join(',')}
</span>
<span data-testid="material-library-can-edit">
{String(canEditOverride)}
</span>
</div>
),
}))
jest.mock('./non-integrated/NonIntegratedDetailClient', () => ({
__esModule: true,
default: ({
@ -284,15 +259,13 @@ function renderSelector(props?: {
initialActiveSection?:
| 'pending'
| 'progress'
| 'bom'
| 'rawMaterialLibrary'
| 'referenceEstimator'
| 'patents'
| null
initialActiveRawMaterialLibrary?: 'processConfig' | 'detailArchive'
initialRawMaterialName?: string
initialNodePermissionOverrides?: IntakeNodePermissionOverrideMap
materialLibrarySubstrates?: Array<Record<string, unknown>>
initialSeriesNameOptions?: string[]
initialOpenProductWorkspace?: {
product: Record<string, unknown>
@ -342,22 +315,13 @@ function renderSelector(props?: {
eligibleSkuList={props?.eligibleSkuList as never}
draftGroupId={null}
hasIneligibleSelected={false}
materialLibrarySubstrates={
(props?.materialLibrarySubstrates as never) ?? []
}
materialLibraryFinishes={[] as never}
materialLibraryCategories={[] as never}
materialLibraryDictionaries={
{
categories: [],
environmentGrades: [],
thicknessSpecs: [],
surfaceOptions: [],
} as never
}
initialNonIntegratedProducts={
(props?.initialNonIntegratedProducts as never) ?? []
}
initialProductDevelopmentProgressProducts={
(props?.initialNonIntegratedProducts as never) ?? []
}
initialActiveSection={props?.initialActiveSection}
initialActiveRawMaterialLibrary={props?.initialActiveRawMaterialLibrary}
initialRawMaterialName={props?.initialRawMaterialName}
@ -387,18 +351,9 @@ function renderSelectorWithInitialCreateWorkspace() {
eligibleSkuList={[] as never}
draftGroupId={null}
hasIneligibleSelected={false}
materialLibrarySubstrates={[] as never}
materialLibraryFinishes={[] as never}
materialLibraryCategories={[] as never}
materialLibraryDictionaries={
{
categories: [],
environmentGrades: [],
thicknessSpecs: [],
surfaceOptions: [],
} as never
}
initialNonIntegratedProducts={[] as never}
initialProductDevelopmentProgressProducts={[]}
initialOpenNewNonIntegratedProduct
/>,
)
@ -449,18 +404,9 @@ function renderEditor() {
locations={[] as never}
categories={[] as never}
defaultAttachProductId={null}
materialLibrarySubstrates={[] as never}
materialLibraryFinishes={[] as never}
materialLibraryCategories={[] as never}
materialLibraryDictionaries={
{
categories: [],
environmentGrades: [],
thicknessSpecs: [],
surfaceOptions: [],
} as never
}
initialNonIntegratedProducts={[] as never}
initialProductDevelopmentProgressProducts={[]}
/>,
)
}
@ -587,30 +533,6 @@ function createApprovedWorkflowStateBefore(targetCategory: string) {
}
}
function mockFileReaderDataUrl(
resultDataUrl = 'data:image/png;base64,reference-image',
) {
class MockFileReader {
result = resultDataUrl
onload: (() => void) | null = null
readAsDataURL() {
this.onload?.()
}
}
Object.defineProperty(globalThis, 'FileReader', {
configurable: true,
writable: true,
value: MockFileReader,
})
Object.defineProperty(window, 'FileReader', {
configurable: true,
writable: true,
value: MockFileReader,
})
}
describe('IntakeClient', () => {
beforeEach(() => {
cleanup()
@ -638,18 +560,7 @@ describe('IntakeClient', () => {
const rightPanel = screen.getByTestId('right-panel')
expect(within(rightPanel).getByRole('button', { name: '产品开发' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: /产品开发进度/ })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: 'BOM资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '原材料资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '板材资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '花色资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '钢架资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '配件资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '包材资料库' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '材质工艺配置' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '材质详情档案' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '预估成本测算' })).toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: '预估成本测算' }))
expect(within(rightPanel).getByRole('button', { name: '参考图预估成本' })).toBeInTheDocument()
expect(within(rightPanel).queryByRole('button', { name: /^(BOM资料库|原材料资料库|预估成本测算)$/ })).not.toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '产品专利' })).toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: '产品专利' }))
expect(within(rightPanel).getByRole('button', { name: '产品专利明细' })).toBeInTheDocument()
@ -1802,65 +1713,6 @@ describe('IntakeClient', () => {
expect(within(leftPanel).queryByText('GBGJ-SZ0230')).not.toBeInTheDocument()
})
it('splits board and finish material libraries while keeping packaging library config', async () => {
const actor = userEvent.setup()
renderSelector({ eligibleSkuList: [] })
const rightPanel = screen.getByTestId('right-panel')
await actor.click(within(rightPanel).getByRole('button', { name: 'BOM资料库' }))
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-active-tab')).toHaveTextContent('substrate')
expect(screen.getByTestId('material-library-visible-tabs')).toHaveTextContent('substrate')
await actor.click(within(rightPanel).getByRole('button', { name: '花色资料库' }))
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-active-tab')).toHaveTextContent('finish')
expect(screen.getByTestId('material-library-visible-tabs')).toHaveTextContent('finish')
await actor.click(within(rightPanel).getByRole('button', { name: '包材资料库' }))
expect(screen.getByLabelText('包材编号')).toBeInTheDocument()
expect(screen.getByLabelText('包材名称')).toBeInTheDocument()
expect(screen.getByRole('button', { name: '查询' })).toBeInTheDocument()
})
it('opens raw material library entries as workspace tabs', async () => {
const actor = userEvent.setup()
renderSelector({ eligibleSkuList: [] })
const rightPanel = screen.getByTestId('right-panel')
await actor.click(
within(rightPanel).getByRole('button', { name: '原材料资料库' }),
)
await actor.click(within(rightPanel).getByRole('button', { name: '材质工艺配置' }))
expect(screen.getByRole('tab', { name: '材质工艺配置' })).toHaveAttribute(
'aria-selected',
'true',
)
const leftPanel = screen.getByTestId('left-panel')
expect(
within(leftPanel).getByRole('heading', { name: '材质工艺配置' }),
).toBeInTheDocument()
expect(within(leftPanel).getByText('主流木材等级')).toBeInTheDocument()
expect(within(leftPanel).getByText('生长树龄')).toBeInTheDocument()
expect(within(leftPanel).getByText('图片占位')).toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: '材质详情档案' }))
expect(screen.getByRole('tab', { name: '材质详情档案' })).toHaveAttribute(
'aria-selected',
'true',
)
expect(within(leftPanel).getByText('材质名称列表')).toBeInTheDocument()
expect(within(leftPanel).getByText(/材质详情档案占位已预留/)).toBeInTheDocument()
})
it('opens raw material process config with the material name from query state', () => {
renderSelector({
eligibleSkuList: [],
@ -1904,201 +1756,6 @@ describe('IntakeClient', () => {
expect(within(leftPanel).getByText('后续这里会按该材质定位工艺资料。')).toBeInTheDocument()
})
it('estimates board material cost from reference image recognition', async () => {
const actor = userEvent.setup()
const referenceImageEstimatePayload = {
success: true,
data: {
boardPieces: [
{ label: '柜体侧板', lengthMm: 1060, widthMm: 240, quantity: 2 },
{ label: '层板/顶底板', lengthMm: 730, widthMm: 240, quantity: 4 },
{ label: '前后拉板', lengthMm: 730, widthMm: 50, quantity: 2 },
{ label: '三合板背板', lengthMm: 1060, widthMm: 830, quantity: 1 },
],
hardwareItems: [{ id: 'wrench', name: '扳手', quantity: 1 }],
summary: '图片识别完成',
},
}
let resolveReferenceImageEstimateJson:
| ((value: typeof referenceImageEstimatePayload) => void)
| null = null
const referenceImageEstimateJson = jest.fn(
() =>
new Promise<typeof referenceImageEstimatePayload>((resolve) => {
resolveReferenceImageEstimateJson = resolve
}),
)
const fetchMock = jest.fn().mockResolvedValue({
ok: true,
json: referenceImageEstimateJson,
} as Response)
Object.defineProperty(global, 'fetch', {
value: fetchMock,
configurable: true,
writable: true,
})
mockFileReaderDataUrl()
renderSelector({
eligibleSkuList: [],
materialLibrarySubstrates: [
{
id: 'substrate-1',
code: 'BC-0001',
name: '15密度板',
description: null,
systemNameOptionId: null,
systemNameOptionName: null,
categoryId: 'category-density',
categoryName: '密度板',
environmentGradeId: 'env-enf',
environmentGradeName: 'ENF',
thicknessSpecId: 'thickness-15',
thicknessSpecName: '15mm',
thicknessMm: 15,
sheetLengthMm: 1000,
sheetWidthMm: 1000,
surfaceOptionId: 'surface-double',
surfaceOptionName: '双贴',
suggestedPrice: 100,
weightKg: 20,
finishes: [{ id: 'finish-black', name: '炭黑色' }],
metadata: { systemName: '15密度板' },
isActive: true,
createdAt: new Date('2026-04-29T00:00:00.000Z'),
updatedAt: new Date('2026-04-29T00:00:00.000Z'),
},
{
id: 'substrate-plywood',
code: 'BC-0002',
name: '三合板',
description: null,
systemNameOptionId: null,
systemNameOptionName: null,
categoryId: 'category-plywood',
categoryName: '三合板',
environmentGradeId: 'env-enf',
environmentGradeName: 'ENF',
thicknessSpecId: 'thickness-3',
thicknessSpecName: '3mm',
thicknessMm: 3,
sheetLengthMm: 1000,
sheetWidthMm: 1000,
surfaceOptionId: 'surface-double',
surfaceOptionName: '双贴',
suggestedPrice: 60,
weightKg: 8,
finishes: [{ id: 'finish-black', name: '炭黑色' }],
metadata: { systemName: '三合板' },
isActive: true,
createdAt: new Date('2026-04-29T00:00:00.000Z'),
updatedAt: new Date('2026-04-29T00:00:00.000Z'),
},
],
})
const rightPanel = screen.getByTestId('right-panel')
expect(
within(rightPanel).getByRole('button', { name: '预估成本测算' }),
).toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: '预估成本测算' }))
await actor.click(
within(rightPanel).getByRole('button', { name: '参考图预估成本' }),
)
expect(screen.getByRole('tab', { name: '参考图预估成本' })).toHaveAttribute(
'aria-selected',
'true',
)
expect(screen.getByRole('heading', { name: '参考图预估成本' })).toBeInTheDocument()
await actor.type(
screen.getByLabelText('图片补充'),
'高106 宽83 深24,15mm侧板,4层',
)
await actor.upload(
screen.getByLabelText('上传参考图'),
new File(['reference-image'], 'cabinet.png', { type: 'image/png' }),
)
await waitFor(
() => {
expect(fetchMock).toHaveBeenCalledWith(
'/api/intake/reference-image-estimate',
expect.objectContaining({ method: 'POST' }),
)
},
{ timeout: 5000 },
)
await waitFor(() => {
expect(referenceImageEstimateJson).toHaveBeenCalled()
})
await act(async () => {
resolveReferenceImageEstimateJson?.(referenceImageEstimatePayload)
await Promise.resolve()
await Promise.resolve()
})
expect(fetchMock).toHaveBeenCalledTimes(1)
await waitFor(
() => {
expect(screen.queryByText('图片识别中...')).not.toBeInTheDocument()
},
{ timeout: 5000 },
)
expect(screen.getByRole('heading', { name: '样包模板明细' })).toBeInTheDocument()
expect(screen.getByText('分类')).toBeInTheDocument()
expect(screen.getByText('封边米数')).toBeInTheDocument()
expect(
await screen.findByText('图片识别:柜体侧板', undefined, {
timeout: 5000,
}),
).toBeInTheDocument()
expect(screen.getByText('图片识别:层板/顶底板')).toBeInTheDocument()
expect(screen.getByText('图片识别:前后拉板')).toBeInTheDocument()
expect(screen.getByText('图片识别:三合板背板')).toBeInTheDocument()
expect(screen.getAllByText('1060').length).toBeGreaterThanOrEqual(1)
expect(screen.getAllByText('800').length).toBeGreaterThanOrEqual(1)
expect(screen.getAllByText('810').length).toBeGreaterThanOrEqual(1)
expect(screen.getAllByText('260').length).toBeGreaterThanOrEqual(1)
expect(screen.getAllByText('15密度板 炭黑色 双贴').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('同色的三合板')).toBeInTheDocument()
expect(screen.getByText('封边+胶水')).toBeInTheDocument()
expect(screen.getByLabelText('板材厚度')).toBeInTheDocument()
expect(screen.getByLabelText('大板价格')).toBeInTheDocument()
expect(screen.getByLabelText('系数')).toHaveValue('1.05')
expect(screen.queryByLabelText('五金参考')).not.toBeInTheDocument()
expect(screen.getAllByText('五金').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('偏心杆+偏心轮')).toBeInTheDocument()
expect(screen.getByText('半铁层板托')).toBeInTheDocument()
expect(screen.getByText('5*40自攻丝')).toBeInTheDocument()
expect(screen.getByText('扳手')).toBeInTheDocument()
expect(screen.getAllByText('包材').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('外箱纸箱')).toBeInTheDocument()
expect(screen.getByText('PE防尘袋')).toBeInTheDocument()
expect(screen.getByText('1120')).toBeInTheDocument()
expect(screen.getByText('320')).toBeInTheDocument()
expect(screen.getByText(/箱高约182mm/)).toBeInTheDocument()
expect(screen.getAllByText('配件').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('说明书')).toBeInTheDocument()
expect(screen.getAllByText('小计').length).toBeGreaterThanOrEqual(5)
expect(screen.getAllByText('0.26').length).toBeGreaterThanOrEqual(1)
expect(fetchMock).toHaveBeenCalledWith(
'/api/intake/reference-image-estimate',
expect.objectContaining({
method: 'POST',
body: expect.stringContaining('高106 宽83 深24'),
}),
)
await actor.type(screen.getByLabelText('大板价格'), '120')
await actor.type(screen.getByLabelText('板材厚度'), '15松木')
expect(screen.getAllByText('15松木').length).toBeGreaterThanOrEqual(1)
expect(screen.getByText('同色的三合板')).toBeInTheDocument()
}, 10000)
it('defaults to the non-integrated intake view with the pending section expanded', () => {
renderSelector({ eligibleSkuList: [] })
@ -2150,8 +1807,7 @@ describe('IntakeClient', () => {
expect(within(workspacePanel).queryByRole('button', { name: '新增部件' })).not.toBeInTheDocument()
})
it('keeps BOM libraries visible but read-only entry points hidden from purchasing users', async () => {
const actor = userEvent.setup()
it('keeps product development available to purchasing users', () => {
renderSelector({
eligibleSkuList: [],
@ -2167,45 +1823,9 @@ describe('IntakeClient', () => {
const rightPanel = screen.getByTestId('right-panel')
expect(within(rightPanel).getByRole('button', { name: '产品开发明细' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: 'BOM资料库' })).toBeInTheDocument()
expect(within(rightPanel).queryByRole('button', { name: '产品专利' })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { name: '新增产品' })).not.toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: 'BOM资料库' }))
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-active-tab')).toHaveTextContent('substrate')
})
it('keeps BOM library editing enabled for admins', async () => {
const actor = userEvent.setup()
renderSelector({
eligibleSkuList: [],
userRole: 'ADMIN',
userBusinessRoles: ['PURCHASING'],
})
const rightPanel = screen.getByTestId('right-panel')
await actor.click(within(rightPanel).getByRole('button', { name: /BOM/ }))
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-can-edit')).toHaveTextContent('true')
})
it('keeps BOM library editing enabled for designers', async () => {
const actor = userEvent.setup()
renderSelector({
eligibleSkuList: [],
userRole: 'USER',
userBusinessRoles: ['DESIGN'],
})
const rightPanel = screen.getByTestId('right-panel')
await actor.click(within(rightPanel).getByRole('button', { name: /BOM/ }))
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-can-edit')).toHaveTextContent('true')
})
it('opens the series development list with the same product detail capabilities', async () => {
@ -2986,7 +2606,7 @@ describe('IntakeClient', () => {
)
})
it('opens non-integrated products and BOM libraries as workspace tabs', async () => {
it('opens non-integrated products as workspace tabs', async () => {
const actor = userEvent.setup()
replaceNonIntegratedProducts([createNonIntegratedProduct()])
@ -3014,25 +2634,6 @@ describe('IntakeClient', () => {
expect(screen.getByRole('button', { name: '打开DNZ0001工作页' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '产品开发明细' })).toBeInTheDocument()
await actor.click(within(rightPanel).getByRole('button', { name: '板材资料库' }))
expect(screen.getByRole('tab', { name: '板材资料库' })).toBeInTheDocument()
expect(screen.getByText('material-library-copy')).toBeInTheDocument()
expect(screen.getByTestId('material-library-active-tab')).toHaveTextContent('substrate')
await actor.click(screen.getByRole('button', { name: '关闭板材资料库' }))
expect(screen.queryByRole('tab', { name: '板材资料库' })).not.toBeInTheDocument()
expect(screen.getByRole('tab', { name: 'DNZ0001产品开发明细' })).toHaveAttribute(
'aria-selected',
'true',
)
await actor.click(screen.getByRole('tab', { name: '产品开发明细' }))
expect(screen.getByRole('button', { name: '打开DNZ0001工作页' })).toBeInTheDocument()
expect(within(rightPanel).getByRole('button', { name: '产品开发明细' })).toBeInTheDocument()
await actor.click(screen.getByRole('button', { name: '关闭产品开发明细' }))
expect(screen.queryByRole('tab', { name: '产品开发明细' })).not.toBeInTheDocument()
@ -4033,9 +3634,6 @@ describe('IntakeClient', () => {
expect(
within(rightPanel).getByRole('button', { name: 'SPU规则库' }),
).toBeInTheDocument()
expect(
within(rightPanel).getByRole('button', { name: 'BOM资料库' }),
).toBeInTheDocument()
})
it('does not restore removed node permission or admin-only workspaces for ordinary users', async () => {

View File

@ -3,12 +3,10 @@
import type { ComponentProps, ReactNode } from "react";
import { BarcodePrintDomain } from "@/app/intake/barcode-print/BarcodePrintDomain";
import { BrandFilingDomain } from "@/app/intake/brand-filing/BrandFilingDomain";
import { BomLibraryDomain } from "@/app/intake/bom-library/BomLibraryDomain";
import type { IntakeSection } from "@/app/intake/intakeWorkspaceTypes";
import { ProductDevelopmentDomain } from "@/app/intake/product-development/ProductDevelopmentDomain";
import { ProductPatentDashboard } from "@/app/intake/product-patent/ProductPatentDomain";
import { RawMaterialLibraryDomain } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import { ReferenceEstimatorDomain } from "@/app/intake/reference-estimator/ReferenceEstimatorDomain";
import { RawMaterialLibraryDomain } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
type ProductDevelopmentDomainProps = ComponentProps<
typeof ProductDevelopmentDomain
@ -18,12 +16,8 @@ export type IntakePrimaryDomainContentProps = {
activeSection: IntakeSection;
fallback: ReactNode;
productDevelopment: Omit<ProductDevelopmentDomainProps, "activeSection">;
canViewBomLibrary: boolean;
bomLibrary: ComponentProps<typeof BomLibraryDomain>;
canViewRawMaterialLibrary: boolean;
rawMaterialLibrary: ComponentProps<typeof RawMaterialLibraryDomain>;
canViewReferenceEstimator: boolean;
referenceEstimator: ComponentProps<typeof ReferenceEstimatorDomain>;
canViewProductPatentLedger: boolean;
productPatent: ComponentProps<typeof ProductPatentDashboard>;
canViewBarcodePrint: boolean;
@ -35,12 +29,8 @@ export function IntakePrimaryDomainContent({
activeSection,
fallback,
productDevelopment,
canViewBomLibrary,
bomLibrary,
canViewRawMaterialLibrary,
rawMaterialLibrary,
canViewReferenceEstimator,
referenceEstimator,
canViewProductPatentLedger,
productPatent,
canViewBarcodePrint,
@ -56,18 +46,10 @@ export function IntakePrimaryDomainContent({
);
}
if (activeSection === "bom" && canViewBomLibrary) {
return <BomLibraryDomain {...bomLibrary} />;
}
if (activeSection === "rawMaterialLibrary" && canViewRawMaterialLibrary) {
return <RawMaterialLibraryDomain {...rawMaterialLibrary} />;
}
if (activeSection === "referenceEstimator" && canViewReferenceEstimator) {
return <ReferenceEstimatorDomain {...referenceEstimator} />;
}
if (activeSection === "patents" && canViewProductPatentLedger) {
return <ProductPatentDashboard {...productPatent} />;
}

View File

@ -9,6 +9,7 @@ export type IntakeWorkspaceContentPanelProps = Omit<
"fallback"
> & {
tabs: Array<{ id: string; label: string }>;
tabsReady: boolean;
activeTabId: string | null;
mainContent: ReactNode;
onActivate: (tabId: string) => void;
@ -17,6 +18,7 @@ export type IntakeWorkspaceContentPanelProps = Omit<
export function IntakeWorkspaceContentPanel({
tabs,
tabsReady,
activeTabId,
mainContent,
onActivate,
@ -26,6 +28,7 @@ export function IntakeWorkspaceContentPanel({
return (
<IntakeWorkspaceShell
tabs={tabs}
tabsReady={tabsReady}
activeTabId={activeTabId}
activeContent={
<IntakeActiveWorkspaceContent

View File

@ -1,62 +0,0 @@
"use client";
import { FileSpreadsheet } from "lucide-react";
import { AccordionSection } from "@/components/platform/AccordionSection";
import {
FORMAL_SIDEBAR_SECTION_ICON_CLASS,
FormalSidebarIcon,
} from "@/app/intake/components/FormalSidebarIcon";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import { BOM_LIBRARY_OPTIONS } from "@/app/intake/bom-library/bomLibraryConfig";
import type { IntakeSection } from "@/app/intake/intakeWorkspaceTypes";
import { getProductRecordsNavLabel } from "@/config/product-workbench-navigation";
export function BomLibraryWorkbenchSection({
activeSection,
activeBomLibrary,
canViewBomLibrary,
onToggle,
onBomLibraryChange,
}: {
activeSection: IntakeSection;
activeBomLibrary: BomLibraryKey;
canViewBomLibrary: boolean;
onToggle: (section: Exclude<IntakeSection, null>) => void;
onBomLibraryChange: (library: BomLibraryKey) => void;
}) {
if (!canViewBomLibrary) return null;
return (
<AccordionSection
title={getProductRecordsNavLabel("bomLibrary")}
compact
icon={
<FormalSidebarIcon
icon={FileSpreadsheet}
className={FORMAL_SIDEBAR_SECTION_ICON_CLASS}
/>
}
expanded={activeSection === "bom"}
onToggle={() => onToggle("bom")}
>
<div className="space-y-2">
{BOM_LIBRARY_OPTIONS.map((option) => (
<button
key={option.key}
type="button"
onClick={() => {
onBomLibraryChange(option.key);
}}
className={`flex w-full items-center rounded-apple-lg border px-3 py-2 text-left text-xs transition ${
activeSection === "bom" && activeBomLibrary === option.key
? "border-apple-blue bg-apple-blue/10 text-apple-blue"
: "border-apple-separator bg-apple-bg-secondary text-apple-label-secondary"
}`}
>
<span>{option.label}</span>
</button>
))}
</div>
</AccordionSection>
);
}

View File

@ -1,58 +0,0 @@
"use client";
import { BomLibraryDomain } from "@/app/intake/bom-library/BomLibraryDomain";
import type { IntakeWorkspaceTab } from "@/app/intake/intakeWorkspaceTypes";
import type {
MaterialCategoryDTO,
MaterialDTO,
SubstrateDictionaryBundleDTO,
SubstrateDTO,
} from "@/server/services";
type BomLibraryWorkspaceTab = Extract<IntakeWorkspaceTab, { kind: "bomLibrary" }>;
type BomLibraryWorkspaceUser = {
role?: string;
businessRoles?: string[] | null;
department?: { name?: string | null; fullPath?: string | null } | null;
departmentPaths?: string[] | null;
};
export function isBomLibraryWorkspaceTab(
tab: IntakeWorkspaceTab,
): tab is BomLibraryWorkspaceTab {
return tab.kind === "bomLibrary";
}
export function BomLibraryWorkspaceContent({
activeWorkspaceTab,
currentUser,
canEditBomLibrary,
materialLibrarySubstrates,
materialLibraryFinishes,
materialLibraryCategories,
materialLibraryDictionaries,
onMaterialLibraryFinishesChange,
}: {
activeWorkspaceTab: BomLibraryWorkspaceTab;
currentUser: BomLibraryWorkspaceUser;
canEditBomLibrary: boolean;
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
onMaterialLibraryFinishesChange: (finishes: MaterialDTO[]) => void;
}) {
return (
<BomLibraryDomain
user={currentUser}
canEditLibraries={canEditBomLibrary}
activeBomLibrary={activeWorkspaceTab.bomLibrary}
materialLibrarySubstrates={materialLibrarySubstrates}
materialLibraryFinishes={materialLibraryFinishes}
materialLibraryCategories={materialLibraryCategories}
materialLibraryDictionaries={materialLibraryDictionaries}
onMaterialLibraryFinishesChange={onMaterialLibraryFinishesChange}
/>
);
}

View File

@ -15,11 +15,6 @@ describe('FormalIntakeWorkbench navigation source', () => {
pendingEntryTab="nonIntegrated"
onPendingEntryTabChange={noop}
onOpenProgressDashboard={noop}
activeBomLibrary="materialLibrary"
onBomLibraryChange={noop}
activeRawMaterialLibrary="processConfig"
onOpenRawMaterialLibraryWorkspace={noop}
onOpenReferenceEstimatorWorkspace={noop}
onOpenProductPatents={noop}
onOpenProductPatentLedger={noop}
onOpenProductPatentDashboard={noop}
@ -32,20 +27,19 @@ describe('FormalIntakeWorkbench navigation source', () => {
canViewSeriesDevelopmentList
canViewProductProgressDashboard
canViewStockDevelopmentList
canViewBomLibrary
canViewRawMaterialLibrary
canViewReferenceEstimator
canViewProductPatentLedger
canViewProductPatentDashboard
canViewBarcodePrint
canViewBrandFiling
canViewWorkRecord={false}
canViewWorkRecordArchives={false}
canViewWorkRecord
canViewWorkRecordArchives
/>,
)
PRODUCT_RECORDS_NAV_ITEMS.forEach((item) => {
expect(screen.getByText(item.label)).toBeInTheDocument()
})
expect(screen.queryByRole('button', { name: /^(BOM资料库|原材料资料库|预估成本测算)$/ }))
.not.toBeInTheDocument()
})
})

View File

@ -4,18 +4,13 @@ import { useEffect, useRef } from "react";
import { BarcodePrintWorkbenchButton } from "@/app/intake/barcode-print/BarcodePrintWorkbenchButton";
import { BrandFilingWorkbenchSection } from "@/app/intake/brand-filing/BrandFilingWorkbenchSection";
import type { BrandFilingBrand } from "@/app/intake/brand-filing/brandFilingConfig";
import { BomLibraryWorkbenchSection } from "@/app/intake/bom-library/BomLibraryWorkbenchSection";
import type {
IntakeEntryTab,
IntakeSection,
IntakeWorkspaceTab,
} from "@/app/intake/intakeWorkspaceTypes";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import { ProductDevelopmentWorkbenchSection } from "@/app/intake/product-development/ProductDevelopmentWorkbenchSection";
import { ProductPatentWorkbenchSection } from "@/app/intake/product-patent/ProductPatentWorkbenchSection";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import { RawMaterialLibraryWorkbenchSection } from "@/app/intake/raw-material-library/RawMaterialLibraryWorkbenchSection";
import { ReferenceEstimatorWorkbenchSection } from "@/app/intake/reference-estimator/ReferenceEstimatorWorkbenchSection";
import { WorkRecordWorkbenchSection } from "@/app/intake/work-record/WorkRecordWorkbenchSection";
export function FormalIntakeWorkbench({
@ -26,11 +21,6 @@ export function FormalIntakeWorkbench({
pendingEntryTab,
onPendingEntryTabChange,
onOpenProgressDashboard,
activeBomLibrary,
onBomLibraryChange,
activeRawMaterialLibrary,
onOpenRawMaterialLibraryWorkspace,
onOpenReferenceEstimatorWorkspace,
onOpenProductPatents,
onOpenProductPatentLedger,
onOpenProductPatentDashboard,
@ -44,9 +34,6 @@ export function FormalIntakeWorkbench({
canViewSeriesDevelopmentList,
canViewProductProgressDashboard,
canViewStockDevelopmentList,
canViewBomLibrary,
canViewRawMaterialLibrary,
canViewReferenceEstimator,
canViewProductPatentLedger,
canViewProductPatentDashboard,
canViewBarcodePrint,
@ -61,11 +48,6 @@ export function FormalIntakeWorkbench({
pendingEntryTab: IntakeEntryTab;
onPendingEntryTabChange: (tab: IntakeEntryTab) => void;
onOpenProgressDashboard: () => void;
activeBomLibrary: BomLibraryKey;
onBomLibraryChange: (library: BomLibraryKey) => void;
activeRawMaterialLibrary: RawMaterialLibraryKey;
onOpenRawMaterialLibraryWorkspace: (library: RawMaterialLibraryKey) => void;
onOpenReferenceEstimatorWorkspace: () => void;
onOpenProductPatents: () => void;
onOpenProductPatentLedger: () => void;
onOpenProductPatentDashboard: () => void;
@ -79,9 +61,6 @@ export function FormalIntakeWorkbench({
canViewSeriesDevelopmentList: boolean;
canViewProductProgressDashboard: boolean;
canViewStockDevelopmentList: boolean;
canViewBomLibrary: boolean;
canViewRawMaterialLibrary: boolean;
canViewReferenceEstimator: boolean;
canViewProductPatentLedger: boolean;
canViewProductPatentDashboard: boolean;
canViewBarcodePrint: boolean;
@ -115,26 +94,6 @@ export function FormalIntakeWorkbench({
canViewProductProgressDashboard={canViewProductProgressDashboard}
canViewStockDevelopmentList={canViewStockDevelopmentList}
/>
<BomLibraryWorkbenchSection
activeSection={activeSection}
activeBomLibrary={activeBomLibrary}
canViewBomLibrary={canViewBomLibrary}
onToggle={onToggle}
onBomLibraryChange={onBomLibraryChange}
/>
<RawMaterialLibraryWorkbenchSection
activeSection={activeSection}
activeRawMaterialLibrary={activeRawMaterialLibrary}
canViewRawMaterialLibrary={canViewRawMaterialLibrary}
onToggle={onToggle}
onOpenRawMaterialLibraryWorkspace={onOpenRawMaterialLibraryWorkspace}
/>
<ReferenceEstimatorWorkbenchSection
activeSection={activeSection}
canViewReferenceEstimator={canViewReferenceEstimator}
onToggle={onToggle}
onOpenReferenceEstimatorWorkspace={onOpenReferenceEstimatorWorkspace}
/>
<ProductPatentWorkbenchSection
activeSection={activeSection}
canViewProductPatentLedger={canViewProductPatentLedger}

View File

@ -23,9 +23,6 @@ function IntakeMobileMenu({ workbench, onNavigate }: { workbench: WorkbenchProps
<FormalIntakeWorkbench {...workbench}
onPendingEntryTabChange={navigate(workbench.onPendingEntryTabChange)}
onOpenProgressDashboard={navigate(workbench.onOpenProgressDashboard)}
onBomLibraryChange={navigate(workbench.onBomLibraryChange)}
onOpenRawMaterialLibraryWorkspace={navigate(workbench.onOpenRawMaterialLibraryWorkspace)}
onOpenReferenceEstimatorWorkspace={navigate(workbench.onOpenReferenceEstimatorWorkspace)}
onOpenProductPatents={workbench.onOpenProductPatents}
onOpenProductPatentLedger={navigate(workbench.onOpenProductPatentLedger)}
onOpenProductPatentDashboard={navigate(workbench.onOpenProductPatentDashboard)}

View File

@ -1,32 +1,54 @@
"use client";
import type { ReactNode } from "react";
import { useEffect, type ReactNode } from "react";
import { useBreakpoint } from '@/hooks/useMediaQuery';
import { useProductWorkspaceTabs } from '@/components/layout/ProductWorkspaceTabs';
import { IntakeWorkspaceTabBar } from "@/app/intake/components/IntakeWorkspaceTabBar";
export function IntakeWorkspaceShell({
tabs,
tabsReady,
activeTabId,
activeContent,
onActivate,
onClose,
}: {
tabs: Array<{ id: string; label: string }>;
tabsReady?: boolean;
activeTabId: string | null;
activeContent: ReactNode;
onActivate: (tabId: string) => void;
onClose: (tabId: string) => void;
}) {
const { isMobileOrTablet } = useBreakpoint();
const workspaceTabs = useProductWorkspaceTabs();
const command = workspaceTabs?.isIntake ? workspaceTabs.intakeCommands[0] : undefined;
const finishCommand = workspaceTabs?.finishCommand;
const reportIntakeTabs = workspaceTabs?.reportIntakeTabs;
useEffect(() => {
if (!tabsReady || !workspaceTabs?.isIntake) return;
if (!command) {
reportIntakeTabs?.(tabs);
return;
}
if (tabs.some((tab) => tab.id === command.id)) {
if (command.action === 'close') onClose(command.id);
else onActivate(command.id);
}
finishCommand?.(command);
}, [command, finishCommand, onActivate, onClose, reportIntakeTabs, tabs, tabsReady, workspaceTabs?.isIntake]);
return (
<div className={`flex h-full min-h-0 flex-col ${isMobileOrTablet ? 'gap-1' : 'gap-2'}`}>
<IntakeWorkspaceTabBar
tabs={tabs}
activeTabId={activeTabId}
onActivate={onActivate}
onClose={onClose}
/>
{workspaceTabs?.renderPageTabBar(tabs, activeTabId, onActivate, onClose) ?? (
<IntakeWorkspaceTabBar
tabs={tabs}
activeTabId={activeTabId}
onActivate={onActivate}
onClose={onClose}
/>
)}
<div className="min-h-0 flex-1 overflow-hidden" role="tabpanel">
{activeContent}
</div>

View File

@ -1,4 +1,4 @@
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import type {
IntakeEntryTab,
IntakeSection,
@ -11,10 +11,7 @@ import type {
CategoryDTO,
DraftGroupDetailDTO,
IntakeProductRecommendationDTO,
MaterialCategoryDTO,
MaterialDTO,
SubstrateDictionaryBundleDTO,
SubstrateDTO,
WarehouseLocationDTO,
} from "@/server/services";
import type { PlatformMetricItem } from "@/components/platform/types";
@ -43,10 +40,7 @@ type IntakeOpenProductWorkspaceInput = {
type CommonIntakeClientProps = {
user: IntakeClientUser;
metrics: PlatformMetricItem[];
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
initialNonIntegratedProducts: NonIntegratedProductRecord[];
initialProductDevelopmentProgressProducts?: NonIntegratedProductRecord[];
initialNonIntegratedPageInfo?: {

View File

@ -1,7 +1,6 @@
"use client";
import type { BrandFilingBrand } from "@/app/intake/brand-filing/brandFilingConfig";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import { IntakeEmptyDetail } from "@/app/intake/IntakeMainLayout";
import type { IntakePrimaryDomainContentProps } from "@/app/intake/IntakePrimaryDomainContent";
import type { IntakeRightWorkbenchPanelProps } from "@/app/intake/IntakeRightWorkbenchPanel";
@ -19,24 +18,21 @@ import type {
} from "@/app/intake/intakeWorkspaceTypes";
import type { NonIntegratedProductKindFilter } from "@/app/intake/product-development/nonIntegratedListState";
import type { ProductPatentLedgerTarget } from "@/app/intake/product-patent/ProductPatentDomain";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import type { NonIntegratedProductRecord } from "@/app/intake/non-integrated/nonIntegratedStorage";
import type {
MaterialCategoryDTO,
MaterialDTO,
SubstrateDictionaryBundleDTO,
SubstrateDTO,
} from "@/server/services";
type IntakeViewUser = IntakeClientProps["user"];
export function buildIntakeWorkspacePanelProps(params: {
workspaceTabs: IntakeWorkspaceTab[];
workspaceStateReady: boolean;
activeWorkspaceTabId: string | null;
activeWorkspaceTab: IntakeWorkspaceTab | null;
user: IntakeViewUser;
canManageSpuRuleLibrary: boolean;
canEditBomLibrary: boolean;
canViewProductPatentLedger: boolean;
canEditProductPatentLedger: boolean;
canViewProductPatentDashboard: boolean;
@ -50,10 +46,7 @@ export function buildIntakeWorkspacePanelProps(params: {
existingSeriesNames: string[];
existingSeriesComponentDetailNames: string[];
seriesDraftSkuOptions: WorkbenchSku[];
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
selectedRawMaterialName: string;
nonIntegratedProducts: NonIntegratedProductRecord[];
productDevelopmentProgressProducts: NonIntegratedProductRecord[];
@ -73,18 +66,17 @@ export function buildIntakeWorkspacePanelProps(params: {
entryTabOverride?: IntakeEntryTab,
) => void;
onCloseNewProductWorkspace: (tabId: string) => void;
onMaterialLibraryFinishesChange: (finishes: MaterialDTO[]) => void;
onOpenWorkRecordArchiveDetailWorkspace: (monthKey: string, label?: string) => void;
onActivate: (tabId: string) => void;
onClose: (tabId: string) => void;
}): Omit<IntakeWorkspaceContentPanelProps, "mainContent"> {
return {
tabs: params.workspaceTabs,
tabsReady: params.workspaceStateReady,
activeTabId: params.activeWorkspaceTabId,
activeWorkspaceTab: params.activeWorkspaceTab,
currentUser: params.user,
canManageSpuRuleLibrary: params.canManageSpuRuleLibrary,
canEditBomLibrary: params.canEditBomLibrary,
canViewProductPatentLedger: params.canViewProductPatentLedger,
canEditProductPatentLedger: params.canEditProductPatentLedger,
canViewProductPatentDashboard: params.canViewProductPatentDashboard,
@ -100,10 +92,7 @@ export function buildIntakeWorkspacePanelProps(params: {
existingSeriesComponentDetailNames:
params.existingSeriesComponentDetailNames,
seriesDraftSkuOptions: params.seriesDraftSkuOptions,
materialLibrarySubstrates: params.materialLibrarySubstrates,
materialLibraryFinishes: params.materialLibraryFinishes,
materialLibraryCategories: params.materialLibraryCategories,
materialLibraryDictionaries: params.materialLibraryDictionaries,
selectedRawMaterialName: params.selectedRawMaterialName,
nonIntegratedProducts: params.nonIntegratedProducts,
productDevelopmentProgressProducts:
@ -118,7 +107,6 @@ export function buildIntakeWorkspacePanelProps(params: {
onActivatePendingEntryListWorkspace:
params.onActivatePendingEntryListWorkspace,
onCloseNewProductWorkspace: params.onCloseNewProductWorkspace,
onMaterialLibraryFinishesChange: params.onMaterialLibraryFinishesChange,
onOpenWorkRecordArchiveDetailWorkspace:
params.onOpenWorkRecordArchiveDetailWorkspace,
onActivate: params.onActivate,
@ -154,18 +142,9 @@ export function buildIntakePrimaryDomainProps(params: {
onOpenNewProductWorkspace: (
productDevelopmentKind: ProductDevelopmentKind,
) => void;
canViewBomLibrary: boolean;
canEditBomLibrary: boolean;
activeBomLibrary: BomLibraryKey;
materialLibrarySubstrates: SubstrateDTO[];
materialLibraryFinishes: MaterialDTO[];
materialLibraryCategories: MaterialCategoryDTO[];
materialLibraryDictionaries: SubstrateDictionaryBundleDTO;
onMaterialLibraryFinishesChange: (finishes: MaterialDTO[]) => void;
canViewRawMaterialLibrary: boolean;
activeRawMaterialLibrary: RawMaterialLibraryKey;
selectedRawMaterialName: string;
canViewReferenceEstimator: boolean;
canViewProductPatentLedger: boolean;
canEditProductPatentLedger: boolean;
canViewBarcodePrint: boolean;
@ -197,28 +176,11 @@ export function buildIntakePrimaryDomainProps(params: {
onOpenProductWorkspace: params.onOpenProductWorkspace,
onOpenNewProductWorkspace: params.onOpenNewProductWorkspace,
},
canViewBomLibrary: params.canViewBomLibrary,
bomLibrary: {
user: params.user,
canEditLibraries: params.canEditBomLibrary,
activeBomLibrary: params.activeBomLibrary,
materialLibrarySubstrates: params.materialLibrarySubstrates,
materialLibraryFinishes: params.materialLibraryFinishes,
materialLibraryCategories: params.materialLibraryCategories,
materialLibraryDictionaries: params.materialLibraryDictionaries,
onMaterialLibraryFinishesChange:
params.onMaterialLibraryFinishesChange,
},
canViewRawMaterialLibrary: params.canViewRawMaterialLibrary,
rawMaterialLibrary: {
activeRawMaterialLibrary: params.activeRawMaterialLibrary,
selectedMaterialName: params.selectedRawMaterialName,
},
canViewReferenceEstimator: params.canViewReferenceEstimator,
referenceEstimator: {
materialLibrarySubstrates: params.materialLibrarySubstrates,
userId: params.user.id,
},
canViewProductPatentLedger: params.canViewProductPatentLedger,
productPatent: {
products: params.productDevelopmentProgressProducts,
@ -242,14 +204,6 @@ export function buildIntakeRightWorkbenchProps(params: {
pendingEntryTab: IntakeEntryTab;
onPendingEntryTabChange: (entryTab: IntakeEntryTab) => void;
onOpenProgressDashboard: () => void;
activeBomLibrary: BomLibraryKey;
onBomLibraryChange: (library: BomLibraryKey) => void;
activeRawMaterialLibrary: RawMaterialLibraryKey;
onOpenRawMaterialLibraryWorkspace: (
library: RawMaterialLibraryKey,
selectedMaterialName?: string,
) => void;
onOpenReferenceEstimatorWorkspace: () => void;
onOpenProductPatents: () => void;
onOpenProductPatentLedger: () => void;
onOpenProductPatentDashboard: () => void;
@ -263,9 +217,6 @@ export function buildIntakeRightWorkbenchProps(params: {
canViewSeriesDevelopmentList: boolean;
canViewProductProgressDashboard: boolean;
canViewStockDevelopmentList: boolean;
canViewBomLibrary: boolean;
canViewRawMaterialLibrary: boolean;
canViewReferenceEstimator: boolean;
canViewProductPatentLedger: boolean;
canViewProductPatentDashboard: boolean;
canViewBarcodePrint: boolean;
@ -283,13 +234,6 @@ export function buildIntakeRightWorkbenchProps(params: {
pendingEntryTab: params.pendingEntryTab,
onPendingEntryTabChange: params.onPendingEntryTabChange,
onOpenProgressDashboard: params.onOpenProgressDashboard,
activeBomLibrary: params.activeBomLibrary,
onBomLibraryChange: params.onBomLibraryChange,
activeRawMaterialLibrary: params.activeRawMaterialLibrary,
onOpenRawMaterialLibraryWorkspace:
params.onOpenRawMaterialLibraryWorkspace,
onOpenReferenceEstimatorWorkspace:
params.onOpenReferenceEstimatorWorkspace,
onOpenProductPatents: params.onOpenProductPatents,
onOpenProductPatentLedger: params.onOpenProductPatentLedger,
onOpenProductPatentDashboard: params.onOpenProductPatentDashboard,
@ -304,9 +248,6 @@ export function buildIntakeRightWorkbenchProps(params: {
canViewProductProgressDashboard:
params.canViewProductProgressDashboard,
canViewStockDevelopmentList: params.canViewStockDevelopmentList,
canViewBomLibrary: params.canViewBomLibrary,
canViewRawMaterialLibrary: params.canViewRawMaterialLibrary,
canViewReferenceEstimator: params.canViewReferenceEstimator,
canViewProductPatentLedger: params.canViewProductPatentLedger,
canViewProductPatentDashboard: params.canViewProductPatentDashboard,
canViewBarcodePrint: params.canViewBarcodePrint,

View File

@ -1,5 +1,5 @@
export { BARCODE_PRINT_LABEL } from "@/app/intake/barcode-print/barcodePrintConfig";
export { BOM_LIBRARY_OPTIONS } from "@/app/intake/bom-library/bomLibraryConfig";
export { BOM_LIBRARY_OPTIONS } from "@/app/database/bom-library/bomLibraryConfig";
export { PRODUCT_PATENT_DASHBOARD_LABEL, PRODUCT_PATENT_LEDGER_LABEL } from "@/app/intake/product-patent/productPatentConfig";
export { RAW_MATERIAL_LIBRARY_OPTIONS } from "@/app/intake/raw-material-library/rawMaterialLibraryConfig";
export { REFERENCE_ESTIMATOR_GROUP_LABEL, REFERENCE_ESTIMATOR_WORKSPACE_LABEL } from "@/app/intake/reference-estimator/referenceEstimatorConfig";
export { RAW_MATERIAL_LIBRARY_OPTIONS } from "@/app/database/raw-material-library/rawMaterialLibraryConfig";
export { REFERENCE_ESTIMATOR_GROUP_LABEL, REFERENCE_ESTIMATOR_WORKSPACE_LABEL } from "@/app/reference-estimator/referenceEstimatorConfig";

View File

@ -2,19 +2,19 @@ import {
getBrandFilingWorkspaceLabel,
type BrandFilingBrand,
} from "@/app/intake/brand-filing/brandFilingConfig";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import { BOM_LIBRARY_OPTIONS } from "@/app/intake/bom-library/bomLibraryConfig";
import type { BomLibraryKey } from "@/app/database/bom-library/BomLibraryDomain";
import { BOM_LIBRARY_OPTIONS } from "@/app/database/bom-library/bomLibraryConfig";
import { BARCODE_PRINT_LABEL } from "@/app/intake/barcode-print/barcodePrintConfig";
import type { ProductPatentLedgerTarget } from "@/app/intake/product-patent/ProductPatentDomain";
import {
PRODUCT_PATENT_DASHBOARD_LABEL,
PRODUCT_PATENT_LEDGER_LABEL,
} from "@/app/intake/product-patent/productPatentConfig";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import { RAW_MATERIAL_LIBRARY_OPTIONS } from "@/app/intake/raw-material-library/rawMaterialLibraryConfig";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import { RAW_MATERIAL_LIBRARY_OPTIONS } from "@/app/database/raw-material-library/rawMaterialLibraryConfig";
import {
REFERENCE_ESTIMATOR_WORKSPACE_LABEL,
} from "@/app/intake/reference-estimator/referenceEstimatorConfig";
} from "@/app/reference-estimator/referenceEstimatorConfig";
import {
canAccessWorkRecord,
canDownloadWorkRecordMonthlyArchives,
@ -613,23 +613,11 @@ function restoreIntakeWorkspaceTab(
: "new",
);
}
if (tab.kind === "bomLibrary") {
const option = BOM_LIBRARY_OPTIONS.find(
(item) => item.key === tab.bomLibrary,
);
if (!option) return null;
return {
id: tab.id,
kind: tab.kind,
label: option.label,
bomLibrary: option.key,
};
}
if (tab.kind === "rawMaterialLibrary") {
const option = RAW_MATERIAL_LIBRARY_OPTIONS.find(
(item) => item.key === tab.rawMaterialLibrary,
);
if (!option) return null;
if (!option || !tab.selectedMaterialName) return null;
return {
id: tab.id,
kind: tab.kind,
@ -638,14 +626,6 @@ function restoreIntakeWorkspaceTab(
selectedMaterialName: tab.selectedMaterialName,
};
}
if (tab.kind === "referenceEstimator") {
return {
id: tab.id,
kind: tab.kind,
label: REFERENCE_ESTIMATOR_WORKSPACE_LABEL,
};
}
return null;
}

View File

@ -1,7 +1,7 @@
import type { BrandFilingBrand } from "@/app/intake/brand-filing/brandFilingConfig";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import type { BomLibraryKey } from "@/app/database/bom-library/BomLibraryDomain";
import type { ProductPatentLedgerTarget } from "@/app/intake/product-patent/ProductPatentDomain";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import type {
NonIntegratedDocumentWorkspaceCategory,
NonIntegratedProductRecord,

View File

@ -1,6 +1,6 @@
"use client";
import RawMaterialLibraryPanel from "@/app/intake/raw-material-library/RawMaterialLibraryPanel";
import RawMaterialLibraryPanel from "@/app/database/raw-material-library/RawMaterialLibraryPanel";
import type { LinkEntryWorkspaceTab } from "./shared/LinkEntryWorkspaceContent";
type RawMaterialDomainProps = {

View File

@ -1,3 +1,6 @@
import { redirect } from 'next/navigation'
import { rawMaterialLibraryHref } from '@/config/intake-library-navigation'
import { linkedReferenceEstimateId, referenceEstimateHref } from '@/app/reference-estimator/referenceEstimateLinks'
import { requireSession } from '@/lib/server-session'
import { assetCenterService } from '@/server/services/asset-center.service'
import { categoryService } from '@/server/services/category.service'
@ -205,15 +208,13 @@ export default async function IntakePage({
}) {
const { user, authUser } = await requireSession('/login')
const params = await searchParams
const estimateId = linkedReferenceEstimateId(new URLSearchParams({ estimateId: readSingleSearchParam(params, 'estimateId') ?? '' }).toString())
if (estimateId) redirect(referenceEstimateHref(estimateId))
if (readSingleSearchParam(params, 'section') === 'rawMaterialLibrary') {
const library = readSingleSearchParam(params, 'rawMaterialLibrary') === 'detailArchive' ? 'detailArchive' : 'processConfig'
redirect(rawMaterialLibraryHref(library, readSingleSearchParam(params, 'material')))
}
const draftGroupId = typeof params.draftGroupId === 'string' ? params.draftGroupId : null
const initialActiveSection =
readSingleSearchParam(params, 'section') === 'rawMaterialLibrary'
? 'rawMaterialLibrary'
: undefined
const rawMaterialLibraryParam = readSingleSearchParam(params, 'rawMaterialLibrary')
const initialActiveRawMaterialLibrary =
rawMaterialLibraryParam === 'detailArchive' ? 'detailArchive' : 'processConfig'
const initialRawMaterialName = readSingleSearchParam(params, 'material')
const initialOpenNewNonIntegratedProduct = params.newProduct === '1'
const initialOpenProductId = readSingleSearchParam(params, 'openProductId')
const initialOpenProductMode: 'view' | 'edit' =
@ -227,10 +228,7 @@ export default async function IntakePage({
const [
draftGroups,
locations,
materialLibrarySubstrates,
materialLibraryFinishes,
materialLibraryCategories,
materialLibraryDictionaries,
initialProductNonIntegratedProductPage,
initialStockNonIntegratedProductPage,
initialSeriesNonIntegratedProductPage,
@ -241,10 +239,7 @@ export default async function IntakePage({
] = await Promise.all([
draftGroupService.list(),
warehouseService.listLocations(),
assetCenterService.listSubstrates(),
materialService.findAll({ limit: 500 }),
materialService.findAllCategories(),
assetCenterService.getSubstrateDictionaryBundle(),
intakeNonIntegratedProductService.listPage(authUser, {
page: 1,
pageSize: 50,
@ -382,17 +377,11 @@ export default async function IntakePage({
eligibleSkuList={eligibleSkuList}
draftGroupId={draftGroupId}
hasIneligibleSelected={!!draftGroupId && !!selectedDetail}
materialLibrarySubstrates={materialLibrarySubstrates}
materialLibraryFinishes={materialLibraryFinishes}
materialLibraryCategories={materialLibraryCategories}
materialLibraryDictionaries={materialLibraryDictionaries}
initialNonIntegratedProducts={initialNonIntegratedProducts}
initialProductDevelopmentProgressProducts={initialProductDevelopmentProgressProducts}
initialNonIntegratedPageInfo={initialNonIntegratedPageInfo}
initialNodePermissionOverrides={nodePermissionSettings.overrides}
initialActiveSection={initialActiveSection}
initialActiveRawMaterialLibrary={initialActiveRawMaterialLibrary}
initialRawMaterialName={initialRawMaterialName}
initialOpenNewNonIntegratedProduct={initialOpenNewNonIntegratedProduct}
initialOpenProductRequested={Boolean(initialOpenProductId)}
initialOpenProductWorkspace={initialOpenProductWorkspace}
@ -411,17 +400,11 @@ export default async function IntakePage({
locations={locations}
categories={categories}
defaultAttachProductId={defaultAttachProductId}
materialLibrarySubstrates={materialLibrarySubstrates}
materialLibraryFinishes={materialLibraryFinishes}
materialLibraryCategories={materialLibraryCategories}
materialLibraryDictionaries={materialLibraryDictionaries}
initialNonIntegratedProducts={initialNonIntegratedProducts}
initialProductDevelopmentProgressProducts={initialProductDevelopmentProgressProducts}
initialNonIntegratedPageInfo={initialNonIntegratedPageInfo}
initialNodePermissionOverrides={nodePermissionSettings.overrides}
initialActiveSection={initialActiveSection}
initialActiveRawMaterialLibrary={initialActiveRawMaterialLibrary}
initialRawMaterialName={initialRawMaterialName}
initialOpenNewNonIntegratedProduct={initialOpenNewNonIntegratedProduct}
initialOpenProductRequested={Boolean(initialOpenProductId)}
initialOpenProductWorkspace={initialOpenProductWorkspace}

View File

@ -1,69 +0,0 @@
"use client";
import { Database } from "lucide-react";
import { AccordionSection } from "@/components/platform/AccordionSection";
import {
FORMAL_SIDEBAR_SECTION_ICON_CLASS,
FormalSidebarIcon,
} from "@/app/intake/components/FormalSidebarIcon";
import type { IntakeSection } from "@/app/intake/intakeWorkspaceTypes";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import { RAW_MATERIAL_LIBRARY_OPTIONS } from "@/app/intake/raw-material-library/rawMaterialLibraryConfig";
import { getProductRecordsNavLabel } from "@/config/product-workbench-navigation";
export function RawMaterialLibraryWorkbenchSection({
activeSection,
activeRawMaterialLibrary,
canViewRawMaterialLibrary,
onToggle,
onOpenRawMaterialLibraryWorkspace,
}: {
activeSection: IntakeSection;
activeRawMaterialLibrary: RawMaterialLibraryKey;
canViewRawMaterialLibrary: boolean;
onToggle: (section: Exclude<IntakeSection, null>) => void;
onOpenRawMaterialLibraryWorkspace: (library: RawMaterialLibraryKey) => void;
}) {
if (!canViewRawMaterialLibrary) return null;
return (
<AccordionSection
title={getProductRecordsNavLabel("rawMaterialLibrary")}
compact
icon={
<FormalSidebarIcon
icon={Database}
className={FORMAL_SIDEBAR_SECTION_ICON_CLASS}
/>
}
expanded={activeSection === "rawMaterialLibrary"}
onToggle={() => onToggle("rawMaterialLibrary")}
>
<div className="space-y-2">
{RAW_MATERIAL_LIBRARY_OPTIONS.map((option) => (
<button
key={option.key}
type="button"
aria-label={option.label}
onClick={() => {
onOpenRawMaterialLibraryWorkspace(option.key);
}}
className={`flex w-full flex-col rounded-apple-lg border px-3 py-2 text-left text-xs transition ${
activeSection === "rawMaterialLibrary" &&
activeRawMaterialLibrary === option.key
? "border-apple-blue bg-apple-blue/10 text-apple-blue"
: "border-apple-separator bg-apple-bg-secondary text-apple-label-secondary"
}`}
>
<span className="font-apple-semibold text-apple-label-primary">
{option.label}
</span>
<span className="mt-1 text-[10px] leading-4 text-apple-label-tertiary">
{option.description}
</span>
</button>
))}
</div>
</AccordionSection>
);
}

View File

@ -1,62 +0,0 @@
"use client";
import { Calculator } from "lucide-react";
import { AccordionSection } from "@/components/platform/AccordionSection";
import {
FORMAL_SIDEBAR_SECTION_ICON_CLASS,
FormalSidebarIcon,
} from "@/app/intake/components/FormalSidebarIcon";
import type { IntakeSection } from "@/app/intake/intakeWorkspaceTypes";
import {
REFERENCE_ESTIMATOR_WORKSPACE_LABEL,
} from "@/app/intake/reference-estimator/referenceEstimatorConfig";
import { getProductRecordsNavLabel } from "@/config/product-workbench-navigation";
import { openEstimateSkillLibrary } from './skill-library-events';
export function ReferenceEstimatorWorkbenchSection({
activeSection,
canViewReferenceEstimator,
onToggle,
onOpenReferenceEstimatorWorkspace,
}: {
activeSection: IntakeSection;
canViewReferenceEstimator: boolean;
onToggle: (section: Exclude<IntakeSection, null>) => void;
onOpenReferenceEstimatorWorkspace: () => void;
}) {
if (!canViewReferenceEstimator) return null;
return (
<AccordionSection
title={getProductRecordsNavLabel("referenceEstimator")}
compact
icon={
<FormalSidebarIcon
icon={Calculator}
className={FORMAL_SIDEBAR_SECTION_ICON_CLASS}
/>
}
expanded={activeSection === "referenceEstimator"}
onToggle={() => onToggle("referenceEstimator")}
>
<button
type="button"
aria-label={REFERENCE_ESTIMATOR_WORKSPACE_LABEL}
onClick={onOpenReferenceEstimatorWorkspace}
className={`flex w-full flex-col rounded-apple-lg border px-3 py-2 text-left text-xs transition ${
activeSection === "referenceEstimator"
? "border-apple-blue bg-apple-blue/10 text-apple-blue"
: "border-apple-separator bg-apple-bg-secondary text-apple-label-secondary"
}`}
>
<span className="font-apple-semibold text-apple-label-primary">
{REFERENCE_ESTIMATOR_WORKSPACE_LABEL}
</span>
<span className="mt-1 text-[10px] leading-4 text-apple-label-tertiary">
上传参考图,按识别结果和大板价格输出样包模板明细。
</span>
</button>
<button type="button" onClick={() => { onOpenReferenceEstimatorWorkspace(); openEstimateSkillLibrary(); }} className="mt-2 flex w-full rounded-apple-lg border border-apple-separator px-3 py-2 text-left text-xs font-apple-semibold text-apple-label-primary">测算技能库</button>
</AccordionSection>
);
}

View File

@ -1,32 +0,0 @@
"use client";
import type { IntakeWorkspaceTab } from "@/app/intake/intakeWorkspaceTypes";
import { ReferenceEstimatorDomain } from "@/app/intake/reference-estimator/ReferenceEstimatorDomain";
import type { SubstrateDTO } from "@/server/services";
type ReferenceEstimatorWorkspaceTab = Extract<
IntakeWorkspaceTab,
{ kind: "referenceEstimator" }
>;
export function isReferenceEstimatorWorkspaceTab(
tab: IntakeWorkspaceTab,
): tab is ReferenceEstimatorWorkspaceTab {
return tab.kind === "referenceEstimator";
}
export function ReferenceEstimatorWorkspaceContent({
materialLibrarySubstrates,
userId,
}: {
activeWorkspaceTab: ReferenceEstimatorWorkspaceTab;
materialLibrarySubstrates: SubstrateDTO[];
userId: string;
}) {
return (
<ReferenceEstimatorDomain
materialLibrarySubstrates={materialLibrarySubstrates}
userId={userId}
/>
);
}

View File

@ -1,6 +1,5 @@
"use client";
import { useEffect, useRef } from "react";
import type {
IntakeClientWorkspaceViewProps,
} from "@/app/intake/IntakeClientWorkspaceView";
@ -22,8 +21,6 @@ import { useIntakeNonIntegratedProducts } from "@/app/intake/useIntakeNonIntegra
import { useIntakeWorkspaceActivation } from "@/app/intake/useIntakeWorkspaceActivation";
import { useInitialNewNonIntegratedProductWorkspace } from "@/app/intake/useInitialNewNonIntegratedProductWorkspace";
import { useIntakeInitialWorkspaceState } from "@/app/intake/useIntakeInitialWorkspaceState";
import { useIntakeMaterialLibraryFinishes } from "@/app/intake/useIntakeMaterialLibraryFinishes";
import { linkedReferenceEstimateId } from "@/app/intake/reference-estimator/referenceEstimateLinks";
import { buildIntakeClientDerivedData } from "@/app/intake/intakeClientDerivedData";
import { canCreateNonIntegratedProductFromIntake } from "@/lib/non-integrated-permissions";
import {
@ -59,10 +56,7 @@ export function useIntakeClientViewModel(
canViewSeriesDevelopmentList,
canViewProductProgressDashboard,
canViewStockDevelopmentList,
canViewBomLibrary,
canEditBomLibrary,
canViewRawMaterialLibrary,
canViewReferenceEstimator,
canViewProductPatentLedger,
canEditProductPatentLedger,
canViewProductPatentDashboard,
@ -78,8 +72,6 @@ export function useIntakeClientViewModel(
});
const { initialActiveWorkspaceTab, initialWorkspaceState } =
useIntakeInitialWorkspaceState(props);
const { materialLibraryFinishes, setMaterialLibraryFinishes } =
useIntakeMaterialLibraryFinishes(props.materialLibraryFinishes);
const {
selectedRawMaterialName,
seriesDraftSkuOptions,
@ -87,7 +79,6 @@ export function useIntakeClientViewModel(
skuList,
} = buildIntakeClientDerivedData(props);
const {
activeBomLibrary,
activeRawMaterialLibrary,
activeSection,
handleWorkspaceActivationStateChange,
@ -173,7 +164,6 @@ export function useIntakeClientViewModel(
closeNewNonIntegratedProductWorkspace,
openBarcodePrintWorkspace,
openBrandFilingWorkspace,
openBomLibraryWorkspace,
openNewNonIntegratedProductWorkspace,
openPendingEntryWorkspace,
openProductPatentDashboardWorkspace,
@ -183,7 +173,6 @@ export function useIntakeClientViewModel(
openProductWorkspace,
openProgressDashboardWorkspace,
openRawMaterialLibraryWorkspace,
openReferenceEstimatorWorkspace,
openSpuRuleLibraryWorkspace,
openWorkRecordWorkspace,
openWorkRecordScoreWorkspace,
@ -199,13 +188,11 @@ export function useIntakeClientViewModel(
canViewBrandFiling,
canViewWorkRecord,
canViewWorkRecordArchives,
canViewBomLibrary,
canViewFormalWorkspaceByTarget,
canViewProductPatentDashboard,
canViewProductPatentLedger,
canViewProductProgressDashboard,
canViewRawMaterialLibrary,
canViewReferenceEstimator,
createWorkspaceTabId,
markProductWorkspaceTabLoaded,
openWorkspaceTab,
@ -217,14 +204,6 @@ export function useIntakeClientViewModel(
user: props.user,
workspaceTabs,
});
const openedEstimateLink = useRef(false);
useEffect(() => {
if (!workspaceStateReady || !canViewReferenceEstimator || openedEstimateLink.current) return;
if (!linkedReferenceEstimateId(window.location.search)) return;
openedEstimateLink.current = true;
openReferenceEstimatorWorkspace();
}, [workspaceStateReady, canViewReferenceEstimator, openReferenceEstimatorWorkspace]);
useInitialNewNonIntegratedProductWorkspace({
canCreateNonIntegratedProducts,
initialOpenNewNonIntegratedProduct: props.initialOpenNewNonIntegratedProduct,
@ -253,18 +232,9 @@ export function useIntakeClientViewModel(
onProductsChange: handleScopedProductsChange,
onOpenProductWorkspace: openProductWorkspace,
onOpenNewProductWorkspace: openNewNonIntegratedProductWorkspace,
canViewBomLibrary,
canEditBomLibrary,
activeBomLibrary,
materialLibrarySubstrates: props.materialLibrarySubstrates,
materialLibraryFinishes,
materialLibraryCategories: props.materialLibraryCategories,
materialLibraryDictionaries: props.materialLibraryDictionaries,
onMaterialLibraryFinishesChange: setMaterialLibraryFinishes,
canViewRawMaterialLibrary,
activeRawMaterialLibrary,
selectedRawMaterialName,
canViewReferenceEstimator,
canViewProductPatentLedger,
canEditProductPatentLedger,
canViewBarcodePrint,
@ -272,11 +242,11 @@ export function useIntakeClientViewModel(
}),
workspace: buildIntakeWorkspacePanelProps({
workspaceTabs,
workspaceStateReady,
activeWorkspaceTabId,
activeWorkspaceTab,
user: props.user,
canManageSpuRuleLibrary: canManageSpuRules,
canEditBomLibrary,
canViewProductPatentLedger,
canEditProductPatentLedger,
canViewProductPatentDashboard,
@ -290,10 +260,7 @@ export function useIntakeClientViewModel(
existingSeriesNames,
existingSeriesComponentDetailNames,
seriesDraftSkuOptions,
materialLibrarySubstrates: props.materialLibrarySubstrates,
materialLibraryFinishes,
materialLibraryCategories: props.materialLibraryCategories,
materialLibraryDictionaries: props.materialLibraryDictionaries,
materialLibraryFinishes: props.materialLibraryFinishes,
selectedRawMaterialName,
nonIntegratedProducts,
productDevelopmentProgressProducts,
@ -307,7 +274,6 @@ export function useIntakeClientViewModel(
openRawMaterialLibraryWorkspace("processConfig", materialName),
onActivatePendingEntryListWorkspace: activatePendingEntryListWorkspace,
onCloseNewProductWorkspace: closeNewNonIntegratedProductWorkspace,
onMaterialLibraryFinishesChange: setMaterialLibraryFinishes,
onOpenWorkRecordArchiveDetailWorkspace: openWorkRecordArchiveDetailWorkspace,
onActivate: activateWorkspaceTab,
onClose: closeWorkspaceTab,
@ -320,21 +286,12 @@ export function useIntakeClientViewModel(
: null,
activeSection,
onToggle: (section) => {
if (section === "referenceEstimator") {
openReferenceEstimatorWorkspace();
return;
}
setActiveWorkspaceTabId(null);
toggleActiveSection(section);
},
pendingEntryTab,
onPendingEntryTabChange: openPendingEntryWorkspace,
onOpenProgressDashboard: openProgressDashboardWorkspace,
activeBomLibrary,
onBomLibraryChange: openBomLibraryWorkspace,
activeRawMaterialLibrary,
onOpenRawMaterialLibraryWorkspace: openRawMaterialLibraryWorkspace,
onOpenReferenceEstimatorWorkspace: openReferenceEstimatorWorkspace,
onOpenProductPatents: openProductPatents,
onOpenProductPatentLedger: openProductPatentLedgerWorkspace,
onOpenProductPatentDashboard: openProductPatentDashboardWorkspace,
@ -350,9 +307,6 @@ export function useIntakeClientViewModel(
canViewSeriesDevelopmentList,
canViewProductProgressDashboard,
canViewStockDevelopmentList,
canViewBomLibrary,
canViewRawMaterialLibrary,
canViewReferenceEstimator,
canViewProductPatentLedger,
canViewProductPatentDashboard,
canViewBarcodePrint,

View File

@ -1,17 +0,0 @@
"use client";
import { useState } from "react";
import type { MaterialDTO } from "@/server/services";
export function useIntakeMaterialLibraryFinishes(
initialMaterialLibraryFinishes: MaterialDTO[],
) {
const [materialLibraryFinishes, setMaterialLibraryFinishes] = useState<
MaterialDTO[]
>(() => initialMaterialLibraryFinishes);
return {
materialLibraryFinishes,
setMaterialLibraryFinishes,
};
}

View File

@ -5,7 +5,7 @@ import {
useEffect,
useState,
} from "react";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import type { BomLibraryKey } from "@/app/database/bom-library/BomLibraryDomain";
import type {
IntakeEntryTab,
IntakeSection,
@ -19,7 +19,7 @@ import {
} from "@/app/intake/intakeWorkspaceState";
import type {
RawMaterialLibraryKey,
} from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
} from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import { isSupplierAccount } from "@/lib/supplier-account";
import type { IntakeNonIntegratedPermissionUser } from "@/lib/non-integrated-permissions";

View File

@ -2,7 +2,6 @@
import { useCallback, type Dispatch, type SetStateAction } from "react";
import type { BrandFilingBrand } from "@/app/intake/brand-filing/brandFilingConfig";
import type { BomLibraryKey } from "@/app/intake/bom-library/BomLibraryDomain";
import type {
IntakeEntryTab,
IntakeSection,
@ -14,7 +13,6 @@ import type {
import {
createBarcodePrintWorkspaceTab,
createBrandFilingWorkspaceTab,
createBomLibraryWorkspaceTab,
createNewNonIntegratedProductWorkspaceTab,
createNonIntegratedProductWorkspaceTab,
createNonIntegratedProductWorkspaceTabForCurrentNode,
@ -23,7 +21,6 @@ import {
createProductPatentLedgerWorkspaceTab,
createProgressDashboardWorkspaceTab,
createRawMaterialLibraryWorkspaceTab,
createReferenceEstimatorWorkspaceTab,
createSpuRuleLibraryWorkspaceTab,
createWorkRecordArchiveWorkspaceTab,
createWorkRecordArchiveDetailWorkspaceTab,
@ -37,7 +34,7 @@ import {
getPendingEntryTabFromProductDevelopmentKind,
} from "@/app/intake/product-development/nonIntegratedProductIdentity";
import type { ProductPatentLedgerTarget } from "@/app/intake/product-patent/ProductPatentDomain";
import type { RawMaterialLibraryKey } from "@/app/intake/raw-material-library/RawMaterialLibraryDomain";
import type { RawMaterialLibraryKey } from "@/app/database/raw-material-library/RawMaterialLibraryDomain";
import type { IntakeNodePermissionTargetKey } from "@/lib/intake-node-permission-settings";
import type { IntakeNonIntegratedPermissionUser } from "@/lib/non-integrated-permissions";
@ -50,7 +47,6 @@ type WorkspaceOpenersParams = {
canViewBrandFiling: boolean;
canViewWorkRecord: boolean;
canViewWorkRecordArchives: boolean;
canViewBomLibrary: boolean;
canViewFormalWorkspaceByTarget: (
targetKey: IntakeNodePermissionTargetKey,
) => boolean;
@ -58,7 +54,6 @@ type WorkspaceOpenersParams = {
canViewProductPatentLedger: boolean;
canViewProductProgressDashboard: boolean;
canViewRawMaterialLibrary: boolean;
canViewReferenceEstimator: boolean;
createWorkspaceTabId: (prefix: string, key: string) => string;
markProductWorkspaceTabLoaded: (tabId: string) => void;
openWorkspaceTab: (nextTab: IntakeWorkspaceTab) => void;
@ -80,13 +75,11 @@ export function useIntakeWorkspaceOpeners({
canViewBrandFiling,
canViewWorkRecord,
canViewWorkRecordArchives,
canViewBomLibrary,
canViewFormalWorkspaceByTarget,
canViewProductPatentDashboard,
canViewProductPatentLedger,
canViewProductProgressDashboard,
canViewRawMaterialLibrary,
canViewReferenceEstimator,
createWorkspaceTabId,
markProductWorkspaceTabLoaded,
openWorkspaceTab,
@ -342,22 +335,6 @@ export function useIntakeWorkspaceOpeners({
[createWorkspaceTabId, setWorkspaceTabs, syncWorkspaceState, workspaceTabs],
);
const openBomLibraryWorkspace = useCallback(
(library: BomLibraryKey) => {
if (!canViewBomLibrary) {
return;
}
openWorkspaceTab(
createBomLibraryWorkspaceTab(
createWorkspaceTabId("bom-library", library),
library,
),
);
},
[canViewBomLibrary, createWorkspaceTabId, openWorkspaceTab],
);
const openRawMaterialLibraryWorkspace = useCallback(
(library: RawMaterialLibraryKey, selectedMaterialName?: string) => {
if (!canViewRawMaterialLibrary) {
@ -381,18 +358,6 @@ export function useIntakeWorkspaceOpeners({
[canViewRawMaterialLibrary, createWorkspaceTabId, openWorkspaceTab],
);
const openReferenceEstimatorWorkspace = useCallback(() => {
if (!canViewReferenceEstimator) {
return;
}
openWorkspaceTab(
createReferenceEstimatorWorkspaceTab(
createWorkspaceTabId("reference-estimator", "reference-image-cost"),
),
);
}, [canViewReferenceEstimator, createWorkspaceTabId, openWorkspaceTab]);
const openProductPatentDashboardWorkspace = useCallback(() => {
if (!canViewProductPatentDashboard) {
return;
@ -527,7 +492,6 @@ export function useIntakeWorkspaceOpeners({
closeNewNonIntegratedProductWorkspace,
openBarcodePrintWorkspace,
openBrandFilingWorkspace,
openBomLibraryWorkspace,
openNewNonIntegratedProductWorkspace,
openPendingEntryWorkspace,
openProductPatentDashboardWorkspace,
@ -537,7 +501,6 @@ export function useIntakeWorkspaceOpeners({
openProductWorkspace,
openProgressDashboardWorkspace,
openRawMaterialLibraryWorkspace,
openReferenceEstimatorWorkspace,
openSpuRuleLibraryWorkspace,
openWorkRecordWorkspace,
openWorkRecordScoreWorkspace,

View File

@ -0,0 +1,21 @@
import { redirect } from 'next/navigation'
import { getIntakeLibraryAccess } from '@/lib/intake-library-access'
import { requireSession } from '@/lib/server-session'
import { assetCenterService } from '@/server/services/asset-center.service'
import { intakeNodePermissionSettingsService } from '@/server/services/intake-node-permission-settings.service'
import { ReferenceEstimatorDomain } from './ReferenceEstimatorDomain'
export const metadata = { title: '预估成本测算' }
export default async function ReferenceEstimatorPage() {
const { authUser } = await requireSession()
const { overrides } = await intakeNodePermissionSettingsService.getSettings()
if (!getIntakeLibraryAccess(authUser, overrides, 'referenceEstimator').canView) redirect('/intake')
const substrates = await assetCenterService.listSubstrates()
return (
<section aria-label="预估成本测算" className="h-full min-h-0 overflow-auto p-3 md:p-4">
<ReferenceEstimatorDomain materialLibrarySubstrates={substrates} userId={authUser.id} />
</section>
)
}

View File

@ -1,9 +1,11 @@
import { REFERENCE_ESTIMATOR_PATH } from '@/config/intake-library-navigation'
const estimateQuery = 'estimateId'
const productLibraryPath = '/intake/product-library'
export const referenceEstimateWorkspaceKey = 'reference-estimator'
export function referenceEstimateHref(id: string) {
return '/intake?' + new URLSearchParams({ [estimateQuery]: id })
return REFERENCE_ESTIMATOR_PATH + '?' + new URLSearchParams({ [estimateQuery]: id })
}
export function linkedReferenceEstimateId(search: string) {

View File

@ -20,6 +20,7 @@ import { StandardSamplingPanel } from './StandardSamplingPanel'
import { useReferenceImagePaste } from './reference-image-paste'
import { readWorkspacePosition, writeWorkspacePosition } from '@/lib/workspace-session-state'
import { referenceEstimateWorkspaceKey } from '../referenceEstimateLinks'
import { openEstimateSkillLibrary } from '../skill-library-events'
const stages = [['model','1 模型'],['sampling','2 打样资料'],['packing','3 包装'],['cost','4 成本明细']] as const
type Stage = typeof stages[number][0]
@ -48,6 +49,7 @@ export function StandardEstimator({substrates,userId}:{substrates:SubstrateDTO[]
<input aria-label="测算单名称" value={c.document.title} disabled={Boolean(c.busy)} onChange={e=>c.title(e.target.value)}/>
<select aria-label="打开已保存测算单" value={c.record?.id??''} disabled={Boolean(c.busy)} onChange={e=>{if(e.target.value)void c.open(e.target.value)}}><option value="">打开已保存测算单</option>{c.records.map(r=><option key={r.id} value={r.id}>{r.title}</option>)}</select>
<Button size="small" onClick={()=>void c.save()} disabled={Boolean(c.busy)}>保存</Button>
<Button size="small" variant="gray" onClick={() => openEstimateSkillLibrary()}>测算技能库</Button>
<span title={!c.record||c.dirty?'请先保存测算单':undefined}>
<Button type="button" size="small" variant="gray" disabled={!c.record||c.dirty||Boolean(c.busy)} onClick={()=>void c.pushToProductLibrary()}>
<Send size={14} aria-hidden="true"/>推送到产品资料

Some files were not shown because too many files have changed in this diff Show More