From 700bc826092e4084d873a60f21ba2df11f0dba7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=81=A5=E9=93=AD?= Date: Fri, 4 Dec 2026 20:07:46 -0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E7=89=88=E5=BC=80=E5=8D=95=E9=A1=B5?= =?UTF-8?q?=EF=BC=9A=E7=BC=96=E5=8F=B7=E5=88=86=E5=8C=BA=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E3=80=81=E5=86=85=E9=83=A8=E5=8C=BA=E5=9F=9F=E9=87=91=E8=89=B2?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E3=80=81=E5=93=8D=E5=BA=94=E5=BC=8F=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=E3=80=81=E5=B8=B8=E7=94=A8=E6=88=90=E6=9C=AC=E5=8B=BE?= =?UTF-8?q?=E9=80=89=E5=8D=A1=E7=89=87=E3=80=81=E5=BA=95=E9=83=A8=E5=B8=B8?= =?UTF-8?q?=E9=A9=BB=E5=90=88=E8=AE=A1=E6=A0=8F=E4=B8=8E=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../web/src/pages/CreateOrder/ChargeList.tsx | 22 ++- .../web/src/pages/CreateOrder/CreateOrderPage.tsx | 23 +-- .../web/src/pages/CreateOrder/CustomerSection.tsx | 41 ++++-- .../web/src/pages/CreateOrder/FeeCosts.tsx | 122 +++++++++------- .../web/src/pages/CreateOrder/InternalCosts.tsx | 78 +++++++---- .../web/src/pages/CreateOrder/IssuedResult.tsx | 128 +++++++++-------- .../web/src/pages/CreateOrder/LineItems.tsx | 91 +++++++++--- .../web/src/pages/CreateOrder/Section.tsx | 44 ++++++ .../web/src/pages/CreateOrder/SummarySection.tsx | 131 +++++++++++------- 新账系统/web/src/pages/CreateOrder/fields.tsx | 74 ++++++++-- .../web/src/pages/CreateOrder/invalidField.ts | 79 +++++++++++ 新账系统/web/src/pages/CreateOrder/layout.ts | 10 ++ 12 files changed, 605 insertions(+), 238 deletions(-) create mode 100644 新账系统/web/src/pages/CreateOrder/Section.tsx create mode 100644 新账系统/web/src/pages/CreateOrder/invalidField.ts create mode 100644 新账系统/web/src/pages/CreateOrder/layout.ts diff --git a/新账系统/web/src/pages/CreateOrder/ChargeList.tsx b/新账系统/web/src/pages/CreateOrder/ChargeList.tsx index 13b6042..6ffa474 100644 --- a/新账系统/web/src/pages/CreateOrder/ChargeList.tsx +++ b/新账系统/web/src/pages/CreateOrder/ChargeList.tsx @@ -1,8 +1,9 @@ import { Button } from 'antd'; +import { CloseOutlined, PlusOutlined } from '@ant-design/icons'; import { Model } from '../../shared'; import type { ChargeState, LineState, OrderForm } from '../../shared'; import { uuid } from './useOrderForm'; -import { ChoiceField, TextField } from './fields'; +import { ChoiceField, Help, TextField } from './fields'; type Update = (change: (form: OrderForm) => OrderForm) => void; @@ -19,19 +20,24 @@ export function ChargeList({ index, line, update }: { index: number; line: LineS }); return (
-
- 工费附加项目(选填) +
+
+ 工费附加项目 + 选填 · 编绳、证书、包装、快递 + + 向客户收费预填:编绳55元、证书10元、包装10元、快递8元,均可修改;按填写金额自动加进本行销售额。 + +
-

- 向客户收费预填:编绳55元、证书10元、包装10元、快递8元,均可修改;按填写金额自动加进本行销售额。 -

+ {line.charges.length > 0 && (
{line.charges.map((charge, j) => (
@@ -62,6 +68,7 @@ export function ChargeList({ index, line, update }: { index: number; line: LineS
))}
+ )}
); } diff --git a/新账系统/web/src/pages/CreateOrder/CreateOrderPage.tsx b/新账系统/web/src/pages/CreateOrder/CreateOrderPage.tsx index c74d3ec..94eb3fa 100644 --- a/新账系统/web/src/pages/CreateOrder/CreateOrderPage.tsx +++ b/新账系统/web/src/pages/CreateOrder/CreateOrderPage.tsx @@ -1,5 +1,6 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { Alert, App as AntApp, Button, Spin, Typography } from 'antd'; +import { ClearOutlined } from '@ant-design/icons'; import type { ApiError, LedgerClient, PendingJob } from '../../lib/api'; import { clearDraft, loadDraft } from '../../lib/drafts'; import { searchParam } from '../../lib/router'; @@ -10,7 +11,8 @@ import { useOrderForm } from './useOrderForm'; import { CustomerSection } from './CustomerSection'; import { LineItems } from './LineItems'; import { FeeCosts } from './FeeCosts'; -import { SummarySection } from './SummarySection'; +import { SubmitBar, SummarySection } from './SummarySection'; +import { focusInvalidField } from './invalidField'; import { EntryTools } from './EntryTools'; import { IssuedResult, type IssuedOrder } from './IssuedResult'; @@ -80,6 +82,7 @@ function CreateOrderForm({ const [tagsStatus, setTagsStatus] = useState('正在读取快捷标签…'); const busy = client.busy; const pending = client.pending(); + const formRef = useRef(null); // 纸单号预览(旧页面 updatePaperNumber):旧草稿沿用原号(换日期时替换日期段),新单读取预计号码。 const [preview, setPreview] = useState<{ date: string; number: string } | null>(null); @@ -126,6 +129,7 @@ function CreateOrderForm({ if (e.code === 'ACCOUNT_CHANGED') setAccountChanged(true); setError(e.message); message.error(e.message); + focusInvalidField(formRef.current, e.message); }, [message], ); @@ -198,14 +202,11 @@ function CreateOrderForm({
-
NEW ORDER · 新版界面
- 开一张新单 - - 开单即交付,一次记录全额收款、实际费用、出库和利润。订单列表、报表等其他功能请 - 返回旧版界面。 - +
New Order · 新版界面
+ 开一张新单 + 开单即交付,一次记录全额收款、实际费用、出库和利润。
-
@@ -249,6 +250,7 @@ function CreateOrderForm({ />
{ @@ -268,14 +270,13 @@ function CreateOrderForm({ message.error(text)} /> +
diff --git a/新账系统/web/src/pages/CreateOrder/CustomerSection.tsx b/新账系统/web/src/pages/CreateOrder/CustomerSection.tsx index 6d63433..c6e98c5 100644 --- a/新账系统/web/src/pages/CreateOrder/CustomerSection.tsx +++ b/新账系统/web/src/pages/CreateOrder/CustomerSection.tsx @@ -1,7 +1,10 @@ -import { Card, Typography } from 'antd'; +import { Row } from 'antd'; +import { CloudSyncOutlined } from '@ant-design/icons'; import { Model } from '../../shared'; import type { LedgerState, OrderForm } from '../../shared'; import { ChoiceField, RadioField, TextField } from './fields'; +import { HALF_Q, QUARTER } from './layout'; +import { Section } from './Section'; // 客户与单据:业务日期、纸单号、客户、客户类型、开单人、订单归属、收款方式与收款人。 export function CustomerSection({ @@ -19,19 +22,29 @@ export function CustomerSection({ const team = Model.teamMode(state); const card = form.payment.method === '信用卡'; return ( - + + } > -
- - + + + {team && (form.memberLocked ? ( - + ) : ( ))} update(f => ({ ...f, payment: { ...f.payment, method } }))} /> update(f => ({ ...f, payment: { ...f.payment, recipient } }))} /> -
- - 纸单号前半段为业务日期,后半段序号持续累计,中间不加横线,换日期不归零;生成时分配。生成单据即按成交合计记录全额收款,同时按所选货盘扣减黄金库存并计入实际利润。请核对商品已交付,选择实际收款方式与收款人;业务日期作为收款和出库日期。 - -
+ + ); } diff --git a/新账系统/web/src/pages/CreateOrder/FeeCosts.tsx b/新账系统/web/src/pages/CreateOrder/FeeCosts.tsx index 4ee02d6..22f72c5 100644 --- a/新账系统/web/src/pages/CreateOrder/FeeCosts.tsx +++ b/新账系统/web/src/pages/CreateOrder/FeeCosts.tsx @@ -1,8 +1,11 @@ -import { Button, Card, Checkbox, Input } from 'antd'; +import { Button, Checkbox, Input, Row } from 'antd'; +import { CloseOutlined, PlusOutlined } from '@ant-design/icons'; import { Model } from '../../shared'; import type { FormSummary, LedgerState, OrderForm } from '../../shared'; import { uuid } from './useOrderForm'; import { ChoiceField, Field, TextField } from './fields'; +import { HALF, QUARTER } from './layout'; +import { Section } from './Section'; type Update = (change: (form: OrderForm) => OrderForm) => void; @@ -21,61 +24,84 @@ export function FeeCosts({ const presets = form.presets; const catalog = Model.presetCatalogView(form, state); const defaults = { certificate: '4', packaging: '3', shipping: '6', ...state.shopSettings?.feeDefaults }; + const help = presets + ? '按实际发生勾选,快递最多选一项;盒子按配置单价和数量计费。取消勾选不记成本,客户收费不受影响。' + : form.feeCostMode === 'checkboxes' + ? '沿用本单已有费用、付款人与支付日期。普通费用按凭据核对;信用卡手续费金额和日期自动维护。' + : `上方附加项目自动带入成本。证书默认${defaults.certificate}元、包装${defaults.packaging}元;快递按整单默认${defaults.shipping}元,均可修改。请填写实际已付金额,没有成本填0;不需要的整单费用可移除。开单时记录费用和付款人。`; return ( - update(f => Model.addManualFee(f, state, uuid))}> - + 添加其他成本 + } > -

- {presets - ? '按实际发生勾选,快递最多选一项;盒子按配置单价和数量计费。取消勾选不记成本,客户收费不受影响。' - : form.feeCostMode === 'checkboxes' - ? '沿用本单已有费用、付款人与支付日期。普通费用按凭据核对;信用卡手续费金额和日期自动维护。' - : `上方附加项目自动带入成本。证书默认${defaults.certificate}元、包装${defaults.packaging}元;快递按整单默认${defaults.shipping}元,均可修改。请填写实际已付金额,没有成本填0;不需要的整单费用可移除。开单时记录费用和付款人。`}{' '} - 客户单据不显示。 -

-
+ {!presets &&

{help}

} + update(f => ({ ...f, fees_date: value }))} /> -
+ {presets && (
- 常用成本 · 按实际发生勾选 -

快递二选一,也可不选;取消勾选不记成本。

+ + 常用成本 按实际发生勾选 · 快递二选一,也可不选 +
- {catalog.length === 0 &&

暂无启用的勾选成本,可在店铺配置中添加。

} - {catalog.map(item => ( -
- update(f => Model.togglePreset(f, item.kind, event.target.checked, state, uuid))} - > - {item.name} {item.price} - {item.kind === 'yt' && !presets.configured ? summary.presetNotes.ytPayer : item.payer} - - {item.byQuantity && ( - - update(f => Model.setPresetQuantity(f, item.kind, event.target.value))} - /> - - )} -
- ))} + {catalog.length === 0 &&

暂无启用的勾选成本,可在店铺配置中添加。

} + {catalog.map(item => { + const checked = !!presets.checked[item.kind]; + return ( +
+ update(f => Model.togglePreset(f, item.kind, event.target.checked, state, uuid))} + > + + {item.name} + {item.price} + + + {item.kind === 'yt' && !presets.configured ? summary.presetNotes.ytPayer : item.payer} + + + {item.byQuantity && checked && ( + + update(f => Model.setPresetQuantity(f, item.kind, event.target.value))} + /> + + )} +
+ ); + })}
)} @@ -116,6 +142,7 @@ export function FeeCosts({ -
+ )} - -

