第6项:统一业务控件、主题与移动布局,保留原生输入和焦点契约
This commit is contained in:
1 parent
ff8b05973a
commit
f30905b236
74 files changed
+3567
-2443
No files matched your search
@@ -17,12 +17,13 @@ type TextKey<T> = { [K in keyof T]-?: T[K] extends string ? K : never }[keyof T]
|
||||
|
||||
import { Fees, Model } from '../../shared';
|
||||
import { uuid } from '../CreateOrder/useOrderForm';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
|
||||
export function Input({ label, name, value, type = 'text', hidden, help, onChange, ...props }: InputProps) {
|
||||
return (
|
||||
<label hidden={hidden}>
|
||||
{label}
|
||||
<input
|
||||
<LedgerInput
|
||||
{...props}
|
||||
name={name}
|
||||
type={type}
|
||||
@@ -38,7 +39,7 @@ export function Choice({ label, name, value, options, hidden, help, onChange, ..
|
||||
return (
|
||||
<label hidden={hidden}>
|
||||
{label}
|
||||
<select
|
||||
<LedgerSelect
|
||||
{...props}
|
||||
name={name}
|
||||
value={value ?? ''}
|
||||
@@ -53,7 +54,7 @@ export function Choice({ label, name, value, options, hidden, help, onChange, ..
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
{help}
|
||||
</label>
|
||||
);
|
||||
@@ -111,7 +112,7 @@ export function EditLine({
|
||||
<div className="line-item" data-legacy={line.legacy}>
|
||||
<div className="panel-title">
|
||||
<h3>商品 {index + 1}</h3>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="remove-line"
|
||||
onClick={() => {
|
||||
@@ -123,7 +124,7 @@ export function EditLine({
|
||||
}}
|
||||
>
|
||||
移除
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div className="grid four">
|
||||
<Choice label="商品名称" {...prop('nameType')} options={[...Model.productNames, '其他']} />
|
||||
@@ -163,9 +164,13 @@ export function EditLine({
|
||||
<div className="sale-charges">
|
||||
<div className="panel-title">
|
||||
<strong>工费附加项目(选填)</strong>
|
||||
<button type="button" data-action="add-charge" onClick={() => update(f => Model.addCharge(f, index, uuid))}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="add-charge"
|
||||
onClick={() => update(f => Model.addCharge(f, index, uuid))}
|
||||
>
|
||||
+ 添加附加项目
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
{line.charges.map((c, i) => (
|
||||
<div key={c.id} className="charge-row grid four">
|
||||
@@ -191,13 +196,16 @@ export function EditLine({
|
||||
value={c.amount}
|
||||
onChange={value => updateCharge(i, charge => Model.setChargeAmount(charge, value))}
|
||||
/>
|
||||
<button type="button" onClick={() => change(l => ({ ...l, charges: l.charges.filter((_, j) => j !== i) }))}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
onClick={() => change(l => ({ ...l, charges: l.charges.filter((_, j) => j !== i) }))}
|
||||
>
|
||||
移除项目
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{c.costRemoved && (
|
||||
<button type="button" onClick={() => update(f => Model.restoreChargeCost(f, index, i))}>
|
||||
<LedgerButton type="button" onClick={() => update(f => Model.restoreChargeCost(f, index, i))}>
|
||||
恢复内部成本
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
@@ -235,7 +243,7 @@ export function EditLine({
|
||||
<>
|
||||
<Choice label="货品成本付款人" {...prop('payer')} options={members(line.payer)} />
|
||||
<Input label="原单货品成本(旧版未分项)" {...prop('cost')} type="number" readOnly />
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
onClick={() =>
|
||||
change(l => {
|
||||
@@ -252,7 +260,7 @@ export function EditLine({
|
||||
}
|
||||
>
|
||||
拆分这行成本
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
) : (
|
||||
<div className="cost-fields grid">
|
||||
@@ -277,9 +285,9 @@ export function EditLine({
|
||||
hidden={!pooled}
|
||||
onChange={poolId => change(l => ({ ...l, pool: { ...l.pool!, poolId, defaultDate: false } }))}
|
||||
/>
|
||||
<button type="button" onClick={reloadPools}>
|
||||
<LedgerButton type="button" onClick={reloadPools}>
|
||||
刷新料价
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{line.view.poolNote && <p>{line.view.poolNote}</p>}
|
||||
</div>
|
||||
)}
|
||||
@@ -352,7 +360,7 @@ export function EditLine({
|
||||
options={members(p!.laborPayer)}
|
||||
/>
|
||||
{laborFunding && (
|
||||
<input
|
||||
<LedgerInput
|
||||
type="hidden"
|
||||
className="cost-funding"
|
||||
data-component="labor"
|
||||
@@ -371,9 +379,9 @@ export function EditLine({
|
||||
) : (
|
||||
<>
|
||||
{(['accessories', 'other'] as const).map(key => (
|
||||
<input key={key} type="hidden" name={prefix + key} value={p![key]} />
|
||||
<LedgerInput key={key} type="hidden" name={prefix + key} value={p![key]} />
|
||||
))}
|
||||
<input type="hidden" name="payer" value={line.payer} />
|
||||
<LedgerInput type="hidden" name="payer" value={line.payer} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
@@ -393,9 +401,9 @@ export function EditFees({ store, state, update }: { store: FormStore; state: Le
|
||||
<section className="panel internal">
|
||||
<div className="panel-title">
|
||||
<h2>实际费用(内部)</h2>
|
||||
<button type="button" onClick={() => update(f => Model.addManualFee(f, state, uuid))}>
|
||||
<LedgerButton type="button" onClick={() => update(f => Model.addManualFee(f, state, uuid))}>
|
||||
+ 添加其他成本
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<Input
|
||||
label="新增费用默认支付日期"
|
||||
@@ -411,7 +419,7 @@ export function EditFees({ store, state, update }: { store: FormStore; state: Le
|
||||
{Model.presetCatalogView(form, state).map(item => (
|
||||
<Fragment key={item.kind}>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name={'cost_' + item.kind}
|
||||
disabled={hasLinkedCost(item.kind)}
|
||||
@@ -490,12 +498,12 @@ export function EditFees({ store, state, update }: { store: FormStore; state: Le
|
||||
onChange={v => edit('date', v)}
|
||||
/>
|
||||
{!row.automatic && (
|
||||
<button type="button" onClick={() => update(f => Model.removeFeeRow(f, i))}>
|
||||
<LedgerButton type="button" onClick={() => update(f => Model.removeFeeRow(f, i))}>
|
||||
移除费用
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
{ref && (
|
||||
<input
|
||||
<LedgerInput
|
||||
type="hidden"
|
||||
className="cost-funding"
|
||||
data-component="fee"
|
||||
|
||||
Reference in new issue
Block a user