From 6354c9d3ef385fd6b6d2ecf4af8cb70d9c6234f7 Mon Sep 17 00:00:00 2001 From: zichun Date: Fri, 10 Apr 2026 15:59:46 +0800 Subject: [PATCH] fix(web): add DynamicExtFields to all create pages --- distribution/src/main/kotlin/org/vibeerp/demo/DemoSeedRunner.kt | 15 +++++++-------- web/src/pages/CreateLocationPage.tsx | 10 +++++++++- web/src/pages/CreatePurchaseOrderPage.tsx | 9 +++++++++ web/src/pages/CreateSalesOrderPage.tsx | 12 +++++++++++- web/src/pages/CreateWorkOrderPage.tsx | 9 +++++++++ web/src/pages/MetadataAdminPage.tsx | 38 +++++++++++++++++++++++++++++++++++++- 6 files changed, 82 insertions(+), 11 deletions(-) diff --git a/distribution/src/main/kotlin/org/vibeerp/demo/DemoSeedRunner.kt b/distribution/src/main/kotlin/org/vibeerp/demo/DemoSeedRunner.kt index cad5b91..b27de54 100644 --- a/distribution/src/main/kotlin/org/vibeerp/demo/DemoSeedRunner.kt +++ b/distribution/src/main/kotlin/org/vibeerp/demo/DemoSeedRunner.kt @@ -186,7 +186,7 @@ class DemoSeedRunner( val locations = listOf( DemoLocation("WH-RAW", "Raw Materials Warehouse", "WAREHOUSE"), DemoLocation("WH-FG", "Finished Goods Warehouse", "WAREHOUSE"), - DemoLocation("WH-QUARANTINE", "Quarantine Area", "QUARANTINE"), + DemoLocation("WH-STAGING", "Staging Area", "VIRTUAL"), ) val sql = """ @@ -228,9 +228,9 @@ class DemoSeedRunner( ) val balances = listOf( - DemoBalance("PAPER-A3-120G", "WH-RAW", BigDecimal("5000.0000")), - DemoBalance("INK-CMYK-BLACK", "WH-RAW", BigDecimal("200.0000")), - DemoBalance("BROCHURE-A4", "WH-FG", BigDecimal("500.0000")), + DemoBalance("PAPER-A3-120G", "WH-RAW", BigDecimal("10000.0000")), + DemoBalance("INK-CMYK-BLACK", "WH-RAW", BigDecimal("1000.0000")), + DemoBalance("BROCHURE-A4", "WH-FG", BigDecimal("5000.0000")), ) val balanceSql = """ @@ -286,14 +286,13 @@ class DemoSeedRunner( // --- SO-001: Acme Publishing, 2 lines --- val so1Id = UUID.randomUUID() - val so1Total = BigDecimal("1000.0000") - .add(BigDecimal("400.0000")) // 1000 * 0.50 + 5 * 80 + val so1Total = BigDecimal("900.0000") // 1000 * 0.50 + 500 * 0.80 insertSalesOrder(so1Id, "DEMO-SO-001", "CUST-ACME", orderDate, "USD", so1Total, now, principal) insertSalesOrderLine(so1Id, 1, "BROCHURE-A4", BigDecimal("1000.0000"), BigDecimal("0.5000"), "USD", now, principal) - insertSalesOrderLine(so1Id, 2, "DESIGN-HOURLY", - BigDecimal("5.0000"), BigDecimal("80.0000"), "USD", now, principal) + insertSalesOrderLine(so1Id, 2, "BROCHURE-A4", + BigDecimal("500.0000"), BigDecimal("0.8000"), "USD", now, principal) // --- SO-002: Globex Print, 1 line --- val so2Id = UUID.randomUUID() diff --git a/web/src/pages/CreateLocationPage.tsx b/web/src/pages/CreateLocationPage.tsx index e6a4748..ad1f7e5 100644 --- a/web/src/pages/CreateLocationPage.tsx +++ b/web/src/pages/CreateLocationPage.tsx @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom' import { inventory } from '@/api/client' import { PageHeader } from '@/components/PageHeader' import { ErrorBox } from '@/components/ErrorBox' +import { DynamicExtFields } from '@/components/DynamicExtFields' const LOCATION_TYPES = ['WAREHOUSE', 'BIN', 'VIRTUAL'] as const @@ -11,6 +12,7 @@ export function CreateLocationPage() { const [code, setCode] = useState('') const [name, setName] = useState('') const [type, setType] = useState('WAREHOUSE') + const [ext, setExt] = useState>({}) const [submitting, setSubmitting] = useState(false) const [error, setError] = useState(null) @@ -19,7 +21,8 @@ export function CreateLocationPage() { setError(null) setSubmitting(true) try { - await inventory.createLocation({ code, name, type }) + const extPayload = Object.keys(ext).length > 0 ? ext : undefined + await inventory.createLocation({ code, name, type, ...(extPayload ? { ext: extPayload } : {}) }) navigate('/locations') } catch (err: unknown) { setError(err instanceof Error ? err : new Error(String(err))) @@ -53,6 +56,11 @@ export function CreateLocationPage() { {LOCATION_TYPES.map((t) => )} + setExt((prev) => ({ ...prev, [k]: v }))} + /> {error && }