{line.pool.help}

+ {pooled && line.view.poolNote && (

{line.view.poolNote} @@ -96,9 +110,10 @@ export function InternalCosts({ )} )} -

+ {v.materialMode && ( )} {v.materialPayer ? ( ) : ( )} -
+

{line.view.materialFormula}

{line.view.materialOriginal &&

{line.view.materialOriginal}

} -
+ -
+

{line.view.laborFormula}

{v.extraCosts && (

这里保留原来填写的货品成本,不要在下方实际费用重复登记。

-
+ setLine(l => ({ ...l, payer: value }))} /> -
+
)} -

- 本行货品成本合计: - {line.view.purchase?.total == null - ? pooled - ? '料费待核算' - : '请补齐(没有的项目填0)' - : '¥' + Model.yuan(line.view.purchase.total)} +

+ 本行货品成本合计 + + {line.view.purchase?.total == null + ? pooled + ? '料费待核算' + : '请补齐(没有的项目填0)' + : '¥' + Model.yuan(line.view.purchase.total)} +

) diff --git a/新账系统/web/src/pages/CreateOrder/IssuedResult.tsx b/新账系统/web/src/pages/CreateOrder/IssuedResult.tsx index f0a3417..0122e13 100644 --- a/新账系统/web/src/pages/CreateOrder/IssuedResult.tsx +++ b/新账系统/web/src/pages/CreateOrder/IssuedResult.tsx @@ -1,4 +1,5 @@ -import { Button, Result, Space, Typography } from 'antd'; +import { Button, Card, Result, Space, Typography } from 'antd'; +import { FileTextOutlined, PlusOutlined, PrinterOutlined } from '@ant-design/icons'; import { orderAmount } from '../../lib/format'; export interface IssuedOrder { @@ -25,61 +26,76 @@ export function IssuedResult({ }) { const loaded = order.total !== undefined; return ( - - {loaded && ( -
-
- 纸单号 -
- {order.paper_number || '未分配'} -
-
-
- 成交合计 -
- {orderAmount(order.total ?? null, order.rounding_mode || 'cent')} -
-
- {order.customer && ( -
- 客户 -
{order.customer}
-
+
+ + + {loaded && ( +
+
+
+ 纸单号 +
+
+ {order.paper_number || '未分配'} +
+
+
+
+ 成交合计 +
+
+ {orderAmount(order.total ?? null, order.rounding_mode || 'cent')} +
+
+ {order.customer && ( +
+
+ 客户 +
+
{order.customer}
+
+ )} +
)} -
- )} - - - - {!loaded && } - - - - } - /> +
+ + + {!loaded && ( + + )} +
+ + + } + /> + +
); } diff --git a/新账系统/web/src/pages/CreateOrder/LineItems.tsx b/新账系统/web/src/pages/CreateOrder/LineItems.tsx index 9a535eb..c788079 100644 --- a/新账系统/web/src/pages/CreateOrder/LineItems.tsx +++ b/新账系统/web/src/pages/CreateOrder/LineItems.tsx @@ -1,10 +1,16 @@ -import { Button, Card, Typography } from 'antd'; +import { Button, Col, Row, Typography } from 'antd'; +import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; import { Model } from '../../shared'; import type { LedgerState, LineState, OrderForm } from '../../shared'; import { uuid } from './useOrderForm'; import { ChoiceField, RadioField, TextField } from './fields'; import { ChargeList } from './ChargeList'; import { InternalCosts } from './InternalCosts'; +import { HALF, HALF_Q, QUARTER, type Span } from './layout'; +import { Section } from './Section'; + +const PRICING: Span = { xs: 24, sm: 12, xl: 8 }; +const UNIT: Span = { xs: 12, sm: 12, xl: 4 }; type Update = (change: (form: OrderForm) => OrderForm) => void; @@ -30,7 +36,12 @@ export function LineItems({ } }; return ( - 金价与工费分开填写}> +
共 {form.lines.length} 件商品} + > {form.lines.map((line, index) => ( ))}
- - 银饰不扣黄金货盘;外配使用店内金料时,选实际出库货盘。 + 银饰不扣黄金货盘;外配用店内金料时选实际出库货盘。
- +
); } @@ -80,13 +96,25 @@ function LineCard({ return (
- 商品 {String(index + 1).padStart(2, '0')} -
-
+
-
+ + +
+ -
- - - {line.view.calculation} - -
+ + + + + {line.view.calculation} + + +
); diff --git a/新账系统/web/src/pages/CreateOrder/Section.tsx b/新账系统/web/src/pages/CreateOrder/Section.tsx new file mode 100644 index 0000000..276ee91 --- /dev/null +++ b/新账系统/web/src/pages/CreateOrder/Section.tsx @@ -0,0 +1,44 @@ +import type { ReactNode } from 'react'; +import { Card } from 'antd'; +import { Help, InternalTag } from './fields'; + +// 开单页分区卡片:编号(沿用旧界面 01 02… 的样式)、标题、可选说明与右侧操作;内部分区用金色左边框与暖色底。 +export function Section({ + step, + title, + help, + extra, + internal, + className, + testId, + children, +}: { + step: string; + title: ReactNode; + help?: ReactNode; + extra?: ReactNode; + internal?: boolean; + className?: string; + testId?: string; + children: ReactNode; +}) { + return ( + + +

{title}

+ {help ? {help} : null} + {internal ? : null} + + } + extra={extra} + > + {children} +
+ ); +} diff --git a/新账系统/web/src/pages/CreateOrder/SummarySection.tsx b/新账系统/web/src/pages/CreateOrder/SummarySection.tsx index 502dc0b..5666b29 100644 --- a/新账系统/web/src/pages/CreateOrder/SummarySection.tsx +++ b/新账系统/web/src/pages/CreateOrder/SummarySection.tsx @@ -1,76 +1,76 @@ -import { Alert, Button, Card, Input } from 'antd'; +import { Alert, Button, Input, Row } from 'antd'; +import { CheckOutlined, LockOutlined } from '@ant-design/icons'; import { Model } from '../../shared'; import type { FormSummary, OrderForm } from '../../shared'; import { TextField, Field } from './fields'; +import { Section } from './Section'; type Update = (change: (form: OrderForm) => OrderForm) => void; -// 整单优惠、客户单备注、内部备注(快捷标签)、成交合计与提交。 +// 整单优惠、客户单备注、内部备注(快捷标签)。 export function SummarySection({ form, - summary, tags, tagsStatus, busy, - error, update, onError, }: { form: OrderForm; - summary: FormSummary; tags: string[]; tagsStatus: string; busy: boolean; - error: string; update: Update; onError: (message: string) => void; }) { const shown = Model.filterNoteTags(tags, form.internal_note); const query = /(?:^|[\s,。;、])#([\p{L}\p{N}_-]*)$/u.test(form.internal_note); return ( - -
+
+ update(f => ({ ...f, discount: value }))} /> - + update(f => ({ ...f, note: event.target.value }))} /> -
- - 内部备注(客户不可见)必填,至少3个字符(含#号),最多500字 - - } - field="internal_note" - > - update(f => ({ ...f, internal_note: event.target.value }))} - /> - -
-

- 输入 #词语 添加标签,例如 #补货、#客户自提。保存订单后可复用,点击下方标签即可填入。 -

+ +
+ +
{tagsStatus ? ( {tagsStatus} @@ -79,6 +79,7 @@ export function SummarySection({
-
-
- 成交合计 -
- {summary.totalText} -
-
- {summary.roundingHint} -
-
- -
+ + ); +} + +// 底部常驻操作栏:成交合计(大号等宽数字)、取整说明、整单优惠与“生成销售单据”。桌面与手机都贴在视口底部。 +export function SubmitBar({ + form, + summary, + busy, + error, +}: { + form: OrderForm; + summary: FormSummary; + busy: boolean; + error: string; +}) { + const discount = String(form.discount).trim(); + const discountCents = /^\d+(?:\.\d{1,2})?$/.test(discount) ? Math.round(Number(discount) * 100) : 0; + return ( +
{error && ( )} - +
+
+ 成交合计 +
+ {summary.totalText} +
+
+
+ + {form.lines.length} 件商品 + {discountCents > 0 ? <> · 整单优惠 −¥{Model.yuan(discountCents)} : null} + + + {summary.roundingHint} + +
+ +
+
); } diff --git a/新账系统/web/src/pages/CreateOrder/fields.tsx b/新账系统/web/src/pages/CreateOrder/fields.tsx index a622fdc..7beba0d 100644 --- a/新账系统/web/src/pages/CreateOrder/fields.tsx +++ b/新账系统/web/src/pages/CreateOrder/fields.tsx @@ -1,24 +1,67 @@ // 表单小部件:带标签的文本、数字、选择与单选。每个字段外层带 data-field,便于核对与自动化操作。 -import type { ReactNode } from 'react'; -import { Input, Radio, Select } from 'antd'; +// 传入 span 时字段包在 antd Col 里,由外层 Row 排成响应式网格;标签通过 htmlFor / aria-labelledby 与控件关联。 +import { useId, type ReactNode } from 'react'; +import { Col, Input, Radio, Select, Tooltip } from 'antd'; +import type { Span } from './layout'; +import { LockOutlined, QuestionCircleOutlined } from '@ant-design/icons'; + +// “?”说明:悬停、聚焦或点按显示。长说明放这里,页面上只留必要文字。 +export function Help({ children, label = '查看说明' }: { children: ReactNode; label?: string }) { + return ( + + + + + + ); +} +// 内部区域标记:客户单据和打印件中不出现。 +export function InternalTag() { + return ( + + + ); +} interface Base { label: ReactNode; field: string; hint?: ReactNode; + help?: ReactNode; hidden?: boolean; className?: string; + span?: Span; } -export function Field({ label, field, hint, hidden, className, children }: Base & { children: ReactNode }) { +export function Field({ + label, + field, + hint, + help, + hidden, + className, + span, + id, + labelId, + children, +}: Base & { children: ReactNode; id?: string; labelId?: string }) { if (hidden) return null; - return ( + const body = (
- +
+ + {help ? {help} : null} +
{children} {hint ?
{hint}
: null}
); + return span ? {body} : body; } +const ariaLabel = (base: Base) => (typeof base.label === 'string' ? base.label : base.field); + export function TextField({ value, onChange, @@ -39,11 +82,13 @@ export function TextField({ maxLength?: number; type?: string; }) { + const id = useId(); return ( - + onChange?.(event.target.value)} /> @@ -72,10 +117,12 @@ export function ChoiceField({ disabled?: boolean; placeholder?: string; }) { + const id = useId(); return ( - +