第6项:统一业务控件、主题与移动布局,保留原生输入和焦点契约
This commit is contained in:
1 parent
ff8b05973a
commit
2a4fb47227
77 files changed
+3609
-2451
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { useLayoutEffect, useRef } from 'react';
|
||||
import { Button, Checkbox, Input, Row } from 'antd';
|
||||
import { CloseOutlined, PlusOutlined } from '@ant-design/icons';
|
||||
import { Model } from '../../shared';
|
||||
@@ -21,6 +22,16 @@ export function FeeCosts({
|
||||
summary: FormSummary;
|
||||
update: Update;
|
||||
}) {
|
||||
const feeGrid = useRef<HTMLDivElement>(null);
|
||||
const focusNewFee = useRef(false);
|
||||
useLayoutEffect(() => {
|
||||
if (!focusNewFee.current) return;
|
||||
focusNewFee.current = false;
|
||||
const names = feeGrid.current?.querySelectorAll<HTMLInputElement>('input[name="feeNote"]');
|
||||
const name = names?.[names.length - 1];
|
||||
name?.scrollIntoView?.({ behavior: 'smooth', block: 'nearest' });
|
||||
name?.focus({ preventScroll: true });
|
||||
}, [form.feeRows.length]);
|
||||
const presets = form.presets;
|
||||
const catalog = Model.presetCatalogView(form, state);
|
||||
const defaults = { certificate: '4', packaging: '3', shipping: '6', ...state.shopSettings?.feeDefaults };
|
||||
@@ -43,13 +54,8 @@ export function FeeCosts({
|
||||
icon={<PlusOutlined />}
|
||||
data-action="add-fee"
|
||||
onClick={() => {
|
||||
focusNewFee.current = true;
|
||||
update(f => Model.addManualFee(f, state, uuid));
|
||||
window.requestAnimationFrame(() => {
|
||||
const rows = document.querySelectorAll('.fee-row [data-field="feeNote"] input');
|
||||
const last = rows[rows.length - 1] as HTMLInputElement | undefined;
|
||||
last?.scrollIntoView?.({ behavior: 'smooth', block: 'nearest' });
|
||||
last?.focus?.({ preventScroll: true });
|
||||
});
|
||||
}}
|
||||
>
|
||||
添加其他成本
|
||||
@@ -114,7 +120,7 @@ export function FeeCosts({
|
||||
</div>
|
||||
</fieldset>
|
||||
)}
|
||||
<div className="fee-grid">
|
||||
<div ref={feeGrid} className="fee-grid">
|
||||
{form.feeRows.map((row, index) => {
|
||||
const manual = row.key.startsWith('manual:');
|
||||
return (
|
||||
|
||||
@@ -93,7 +93,7 @@ export function SummarySection({
|
||||
try {
|
||||
const next = Model.insertNoteTag(form.internal_note, tag);
|
||||
update(f => ({ ...f, internal_note: next }));
|
||||
window.setTimeout(() => internalNoteRef.current?.focus(), 0);
|
||||
internalNoteRef.current?.focus();
|
||||
} catch (err) {
|
||||
onError((err as Error).message);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
type Selection,
|
||||
type Values,
|
||||
} from './data';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput, LedgerTextArea } from '../../components/BusinessControls';
|
||||
type List = { requests: ChangeRequest[]; counts: Record<string, number> };
|
||||
function checkValues(v?: Values) {
|
||||
if (
|
||||
@@ -101,9 +102,9 @@ export function Changes({
|
||||
<section className="panel" id="inventory-changes">
|
||||
<div className="panel-title">
|
||||
<h2>{owner ? '库存修改审批' : '我的库存修改申请'}</h2>
|
||||
<button data-action="inventory-change-refresh" onClick={() => retry(n => n + 1)}>
|
||||
<LedgerButton data-action="inventory-change-refresh" onClick={() => retry(n => n + 1)}>
|
||||
刷新申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<p>
|
||||
员工可直接修改本人当天的手动流水;跨天修改、改到其他日期及删除须{Model.memberName(state, 'owner')}
|
||||
@@ -114,9 +115,9 @@ export function Changes({
|
||||
{result?.error ? (
|
||||
<div>
|
||||
{result.error}{' '}
|
||||
<button data-action="inventory-change-refresh" onClick={() => retry(n => n + 1)}>
|
||||
<LedgerButton data-action="inventory-change-refresh" onClick={() => retry(n => n + 1)}>
|
||||
重新读取
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : !r ? (
|
||||
'正在读取库存申请…'
|
||||
@@ -124,7 +125,7 @@ export function Changes({
|
||||
<>
|
||||
<div role="group" aria-label="库存申请状态">
|
||||
{Object.entries({ ...statuses, pending: '待审批', all: '全部' }).map(([k, t]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={k}
|
||||
data-action="inventory-change-filter"
|
||||
data-status={k}
|
||||
@@ -136,57 +137,56 @@ export function Changes({
|
||||
>
|
||||
{t}
|
||||
{k !== 'all' && '(' + r.counts[k] + ')'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
{!r.requests.length ? (
|
||||
<p>全部日期没有此状态的库存申请。</p>
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['原库存记录/申请内容', '申请人/说明', '状态/处理意见', '操作'].map(t => (
|
||||
<th key={t}>{t}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{r.requests.map(x => (
|
||||
<tr key={x.id} data-inventory-request={x.id}>
|
||||
<td>
|
||||
<div>{summary(x.before)}</div>
|
||||
<div>{x.action === 'delete' ? '申请删除整组记录' : '申请改为:' + summary(x.after)}</div>
|
||||
</td>
|
||||
<td>
|
||||
{actor(state, x.requesterName) || Model.memberName(state, x.requesterMember)}
|
||||
<div>{x.created && time(x.created)}</div>
|
||||
<div>{x.reason || '—'}</div>
|
||||
</td>
|
||||
<td>
|
||||
{statuses[x.status]}
|
||||
{x.stale && x.status === 'pending' && <div>原记录已变化,请驳回后重新申请。</div>}
|
||||
<div>{x.note}</div>
|
||||
{x.reviewerName && (
|
||||
<div>
|
||||
{actor(state, x.reviewerName)} · {time(x.reviewed)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
disabled={blocked}
|
||||
data-action="inventory-change-open-request"
|
||||
data-id={x.id}
|
||||
onClick={() => open({ kind: 'request', id: x.id })}
|
||||
>
|
||||
{owner && x.status === 'pending' ? '查看并审批' : '查看申请'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '原库存记录/申请内容' },
|
||||
{ title: '申请人/说明' },
|
||||
{ title: '状态/处理意见' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={r.requests.map(x => ({
|
||||
key: x.id,
|
||||
attributes: { 'data-inventory-request': x.id },
|
||||
cells: [
|
||||
<>
|
||||
<div>{summary(x.before)}</div>
|
||||
<div>{x.action === 'delete' ? '申请删除整组记录' : '申请改为:' + summary(x.after)}</div>
|
||||
</>,
|
||||
<>
|
||||
{actor(state, x.requesterName) || Model.memberName(state, x.requesterMember)}
|
||||
<div>{x.created && time(x.created)}</div>
|
||||
<div>{x.reason || '—'}</div>
|
||||
</>,
|
||||
<>
|
||||
{statuses[x.status]}
|
||||
{x.stale && x.status === 'pending' && <div>原记录已变化,请驳回后重新申请。</div>}
|
||||
<div>{x.note}</div>
|
||||
{x.reviewerName && (
|
||||
<div>
|
||||
{actor(state, x.reviewerName)} · {time(x.reviewed)}
|
||||
</div>
|
||||
)}
|
||||
</>,
|
||||
<>
|
||||
<LedgerButton
|
||||
disabled={blocked}
|
||||
data-action="inventory-change-open-request"
|
||||
data-id={x.id}
|
||||
onClick={() => open({ kind: 'request', id: x.id })}
|
||||
>
|
||||
{owner && x.status === 'pending' ? '查看并审批' : '查看申请'}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
@@ -238,7 +238,7 @@ function Legacy({ record }: { record: LegacyCount }) {
|
||||
'这笔历史记录未记录对数,当前对数按实际盘点基准保留。本次旧重量冲回不自动更改当前对数,如实物有变化请另做当天对数调整。'}
|
||||
</p>
|
||||
<label>
|
||||
<input type="checkbox" name="legacyCountVerified" required />
|
||||
<LedgerInput type="checkbox" name="legacyCountVerified" required />
|
||||
已核对当前对数基准,理解本次更正对历史对数的处理
|
||||
</label>
|
||||
</>
|
||||
@@ -348,16 +348,16 @@ export function ChangeDialog({
|
||||
<div id="inventory-change-error" aria-live="polite">
|
||||
{err}{' '}
|
||||
{stale && (
|
||||
<button type="button" onClick={readAgain}>
|
||||
<LedgerButton type="button" onClick={readAgain}>
|
||||
{review ? '重新读取申请' : '重新读取原记录'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
const cancel = (
|
||||
<button type="button" data-action="inventory-change-close" disabled={client.busy} onClick={close}>
|
||||
<LedgerButton type="button" data-action="inventory-change-close" disabled={client.busy} onClick={close}>
|
||||
{review ? '关闭' : '取消'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
function submit(e: FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
@@ -368,7 +368,7 @@ export function ChangeDialog({
|
||||
{!result?.value ? (
|
||||
result?.error ? (
|
||||
<div>
|
||||
{result.error} <button onClick={readAgain}>重新读取</button>
|
||||
{result.error} <LedgerButton onClick={readAgain}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : (
|
||||
<p>{review ? '正在读取申请与原记录…' : '正在读取整组库存记录…'}</p>
|
||||
@@ -401,24 +401,24 @@ export function ChangeDialog({
|
||||
<Legacy record={request} />
|
||||
<label>
|
||||
处理意见(批准时选填,驳回时必填)
|
||||
<textarea name="note" maxLength={200} rows={2} />
|
||||
<LedgerTextArea name="note" maxLength={200} rows={2} />
|
||||
</label>
|
||||
</fieldset>
|
||||
{problem}
|
||||
<div className="form-actions">
|
||||
{cancel}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="inventory-change-reject"
|
||||
disabled={stale || blocked}
|
||||
onClick={e => void save(e.currentTarget.form!, 'reject')}
|
||||
>
|
||||
驳回申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{!request.stale && request.canApprove !== false && (
|
||||
<button type="submit" className="primary" disabled={stale || blocked}>
|
||||
<LedgerButton type="submit" className="primary" disabled={stale || blocked}>
|
||||
批准{act}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
@@ -433,7 +433,9 @@ export function ChangeDialog({
|
||||
{detail.pending && '这组记录已有申请,等待审批期间库存不变。'}
|
||||
</p>
|
||||
{detail.pending && (
|
||||
<button onClick={() => open({ kind: 'request', id: detail.pending!.id })}>查看待审批申请</button>
|
||||
<LedgerButton onClick={() => open({ kind: 'request', id: detail.pending!.id })}>
|
||||
查看待审批申请
|
||||
</LedgerButton>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
@@ -465,15 +467,20 @@ export function ChangeDialog({
|
||||
)}
|
||||
<label>
|
||||
说明(选填)
|
||||
<input name="reason" type="text" maxLength={200} placeholder="可填写修正原因,供审批或后续核对" />
|
||||
<LedgerInput
|
||||
name="reason"
|
||||
type="text"
|
||||
maxLength={200}
|
||||
placeholder="可填写修正原因,供审批或后续核对"
|
||||
/>
|
||||
</label>
|
||||
</fieldset>
|
||||
{problem}
|
||||
<div className="form-actions">
|
||||
{cancel}
|
||||
<button type="submit" className="primary" disabled={blocked || stale}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked || stale}>
|
||||
{approval ? '提交' + act + '申请' : deleting ? '确认删除' : '保存修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useEffect, useRef, type ReactNode } from 'react';
|
||||
import { type ReactNode } from 'react';
|
||||
import { LedgerButton, LedgerDialog } from '../../components/BusinessControls';
|
||||
export function Dialog({
|
||||
id,
|
||||
title,
|
||||
@@ -10,16 +11,9 @@ export function Dialog({
|
||||
close: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
useEffect(() => {
|
||||
const dialog = ref.current!;
|
||||
dialog.showModal();
|
||||
return () => dialog.close();
|
||||
}, []);
|
||||
const pocket = id === 'pocket-editor-dialog';
|
||||
return (
|
||||
<dialog
|
||||
ref={ref}
|
||||
<LedgerDialog
|
||||
id={id}
|
||||
aria-labelledby={pocket ? 'pocket-editor-title' : 'inventory-change-title'}
|
||||
onCancel={e => {
|
||||
@@ -27,7 +21,7 @@ export function Dialog({
|
||||
close();
|
||||
}}
|
||||
>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
data-action={pocket ? 'pocket-manager-close' : 'inventory-change-close'}
|
||||
@@ -35,9 +29,9 @@ export function Dialog({
|
||||
onClick={close}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id={pocket ? 'pocket-editor-title' : 'inventory-change-title'}>{title}</h2>
|
||||
{children}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import { Movements } from './Movements';
|
||||
import { Changes, ChangeDialog } from './Changes';
|
||||
import { Pockets, type RegisterLeaveGuard } from './Pockets';
|
||||
import './inventory.css';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
const viewMemory = new WeakMap<Props['client'], { user: string; history: boolean; manager: boolean }>();
|
||||
export function InventoryPage({
|
||||
@@ -106,7 +107,7 @@ export function InventoryPage({
|
||||
{page && (
|
||||
<div className="actions">
|
||||
{owner && (
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="pocket-manager-toggle"
|
||||
aria-controls="pocket-manager"
|
||||
aria-expanded={manager}
|
||||
@@ -121,9 +122,9 @@ export function InventoryPage({
|
||||
}}
|
||||
>
|
||||
管理货盘
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<button
|
||||
<LedgerButton
|
||||
id="inventory-changes-entry"
|
||||
data-action="inventory-change-jump"
|
||||
onClick={() => {
|
||||
@@ -135,20 +136,20 @@ export function InventoryPage({
|
||||
>
|
||||
{owner ? '库存修改审批' : '我的库存申请'}
|
||||
{pendingCount != null && '(' + pendingCount + (owner ? '' : '待批') + ')'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{owner && page.canReview && (
|
||||
<button className="primary" disabled={blocked} data-action="inventory-review" onClick={review}>
|
||||
<LedgerButton className="primary" disabled={blocked} data-action="inventory-review" onClick={review}>
|
||||
复核并保存今日快照
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="inventory-history"
|
||||
aria-expanded={history}
|
||||
aria-controls="inventory-history"
|
||||
onClick={() => changeView(!history, manager)}
|
||||
>
|
||||
{history ? '收起每日快照' : '查看每日快照'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{owner && <a href="/api/export/inventory">导出当前库存</a>}
|
||||
</div>
|
||||
)}
|
||||
@@ -159,9 +160,9 @@ export function InventoryPage({
|
||||
<div className="error">
|
||||
{response.error}
|
||||
<div>
|
||||
<button data-action="inventory-retry" onClick={reload}>
|
||||
<LedgerButton data-action="inventory-retry" onClick={reload}>
|
||||
重新读取库存
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
) : !page ? (
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { grams } from '../../lib/format';
|
||||
import { Model } from '../../shared';
|
||||
import { actor, count, label, useRead, type Context, type Selection, type Movement } from './data';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
const names: Record<string, string> = {
|
||||
increase: '增加',
|
||||
decrease: '减少',
|
||||
@@ -154,7 +155,7 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
['previous', '上一页'],
|
||||
['next', '下一页'],
|
||||
].map(([k, t]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={k}
|
||||
data-action="inventory-movements-page"
|
||||
data-direction={k}
|
||||
@@ -162,7 +163,7 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
onClick={() => update({ page: r.page + (k === 'next' ? 1 : -1) })}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
@@ -184,7 +185,7 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
' 条'
|
||||
: '共 0 条')}
|
||||
</span>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="primary"
|
||||
id="inventory-movements-export"
|
||||
data-action="inventory-movements-export"
|
||||
@@ -192,7 +193,7 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
onClick={download}
|
||||
>
|
||||
{exporting ? '正在导出…' : '导出Excel'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
<p>团队共用库存,全部流水可查看。员工可直接修改本人当天的手动记录;跨天修改、改到其他日期及删除仍须店主审批。</p>
|
||||
@@ -204,7 +205,7 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
{(['from', 'to'] as const).map(k => (
|
||||
<label key={k}>
|
||||
{k === 'from' ? '开始日期' : '结束日期'}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
id={'inventory-movements-' + k}
|
||||
value={filter[k]}
|
||||
@@ -212,12 +213,16 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
/>
|
||||
</label>
|
||||
))}
|
||||
<button data-action="inventory-movements-clear-dates" onClick={() => update({ from: '', to: '' })}>
|
||||
<LedgerButton data-action="inventory-movements-clear-dates" onClick={() => update({ from: '', to: '' })}>
|
||||
全部日期
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<label>
|
||||
筛选货盘
|
||||
<select id="inventory-movements-pocket" value={pocket} onChange={e => update({ pocket: e.target.value })}>
|
||||
<LedgerSelect
|
||||
id="inventory-movements-pocket"
|
||||
value={pocket}
|
||||
onChange={e => update({ pocket: e.target.value })}
|
||||
>
|
||||
<option value="">全部货盘</option>
|
||||
{options.map(o => (
|
||||
<option key={o.pocket} value={o.pocket}>
|
||||
@@ -225,11 +230,11 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
{!o.active && '(已停用 · 历史)'}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label>
|
||||
流水类型
|
||||
<select id="inventory-movements-kind" value={kind} onChange={e => update({ kind: e.target.value })}>
|
||||
<LedgerSelect id="inventory-movements-kind" value={kind} onChange={e => update({ kind: e.target.value })}>
|
||||
{Object.entries({
|
||||
all: '全部流水',
|
||||
increase: '手动增加',
|
||||
@@ -241,16 +246,16 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
{v}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="inventory-movements-toggle-deleted"
|
||||
id="inventory-movements-toggle-deleted"
|
||||
aria-pressed={hideDeleted}
|
||||
onClick={() => update({ hideDeleted: !hideDeleted })}
|
||||
>
|
||||
{hideDeleted ? '显示' : '隐藏'}已删除记录
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<span>按流水日期筛选,含起止当天;留空不限。每页100条,可翻页查看更早记录。平移按两边货盘分别记一条。</span>
|
||||
</div>
|
||||
<div id="inventory-movements-pagination">{pager}</div>
|
||||
@@ -260,7 +265,8 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
<div id="inventory-movements-list" aria-live="polite" aria-busy={valid && !reply}>
|
||||
{!valid || reply?.error ? (
|
||||
<div>
|
||||
{reply?.error || '开始日期不能晚于结束日期'} <button onClick={() => retry(n => n + 1)}>重新读取流水</button>
|
||||
{reply?.error || '开始日期不能晚于结束日期'}{' '}
|
||||
<LedgerButton onClick={() => retry(n => n + 1)}>重新读取流水</LedgerButton>
|
||||
</div>
|
||||
) : !r ? (
|
||||
'正在读取库存流水…'
|
||||
@@ -270,41 +276,41 @@ export function Movements({ client, state, version, blocked, open }: { open: (s:
|
||||
'当前筛选下暂无库存流水。'
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['日期', '货盘', '变动', '动作', '备注/原单', '经办人', '状态/操作'].map(t => (
|
||||
<th key={t}>{t}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{r.movements.map(row => (
|
||||
<tr key={row.id} data-movement-id={row.id}>
|
||||
<td>{row.date}</td>
|
||||
<td>
|
||||
{label(state, row.pocket)}
|
||||
{!Model.activePocketKeys(state).includes(row.pocket) && <div>已停用 · 历史</div>}
|
||||
</td>
|
||||
<td>
|
||||
{row.mg > 0 && '+'}
|
||||
{grams(row.mg)}g
|
||||
{(row.stockCount != null || Model.pocketCountsEnabled(state, row.pocket)) && (
|
||||
<div>{count(row.stockCount, true)}</div>
|
||||
)}
|
||||
</td>
|
||||
<td>{names[row.kind] || row.kind}</td>
|
||||
<td>
|
||||
{row.reversal || row.kind === 'manual_reversal' ? '撤回旧记录的库存影响' : row.note || '—'}
|
||||
</td>
|
||||
<td>{actor(state, row.actor)}</td>
|
||||
<td>
|
||||
<Actions row={row} open={open} blocked={blocked} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '日期' },
|
||||
{ title: '货盘' },
|
||||
{ title: '变动' },
|
||||
{ title: '动作' },
|
||||
{ title: '备注/原单' },
|
||||
{ title: '经办人' },
|
||||
{ title: '状态/操作' },
|
||||
]}
|
||||
rows={r.movements.map(row => ({
|
||||
key: row.id,
|
||||
attributes: { 'data-movement-id': row.id },
|
||||
cells: [
|
||||
row.date,
|
||||
<>
|
||||
{label(state, row.pocket)}
|
||||
{!Model.activePocketKeys(state).includes(row.pocket) && <div>已停用 · 历史</div>}
|
||||
</>,
|
||||
<>
|
||||
{row.mg > 0 && '+'}
|
||||
{grams(row.mg)}g
|
||||
{(row.stockCount != null || Model.pocketCountsEnabled(state, row.pocket)) && (
|
||||
<div>{count(row.stockCount, true)}</div>
|
||||
)}
|
||||
</>,
|
||||
names[row.kind] || row.kind,
|
||||
row.reversal || row.kind === 'manual_reversal' ? '撤回旧记录的库存影响' : row.note || '—',
|
||||
actor(state, row.actor),
|
||||
<>
|
||||
<Actions row={row} open={open} blocked={blocked} />
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{pager}
|
||||
@@ -332,37 +338,37 @@ function Actions({ row: r, open, blocked }: { row: Movement; open: (s: Selection
|
||||
<>
|
||||
{text && <div>{text}</div>}
|
||||
{manual && r.pendingRequestId ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
disabled={blocked}
|
||||
data-action="inventory-change-open-request"
|
||||
data-id={r.pendingRequestId}
|
||||
onClick={() => open({ id: r.pendingRequestId!, kind: 'request' })}
|
||||
>
|
||||
待审批 · 查看
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : manual && r.pendingApproval ? (
|
||||
'待店主审批'
|
||||
) : canChange && (r.canEdit || r.canDelete) ? (
|
||||
<>
|
||||
{r.canEdit && (
|
||||
<button
|
||||
<LedgerButton
|
||||
disabled={blocked}
|
||||
data-action="inventory-change-edit"
|
||||
data-id={r.id}
|
||||
onClick={() => open({ id: r.id, kind: 'update' })}
|
||||
>
|
||||
修改
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
{r.canDelete && (
|
||||
<button
|
||||
<LedgerButton
|
||||
disabled={blocked}
|
||||
data-action="inventory-change-delete"
|
||||
data-id={r.id}
|
||||
onClick={() => open({ id: r.id, kind: 'delete' })}
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</>
|
||||
) : manual ? (
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState, type FormEvent } from 'react';
|
||||
import type { ApiError } from '../../lib/api';
|
||||
import { Dialog } from './Dialog';
|
||||
import { countValue, useRead, type CatalogRow, type Context } from './data';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput } from '../../components/BusinessControls';
|
||||
export type RegisterLeaveGuard = (check: () => boolean) => () => void;
|
||||
type Reply = { catalog: CatalogRow[]; pockets: string[]; canManage?: boolean };
|
||||
function validate(r: Reply) {
|
||||
@@ -127,9 +128,9 @@ export function Pockets({
|
||||
<div className="error">
|
||||
{error}
|
||||
{stale && (
|
||||
<button type="button" data-action="pocket-manager-reload" onClick={refresh}>
|
||||
<LedgerButton type="button" data-action="pocket-manager-reload" onClick={refresh}>
|
||||
重新读取货盘
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -139,18 +140,18 @@ export function Pockets({
|
||||
<div className="panel-title">
|
||||
<h2>货盘管理</h2>
|
||||
<div>
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="pocket-manager-add"
|
||||
className="primary"
|
||||
disabled={blocked || stale}
|
||||
onClick={() => edit('new')}
|
||||
>
|
||||
+ 新增货盘
|
||||
</button>
|
||||
<button data-action="pocket-manager-reload" disabled={blocked} onClick={refresh}>
|
||||
</LedgerButton>
|
||||
<LedgerButton data-action="pocket-manager-reload" disabled={blocked} onClick={refresh}>
|
||||
重新读取
|
||||
</button>
|
||||
<button
|
||||
</LedgerButton>
|
||||
<LedgerButton
|
||||
data-action="pocket-manager-toggle"
|
||||
disabled={blocked}
|
||||
onClick={() => {
|
||||
@@ -158,14 +159,14 @@ export function Pockets({
|
||||
}}
|
||||
>
|
||||
收起
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
<p>新增货盘按自有库存管理。停用后保留库存与历史记录,可重新启用。</p>
|
||||
<div id="pocket-manager-content" aria-live="polite" aria-busy={open && !response}>
|
||||
{response?.error ? (
|
||||
<div>
|
||||
{response.error} <button onClick={refresh}>重新读取</button>
|
||||
{response.error} <LedgerButton onClick={refresh}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : !rows ? (
|
||||
'正在读取货盘…'
|
||||
@@ -173,7 +174,7 @@ export function Pockets({
|
||||
<>
|
||||
<label>
|
||||
搜索货盘
|
||||
<input
|
||||
<LedgerInput
|
||||
type="search"
|
||||
id="pocket-manager-search"
|
||||
value={search}
|
||||
@@ -187,48 +188,41 @@ export function Pockets({
|
||||
'没有匹配的货盘。'
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['货盘名称', '计数方式', '状态', '操作'].map(s => (
|
||||
<th key={s}>{s}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{found.map(r => (
|
||||
<tr key={r.key}>
|
||||
<td>{r.name}</td>
|
||||
<td>{r.countUnit === 'pair' ? '克重 + 对数' : '仅克重'}</td>
|
||||
<td>{r.active ? '已启用' : '已停用'}</td>
|
||||
<td>
|
||||
<button
|
||||
data-action="pocket-manager-edit"
|
||||
data-pocket-key={r.key}
|
||||
onClick={() => edit(r)}
|
||||
disabled={blocked || stale}
|
||||
>
|
||||
编辑
|
||||
</button>
|
||||
<button
|
||||
data-action="pocket-manager-status"
|
||||
data-pocket-key={r.key}
|
||||
data-active={!r.active}
|
||||
disabled={blocked || stale}
|
||||
onClick={() =>
|
||||
void save('/api/pockets/' + encodeURIComponent(r.key) + '/update', {
|
||||
revision: r.revision,
|
||||
active: !r.active,
|
||||
})
|
||||
}
|
||||
>
|
||||
{r.active ? '停用' : '启用'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[{ title: '货盘名称' }, { title: '计数方式' }, { title: '状态' }, { title: '操作' }]}
|
||||
rows={found.map(r => ({
|
||||
key: r.key,
|
||||
cells: [
|
||||
r.name,
|
||||
r.countUnit === 'pair' ? '克重 + 对数' : '仅克重',
|
||||
r.active ? '已启用' : '已停用',
|
||||
<>
|
||||
<LedgerButton
|
||||
data-action="pocket-manager-edit"
|
||||
data-pocket-key={r.key}
|
||||
onClick={() => edit(r)}
|
||||
disabled={blocked || stale}
|
||||
>
|
||||
编辑
|
||||
</LedgerButton>
|
||||
<LedgerButton
|
||||
data-action="pocket-manager-status"
|
||||
data-pocket-key={r.key}
|
||||
data-active={!r.active}
|
||||
disabled={blocked || stale}
|
||||
onClick={() =>
|
||||
void save('/api/pockets/' + encodeURIComponent(r.key) + '/update', {
|
||||
revision: r.revision,
|
||||
active: !r.active,
|
||||
})
|
||||
}
|
||||
>
|
||||
{r.active ? '停用' : '启用'}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -248,7 +242,7 @@ export function Pockets({
|
||||
>
|
||||
<label>
|
||||
货盘名称
|
||||
<input
|
||||
<LedgerInput
|
||||
autoFocus
|
||||
required
|
||||
maxLength={40}
|
||||
@@ -265,7 +259,7 @@ export function Pockets({
|
||||
) : (
|
||||
<div>
|
||||
<label>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="enableCounts"
|
||||
checked={enable}
|
||||
@@ -277,7 +271,7 @@ export function Pockets({
|
||||
<div data-pocket-count-baseline hidden={!enable}>
|
||||
<label>
|
||||
实际当前库存数量(对)
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
name="initialCount"
|
||||
min="0"
|
||||
@@ -290,7 +284,7 @@ export function Pockets({
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
<LedgerInput
|
||||
name="countVerified"
|
||||
type="checkbox"
|
||||
disabled={!enable || blocked || stale}
|
||||
@@ -306,12 +300,12 @@ export function Pockets({
|
||||
{problem}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="button" data-action="pocket-manager-close" disabled={blocked} onClick={close}>
|
||||
<LedgerButton type="button" data-action="pocket-manager-close" disabled={blocked} onClick={close}>
|
||||
取消
|
||||
</button>
|
||||
<button type="submit" className="primary" disabled={blocked || stale}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked || stale}>
|
||||
{editor === 'new' ? '新增货盘' : '保存设置'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type Snapshot,
|
||||
type Context,
|
||||
} from './data';
|
||||
import { LedgerButton, LedgerInput, LedgerTable } from '../../components/BusinessControls';
|
||||
|
||||
export function Status({ page, state }: { page: Inventory; state: Context['state'] }) {
|
||||
const s = page.todaySnapshot,
|
||||
@@ -105,7 +106,7 @@ export function SnapshotHistory({ page, open, client, state, version }: { page:
|
||||
['month', '本月'],
|
||||
['all', '全部记录'],
|
||||
].map(([k, t]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={k}
|
||||
data-action="inventory-history-period"
|
||||
data-period={k}
|
||||
@@ -116,12 +117,12 @@ export function SnapshotHistory({ page, open, client, state, version }: { page:
|
||||
}}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
<label>
|
||||
指定日期
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
id="inventory-history-date"
|
||||
value={mode === 'date' ? date : page.date}
|
||||
@@ -143,9 +144,9 @@ export function SnapshotHistory({ page, open, client, state, version }: { page:
|
||||
(!valid || reply?.error ? (
|
||||
<div>
|
||||
{reply?.error || '请选择今天或之前的有效日期。'}{' '}
|
||||
<button data-action="inventory-history-retry" onClick={() => retry(n => n + 1)}>
|
||||
<LedgerButton data-action="inventory-history-retry" onClick={() => retry(n => n + 1)}>
|
||||
重新读取快照
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : !snapshots ? (
|
||||
'正在读取已保存的快照…'
|
||||
@@ -153,7 +154,7 @@ export function SnapshotHistory({ page, open, client, state, version }: { page:
|
||||
'这段日期尚未保存每日库存快照。'
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<LedgerTable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
@@ -198,7 +199,7 @@ export function SnapshotHistory({ page, open, client, state, version }: { page:
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState, type FormEvent } from 'react';
|
||||
import { stockInput } from './stockInput';
|
||||
import { Model, type LedgerState } from '../../shared';
|
||||
import { kinds, type Values, type Context } from './data';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
|
||||
export function StockFields({
|
||||
state,
|
||||
@@ -39,7 +40,7 @@ export function StockFields({
|
||||
const date = (
|
||||
<label>
|
||||
业务日期
|
||||
<input
|
||||
<LedgerInput
|
||||
name="date"
|
||||
type="date"
|
||||
defaultValue={original?.date || state.today}
|
||||
@@ -55,7 +56,7 @@ export function StockFields({
|
||||
{original && date}
|
||||
<label>
|
||||
{original ? '类型' : '动作'}
|
||||
<select name="kind" value={kind} onChange={e => setKind(e.target.value)}>
|
||||
<LedgerSelect name="kind" value={kind} onChange={e => setKind(e.target.value)}>
|
||||
{Object.entries(kinds)
|
||||
.filter(([key]) => key !== 'adjustment' || state.user.role === 'owner' || original?.kind === key)
|
||||
.map(([key, n]) => (
|
||||
@@ -63,23 +64,29 @@ export function StockFields({
|
||||
{key === 'adjustment' && !original ? '只调整对数' : n}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label>
|
||||
<span data-stock-pocket-label>{transfer ? '从哪移出' : '货盘'}</span>
|
||||
<select name="pocket" value={pocket} onChange={e => setPocket(e.target.value)}>
|
||||
<LedgerSelect name="pocket" value={pocket} onChange={e => setPocket(e.target.value)}>
|
||||
{options(original?.pocket)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label data-stock-to hidden={!transfer}>
|
||||
移到哪
|
||||
<select name="to" value={to} disabled={!transfer} required={transfer} onChange={e => setTo(e.target.value)}>
|
||||
<LedgerSelect
|
||||
name="to"
|
||||
value={to}
|
||||
disabled={!transfer}
|
||||
required={transfer}
|
||||
onChange={e => setTo(e.target.value)}
|
||||
>
|
||||
{options(original?.to)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label>
|
||||
{original ? '克重(g)' : '数量(g)'}
|
||||
<input
|
||||
<LedgerInput
|
||||
name="grams"
|
||||
type="number"
|
||||
required
|
||||
@@ -94,7 +101,7 @@ export function StockFields({
|
||||
</label>
|
||||
<label data-stock-count-field hidden={!counted}>
|
||||
库存数量(对)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="stockCount"
|
||||
type="number"
|
||||
defaultValue={original?.stockCount ?? ''}
|
||||
@@ -119,7 +126,7 @@ export function StockFields({
|
||||
)}
|
||||
<label>
|
||||
备注(选填)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="note"
|
||||
type="text"
|
||||
maxLength={200}
|
||||
@@ -128,9 +135,9 @@ export function StockFields({
|
||||
/>
|
||||
</label>
|
||||
{!original && (
|
||||
<button className="primary" id="stock-submit" disabled={!active.length}>
|
||||
<LedgerButton className="primary" id="stock-submit" disabled={!active.length}>
|
||||
{adjustment ? '保存对数调整' : '登记' + kinds[kind]}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.inventory-page {
|
||||
color: var(--ink, #233832);
|
||||
color: var(--ink, var(--ink));
|
||||
min-width: 0;
|
||||
}
|
||||
.inventory-page [hidden] {
|
||||
@@ -14,14 +14,14 @@
|
||||
font-size: clamp(1.9rem, 4vw, 3rem);
|
||||
}
|
||||
.inventory-page p {
|
||||
color: var(--muted, #596963);
|
||||
color: var(--muted, var(--muted));
|
||||
line-height: 1.55;
|
||||
}
|
||||
.inventory-page .panel,
|
||||
.inventory-page .stock-card,
|
||||
.inventory-page .stock-review-status {
|
||||
background: var(--surface, #fff);
|
||||
border: 1px solid var(--line, #dce4df);
|
||||
background: var(--surface, var(--white));
|
||||
border: 1px solid var(--line, var(--border));
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
margin-block: 14px;
|
||||
@@ -38,7 +38,7 @@
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
.inventory-page .stock-card .yesterday {
|
||||
border-top: 1px solid #dce4df;
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 12px;
|
||||
padding-top: 10px;
|
||||
display: grid;
|
||||
@@ -83,7 +83,7 @@
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 8px;
|
||||
border: 1px solid #b9c6bf;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
color: inherit;
|
||||
background: white;
|
||||
@@ -97,7 +97,7 @@
|
||||
}
|
||||
.inventory-page button {
|
||||
cursor: pointer;
|
||||
border: 1px solid #b9c6bf;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
background: white;
|
||||
color: inherit;
|
||||
@@ -110,7 +110,7 @@
|
||||
}
|
||||
.inventory-page .primary,
|
||||
.inventory-page button[aria-pressed='true'] {
|
||||
background: #254f46;
|
||||
background: var(--green);
|
||||
color: white;
|
||||
}
|
||||
.inventory-page .table-wrap {
|
||||
@@ -124,7 +124,7 @@
|
||||
.inventory-page td,
|
||||
.inventory-page th {
|
||||
padding: 9px;
|
||||
border-bottom: 1px solid #dde4df;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: top;
|
||||
}
|
||||
.inventory-page th {
|
||||
@@ -132,7 +132,7 @@
|
||||
}
|
||||
.inventory-page dialog {
|
||||
position: fixed;
|
||||
border: 1px solid #dce4df;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 13px;
|
||||
max-width: min(720px, 94vw);
|
||||
width: 100%;
|
||||
@@ -143,13 +143,13 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.inventory-page dialog::backdrop {
|
||||
background: #18332b55;
|
||||
background: color-mix(in srgb, var(--ink) 33%, transparent);
|
||||
}
|
||||
.inventory-page .dialog-close {
|
||||
float: right;
|
||||
}
|
||||
.inventory-page .error {
|
||||
color: #9a372c;
|
||||
color: var(--danger);
|
||||
}
|
||||
.inventory-page .inventory-change-comparison {
|
||||
display: grid;
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
type Purchase,
|
||||
type EnablePreview,
|
||||
} from './model';
|
||||
import { LedgerButton, LedgerDialog } from '../../components/BusinessControls';
|
||||
|
||||
interface Props {
|
||||
client: LedgerClient;
|
||||
@@ -52,15 +53,9 @@ function MaterialDialog({
|
||||
retry: () => Promise<void>;
|
||||
reload: () => void;
|
||||
} & Props) {
|
||||
const ref = useRef<HTMLDialogElement>(null),
|
||||
[data, setData] = useState<DialogData | null>(null),
|
||||
const [data, setData] = useState<DialogData | null>(null),
|
||||
[readError, setReadError] = useState(''),
|
||||
[error, setError] = useState<ApiError | null>(null);
|
||||
useEffect(() => {
|
||||
const el = ref.current!;
|
||||
el.showModal();
|
||||
return () => el.close();
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
let active = true;
|
||||
async function read(): Promise<DialogData | null> {
|
||||
@@ -112,7 +107,7 @@ function MaterialDialog({
|
||||
const stale =
|
||||
!!error && !settling && (pending || (buying ? error.status === 409 : [403, 404, 409].includes(error.status ?? 0)));
|
||||
const reloadButton = (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="quiet"
|
||||
data-action={
|
||||
@@ -127,7 +122,7 @@ function MaterialDialog({
|
||||
onClick={reload}
|
||||
>
|
||||
{buying ? '重新读取这笔购料' : spec.kind === 'enable' ? '重新核对' : '重新读取申请'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
const actions = {
|
||||
blocked,
|
||||
@@ -138,7 +133,7 @@ function MaterialDialog({
|
||||
<div className="error">
|
||||
{error.message}{' '}
|
||||
{pending ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="danger"
|
||||
data-action="retry"
|
||||
@@ -146,7 +141,7 @@ function MaterialDialog({
|
||||
onClick={() => void retry().catch(setError)}
|
||||
>
|
||||
恢复原操作
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
(stale || (!buying && !settling)) && reloadButton
|
||||
)}
|
||||
@@ -180,8 +175,7 @@ function MaterialDialog({
|
||||
? '更正申请未读到'
|
||||
: '读取购料更正申请';
|
||||
return (
|
||||
<dialog
|
||||
ref={ref}
|
||||
<LedgerDialog
|
||||
id={prefix + '-dialog'}
|
||||
aria-labelledby={prefix + '-title'}
|
||||
onCancel={e => {
|
||||
@@ -189,7 +183,7 @@ function MaterialDialog({
|
||||
close();
|
||||
}}
|
||||
>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
data-action={
|
||||
@@ -205,7 +199,7 @@ function MaterialDialog({
|
||||
onClick={close}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id={prefix + '-title'}>{title}</h2>
|
||||
{readError ? (
|
||||
<div className="error">
|
||||
@@ -235,7 +229,7 @@ function MaterialDialog({
|
||||
: '正在读取原购料记录及订单影响…'}
|
||||
</p>
|
||||
)}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
const lastPool = new WeakMap<LedgerClient, { user: string; date: string }>();
|
||||
@@ -369,14 +363,14 @@ export function MaterialPoolsPage({ client, state, onState, onRecoverOther }: Pr
|
||||
{pending && !client.busy && (
|
||||
<div className="note" role="alert">
|
||||
上次提交结果尚未确认,请先恢复原操作。{' '}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="retry"
|
||||
className="danger"
|
||||
onClick={() => void retry().catch(e => setNotice(e.message))}
|
||||
>
|
||||
恢复原操作
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
)}
|
||||
{saved ? (
|
||||
@@ -391,16 +385,16 @@ export function MaterialPoolsPage({ client, state, onState, onRecoverOther }: Pr
|
||||
: '正在读取最新材料记录…'}
|
||||
</p>
|
||||
<div className="actions">
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="refresh-material-pools"
|
||||
className="primary"
|
||||
onClick={() => void refresh()}
|
||||
>
|
||||
重新读取每日料价
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{saved === '购料已保存' && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="new-material-purchase"
|
||||
onClick={() => {
|
||||
@@ -409,7 +403,7 @@ export function MaterialPoolsPage({ client, state, onState, onRecoverOther }: Pr
|
||||
}}
|
||||
>
|
||||
继续登记另一笔购料
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
@@ -422,9 +416,9 @@ export function MaterialPoolsPage({ client, state, onState, onRecoverOther }: Pr
|
||||
<h1>每日购料</h1>
|
||||
<p>购料付款当天记支出,余料结转;订单按实际耗用自动计料费。</p>
|
||||
</div>
|
||||
<button type="button" data-action="refresh-material-pools" onClick={() => void refresh()}>
|
||||
<LedgerButton type="button" data-action="refresh-material-pools" onClick={() => void refresh()}>
|
||||
刷新
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
{notice && (
|
||||
<div role="status" className="note">
|
||||
@@ -443,9 +437,9 @@ export function MaterialPoolsPage({ client, state, onState, onRecoverOther }: Pr
|
||||
{readError ? (
|
||||
<div className="error">
|
||||
{readError}{' '}
|
||||
<button type="button" data-action="refresh-material-pools" onClick={() => void refresh()}>
|
||||
<LedgerButton type="button" data-action="refresh-material-pools" onClick={() => void refresh()}>
|
||||
重新读取
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : data ? (
|
||||
<>
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type DialogSpec,
|
||||
type Usage,
|
||||
} from './model';
|
||||
import { LedgerButton, LedgerDataTable, LedgerTable } from '../../components/BusinessControls';
|
||||
|
||||
interface Actions {
|
||||
state: LedgerState;
|
||||
@@ -34,7 +35,7 @@ function SourceLink({
|
||||
recoveries: ['recovery-open', 'recovery'],
|
||||
}[kind];
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="link-button"
|
||||
data-action={target[0]}
|
||||
@@ -44,7 +45,7 @@ function SourceLink({
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
export function RollingSummary({ pool: p, cutover }: { pool: Pool; cutover: string }) {
|
||||
@@ -223,7 +224,7 @@ function PurchaseActions({ p, rolling, state, openDialog }: Actions & { p: Purch
|
||||
return (
|
||||
<div className="actions">
|
||||
{(['edit', 'delete'] as const).map(kind => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={kind}
|
||||
type="button"
|
||||
className={kind === 'edit' ? 'quiet' : 'danger'}
|
||||
@@ -233,7 +234,7 @@ function PurchaseActions({ p, rolling, state, openDialog }: Actions & { p: Purch
|
||||
>
|
||||
{prefix}
|
||||
{kind === 'edit' ? '修改' : '删除'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
@@ -267,38 +268,37 @@ function PoolSettlement({ pool: p, state, openDialog }: Actions & { pool: Pool }
|
||||
: (due! < 0 ? owner + '待转回' + assistant : assistant + '待交' + owner) + ' ' + money(Math.abs(due!))}
|
||||
</span>
|
||||
{!blocked && due !== 0 && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="material-pool-settlement"
|
||||
data-id={p.id}
|
||||
onClick={() => openDialog({ kind: 'settlement', pool: p })}
|
||||
>
|
||||
登记实际交款/返款
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
{!!p.settlements?.length && (
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>实际交款/返款</th>
|
||||
<th className="number">金额</th>
|
||||
<th>备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{p.settlements.map((s, i) => (
|
||||
<tr key={i}>
|
||||
<td>{s.date}</td>
|
||||
<td>{s.amount < 0 ? owner + ' → ' + assistant : assistant + ' → ' + owner}</td>
|
||||
<td className="number">{money(Math.abs(s.amount))}</td>
|
||||
<td>{s.note}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="material-detail-table"
|
||||
columns={[
|
||||
{ title: '日期' },
|
||||
{ title: '实际交款/返款' },
|
||||
{ title: '金额', headerClassName: 'number' },
|
||||
{ title: '备注' },
|
||||
]}
|
||||
rows={p.settlements.map((s, i) => ({
|
||||
key: i,
|
||||
cellClasses: [undefined, undefined, 'number', undefined],
|
||||
cells: [
|
||||
s.date,
|
||||
s.amount < 0 ? owner + ' → ' + assistant : assistant + ' → ' + owner,
|
||||
money(Math.abs(s.amount)),
|
||||
s.note,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -327,7 +327,7 @@ function PoolDetail({ pool: p, rolling, state, openDialog }: Actions & { pool: P
|
||||
<h3>{p.date} 购料明细(按录入先后)</h3>
|
||||
<p className="small muted">单价=本笔购买总价÷购买克重,与当天加权料价分开显示;显示精度不改变记账金额。</p>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table material-purchase-table">
|
||||
<LedgerTable className="material-detail-table material-purchase-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>购料日期</th>
|
||||
@@ -359,49 +359,48 @@ function PoolDetail({ pool: p, rolling, state, openDialog }: Actions & { pool: P
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
{!!p.returns?.length && (
|
||||
<>
|
||||
<h3>退货回料追溯</h3>
|
||||
<p className="small muted">回料没有新增购料付款。金料按原订单成本计入,工费与快递费不加入料池。</p>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table material-return-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>回料日期/原订单</th>
|
||||
<th className="number">实际退回克重</th>
|
||||
<th className="number">原金料成本</th>
|
||||
<th>计入方式</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{p.returns.map((r, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
{r.date || p.date}
|
||||
{r.order_id && (
|
||||
<>
|
||||
<br />
|
||||
<SourceLink kind="orders" id={r.order_id}>
|
||||
{r.number || '查看原订单'}
|
||||
</SourceLink>
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
<td className="number">{grams(r.mg ?? r.grossMg)}g</td>
|
||||
<td className="number">{money(r.amount ?? r.grossAmount)}</td>
|
||||
<td>{r.sameDay ? '同日售退已净抵销' : '并入回料当天材料'}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="material-detail-table material-return-table"
|
||||
columns={[
|
||||
{ title: '回料日期/原订单' },
|
||||
{ title: '实际退回克重', headerClassName: 'number' },
|
||||
{ title: '原金料成本', headerClassName: 'number' },
|
||||
{ title: '计入方式' },
|
||||
]}
|
||||
rows={p.returns.map((r, i) => ({
|
||||
key: i,
|
||||
cellClasses: [undefined, 'number', 'number', undefined],
|
||||
cells: [
|
||||
<>
|
||||
{r.date || p.date}
|
||||
{r.order_id && (
|
||||
<>
|
||||
<br />
|
||||
<SourceLink kind="orders" id={r.order_id}>
|
||||
{r.number || '查看原订单'}
|
||||
</SourceLink>
|
||||
</>
|
||||
)}
|
||||
</>,
|
||||
<>{grams(r.mg ?? r.grossMg)}g</>,
|
||||
money(r.amount ?? r.grossAmount),
|
||||
r.sameDay ? '同日售退已净抵销' : '并入回料当天材料',
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<h3>订单耗用与锁价原料明细</h3>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table">
|
||||
<LedgerTable className="material-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期/订单或锁价单</th>
|
||||
@@ -441,7 +440,7 @@ function PoolDetail({ pool: p, rolling, state, openDialog }: Actions & { pool: P
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
<PoolSettlement pool={p} state={state} openDialog={openDialog} />
|
||||
</div>
|
||||
@@ -479,14 +478,14 @@ export function PoolList({
|
||||
<div className="panel-title">
|
||||
<h2>合并未用完的材料</h2>
|
||||
{state.user.role === 'owner' && data.rolling.canEnable && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="primary"
|
||||
data-action="material-rolling-enable-preview"
|
||||
onClick={() => openDialog({ kind: 'enable' })}
|
||||
>
|
||||
核对并启用跨日结转
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
<p className="small muted">
|
||||
@@ -522,7 +521,7 @@ export function PoolList({
|
||||
</span>
|
||||
</div>
|
||||
<div className="table-wrap">
|
||||
<table className={'material-pool-table' + (rolling ? ' material-rolling-history-table' : '')}>
|
||||
<LedgerTable className={'material-pool-table' + (rolling ? ' material-rolling-history-table' : '')}>
|
||||
<thead>
|
||||
<tr>
|
||||
{headings.map((h, i) => (
|
||||
@@ -580,7 +579,7 @@ export function PoolList({
|
||||
</>
|
||||
)}
|
||||
<td>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="quiet"
|
||||
data-action="toggle-material-pool"
|
||||
@@ -589,7 +588,7 @@ export function PoolList({
|
||||
onClick={() => toggle(open ? '' : p.id)}
|
||||
>
|
||||
{open ? '收起' : '查看'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</td>
|
||||
</tr>
|
||||
{open && (
|
||||
@@ -610,7 +609,7 @@ export function PoolList({
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
<p className="small muted material-pool-footnote">
|
||||
{rolling
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type PurchaseInput,
|
||||
type Save,
|
||||
} from './model';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect, LedgerTextArea } from '../../components/BusinessControls';
|
||||
|
||||
function initialDraft(state: LedgerState) {
|
||||
let saved: Record<string, unknown> | null;
|
||||
@@ -43,11 +44,11 @@ function PurchaseFields({
|
||||
<div className="material-purchase-fields">
|
||||
<label>
|
||||
购料日期
|
||||
<input name="date" defaultValue={value.date} type="date" required min={minDate} max={state.today} />
|
||||
<LedgerInput name="date" defaultValue={value.date} type="date" required min={minDate} max={state.today} />
|
||||
</label>
|
||||
<label>
|
||||
购买克重(g)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="grams"
|
||||
defaultValue={value.grams}
|
||||
type="number"
|
||||
@@ -60,7 +61,7 @@ function PurchaseFields({
|
||||
</label>
|
||||
<label>
|
||||
购买总价(元)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="total"
|
||||
defaultValue={value.total}
|
||||
type="number"
|
||||
@@ -73,17 +74,17 @@ function PurchaseFields({
|
||||
</label>
|
||||
<label>
|
||||
付款人
|
||||
<select name="payer" defaultValue={value.payer}>
|
||||
<LedgerSelect name="payer" defaultValue={value.payer}>
|
||||
{Model.memberOptions(state, false, { selected: value.payer }).map(([key, name]) => (
|
||||
<option key={key} value={key}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label>
|
||||
备注(选填)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="note"
|
||||
defaultValue={value.note}
|
||||
type="text"
|
||||
@@ -142,9 +143,9 @@ export function PurchaseForm({
|
||||
onSubmit={submit}
|
||||
>
|
||||
<PurchaseFields state={state} value={draft} create>
|
||||
<button type="submit" className="primary" disabled={blocked}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked}>
|
||||
保存购料
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</PurchaseFields>
|
||||
<div id="material-purchase-error" aria-live="polite">
|
||||
{error && <div className="error">{error}</div>}
|
||||
@@ -185,18 +186,23 @@ export function PurchaseChange({
|
||||
return (
|
||||
<>
|
||||
<p>这笔购料已删除,原记录与操作历史保留。</p>
|
||||
<button className="primary" type="button" data-action="refresh-changed-material-purchase" onClick={refresh}>
|
||||
<LedgerButton
|
||||
className="primary"
|
||||
type="button"
|
||||
data-action="refresh-changed-material-purchase"
|
||||
onClick={refresh}
|
||||
>
|
||||
关闭并刷新每日购料
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
);
|
||||
if (p.recovery_id)
|
||||
return (
|
||||
<>
|
||||
<p>这笔购料随回收/置换原单保留,不能在购料页独立修改或删除。</p>
|
||||
<button type="button" className="quiet" data-action="close-material-purchase" onClick={close}>
|
||||
<LedgerButton type="button" className="quiet" data-action="close-material-purchase" onClick={close}>
|
||||
关闭
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
);
|
||||
if (p.canEdit === false && p.canRequestChange === false)
|
||||
@@ -284,7 +290,7 @@ export function PurchaseChange({
|
||||
<div className="material-purchase-review-fields" hidden={!approval}>
|
||||
<label>
|
||||
更正原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="change_reason"
|
||||
maxLength={200}
|
||||
rows={2}
|
||||
@@ -293,7 +299,7 @@ export function PurchaseChange({
|
||||
/>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input name="change_verified" type="checkbox" required={approval} />
|
||||
<LedgerInput name="change_verified" type="checkbox" required={approval} />
|
||||
已核对原始购料凭据与本次申请值,提交店主复核后再更正。
|
||||
</label>
|
||||
</div>
|
||||
@@ -303,12 +309,12 @@ export function PurchaseChange({
|
||||
{error}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="quiet" data-action="close-material-purchase" onClick={close}>
|
||||
<LedgerButton type="button" className="quiet" data-action="close-material-purchase" onClick={close}>
|
||||
取消
|
||||
</button>
|
||||
<button type="submit" className={edit ? 'primary' : 'danger'} disabled={blocked || stale}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" className={edit ? 'primary' : 'danger'} disabled={blocked || stale}>
|
||||
{approval ? '提交' + text + '申请' : edit ? '保存修改' : '确认删除购料'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
@@ -345,22 +351,22 @@ export function Settlement({ state, pool: p, actions }: { state: LedgerState; po
|
||||
<div className="grid three">
|
||||
<label>
|
||||
业务日期
|
||||
<input name="date" defaultValue={state.today} type="date" max={state.today} required />
|
||||
<LedgerInput name="date" defaultValue={state.today} type="date" max={state.today} required />
|
||||
</label>
|
||||
<label>
|
||||
转款方向
|
||||
<select name="direction" defaultValue={due < 0 ? 'toAssistant' : 'toOwner'}>
|
||||
<LedgerSelect name="direction" defaultValue={due < 0 ? 'toAssistant' : 'toOwner'}>
|
||||
<option value="toOwner">
|
||||
{assistant} → {owner}
|
||||
</option>
|
||||
<option value="toAssistant">
|
||||
{owner} → {assistant}
|
||||
</option>
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label>
|
||||
实际转账金额(元)
|
||||
<input
|
||||
<LedgerInput
|
||||
name="amount"
|
||||
defaultValue={(Math.abs(due) / 100).toFixed(2)}
|
||||
type="number"
|
||||
@@ -372,22 +378,22 @@ export function Settlement({ state, pool: p, actions }: { state: LedgerState; po
|
||||
</div>
|
||||
<label>
|
||||
凭据/备注(选填)
|
||||
<input name="note" type="text" maxLength={150} />
|
||||
<LedgerInput name="note" type="text" maxLength={150} />
|
||||
</label>
|
||||
<label className="check">
|
||||
<input name="verified" type="checkbox" required />
|
||||
<LedgerInput name="verified" type="checkbox" required />
|
||||
已核实双方实际转账。
|
||||
</label>
|
||||
<div id="material-settlement-error" aria-live="polite">
|
||||
{error}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="quiet" data-action="close-material-settlement" onClick={close}>
|
||||
<LedgerButton type="button" className="quiet" data-action="close-material-settlement" onClick={close}>
|
||||
取消
|
||||
</button>
|
||||
<button type="submit" className="primary" disabled={blocked}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked}>
|
||||
保存实际交款
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
type Purchase,
|
||||
} from './model';
|
||||
import type { FormActions } from './PurchaseForms';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput, LedgerTextArea } from '../../components/BusinessControls';
|
||||
|
||||
function time(value?: string) {
|
||||
const date = new Date(value || '');
|
||||
@@ -67,29 +68,34 @@ export function ChangePanel({
|
||||
<section className="panel material-change-panel">
|
||||
<div className="panel-title">
|
||||
<h2>{state.user.role === 'owner' ? '历史购料更正复核' : '我的历史购料更正'}</h2>
|
||||
<button type="button" data-action="material-change-refresh" className="quiet" onClick={() => reload(seq + 1)}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="material-change-refresh"
|
||||
className="quiet"
|
||||
onClick={() => reload(seq + 1)}
|
||||
>
|
||||
刷新更正申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<p className="small muted">历史购料修改或删除先提交申请,店主查看料价和订单影响后批准;待批期间仍按原值记账。</p>
|
||||
<div id="material-changes-list" aria-live="polite" aria-busy={busy}>
|
||||
{error ? (
|
||||
<div className="error">
|
||||
{error}{' '}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="quiet"
|
||||
data-action="material-change-refresh"
|
||||
onClick={() => reload(seq + 1)}
|
||||
>
|
||||
重新读取申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : list ? (
|
||||
<>
|
||||
<div className="material-change-tabs" role="group" aria-label="购料更正状态">
|
||||
{(['pending', 'approved', 'rejected', 'all'] as const).map((s, i) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={s}
|
||||
type="button"
|
||||
data-action="material-change-filter"
|
||||
@@ -104,65 +110,61 @@ export function ChangePanel({
|
||||
>
|
||||
{['待复核', '已批准', '已驳回', '全部'][i]}
|
||||
{s !== 'all' && '(' + list.counts[s] + ')'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
{list.rows.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="material-change-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>更正内容</th>
|
||||
<th>申请人/原因</th>
|
||||
<th>状态/处理意见</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{list.rows.map(r => (
|
||||
<tr key={r.id}>
|
||||
<td>
|
||||
{r.action === 'delete' ? '删除历史购料' : '修改历史购料'}
|
||||
{r.preview?.before && (
|
||||
<div className="small muted">
|
||||
{r.preview.before.date} · {grams(r.preview.before.mg)}g · {money(r.preview.before.amount)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{r.requester_name}
|
||||
<div className="small muted">{time(r.created)}</div>
|
||||
<div className="material-change-text">{r.reason}</div>
|
||||
</td>
|
||||
<td>
|
||||
<span className={'badge ' + (r.status === 'pending' ? 'warn' : '')}>
|
||||
{statuses[r.status]}
|
||||
</span>
|
||||
{r.stale && r.status === 'pending' && (
|
||||
<div className="small danger-text">原记录已变化,需重新核对。</div>
|
||||
)}
|
||||
{r.note && <div className="small material-change-text">{r.note}</div>}
|
||||
{r.reviewer_name && (
|
||||
<div className="small muted">
|
||||
{r.reviewer_name} · {time(r.reviewed)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<button
|
||||
type="button"
|
||||
className="quiet"
|
||||
data-action="material-change-open"
|
||||
data-id={r.id}
|
||||
onClick={() => open(r.id)}
|
||||
>
|
||||
{state.user.role === 'owner' && r.status === 'pending' ? '查看影响并复核' : '查看申请'}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="material-change-table"
|
||||
columns={[
|
||||
{ title: '更正内容' },
|
||||
{ title: '申请人/原因' },
|
||||
{ title: '状态/处理意见' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={list.rows.map(r => ({
|
||||
key: r.id,
|
||||
cells: [
|
||||
<>
|
||||
{r.action === 'delete' ? '删除历史购料' : '修改历史购料'}
|
||||
{r.preview?.before && (
|
||||
<div className="small muted">
|
||||
{r.preview.before.date} · {grams(r.preview.before.mg)}g · {money(r.preview.before.amount)}
|
||||
</div>
|
||||
)}
|
||||
</>,
|
||||
<>
|
||||
{r.requester_name}
|
||||
<div className="small muted">{time(r.created)}</div>
|
||||
<div className="material-change-text">{r.reason}</div>
|
||||
</>,
|
||||
<>
|
||||
<span className={'badge ' + (r.status === 'pending' ? 'warn' : '')}>{statuses[r.status]}</span>
|
||||
{r.stale && r.status === 'pending' && (
|
||||
<div className="small danger-text">原记录已变化,需重新核对。</div>
|
||||
)}
|
||||
{r.note && <div className="small material-change-text">{r.note}</div>}
|
||||
{r.reviewer_name && (
|
||||
<div className="small muted">
|
||||
{r.reviewer_name} · {time(r.reviewed)}
|
||||
</div>
|
||||
)}
|
||||
</>,
|
||||
<>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="quiet"
|
||||
data-action="material-change-open"
|
||||
data-id={r.id}
|
||||
onClick={() => open(r.id)}
|
||||
>
|
||||
{state.user.role === 'owner' && r.status === 'pending' ? '查看影响并复核' : '查看申请'}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="small muted material-rolling-empty">没有此状态的更正申请。</p>
|
||||
@@ -188,24 +190,16 @@ function Comparison({
|
||||
}) {
|
||||
return (
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table material-change-comparison" aria-label={label}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>核对项目</th>
|
||||
<th>{head[0]}</th>
|
||||
<th>{head[1]}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map(([name, a, b]) => (
|
||||
<tr key={name} className={highlight && a !== b ? 'material-change-different' : undefined}>
|
||||
<th scope="row">{name}</th>
|
||||
<td>{a}</td>
|
||||
<td>{b}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="material-detail-table material-change-comparison"
|
||||
aria-label={label}
|
||||
columns={[{ title: '核对项目', rowScope: 'row' }, { title: head[0] }, { title: head[1] }]}
|
||||
rows={rows.map(([name, a, b]) => ({
|
||||
key: name,
|
||||
attributes: { className: highlight && a !== b ? 'material-change-different' : undefined },
|
||||
cells: [name, a, b],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -335,27 +329,27 @@ export function EnableForm({
|
||||
onSubmit={onSubmit}
|
||||
>
|
||||
<label className="check">
|
||||
<input name="verified" type="checkbox" required disabled={blocked || stale} />
|
||||
<LedgerInput name="verified" type="checkbox" required disabled={blocked || stale} />
|
||||
已核对结转克重、金料成本及今日订单影响,确认从 {p.date} 起启用。
|
||||
</label>
|
||||
<div id="material-rolling-error" aria-live="polite">
|
||||
{error}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="quiet" data-action="material-rolling-close" onClick={close}>
|
||||
<LedgerButton type="button" className="quiet" data-action="material-rolling-close" onClick={close}>
|
||||
取消
|
||||
</button>
|
||||
<button type="submit" className="primary" disabled={stale || blocked}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" className="primary" disabled={stale || blocked}>
|
||||
确认启用跨日结转
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
<p className="error">{p.reason || '暂不能启用,请先核对材料记录。'}</p>
|
||||
<button type="button" data-action="material-rolling-enable-preview" className="quiet" onClick={reload}>
|
||||
<LedgerButton type="button" data-action="material-rolling-enable-preview" className="quiet" onClick={reload}>
|
||||
重新核对
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
@@ -390,9 +384,9 @@ export function ReviewForm({ r, state, actions }: { r: Change; state: LedgerStat
|
||||
['备注', p => p.note || '未填写'],
|
||||
];
|
||||
const closeButton = (
|
||||
<button type="button" data-action="material-rolling-close" className="quiet" onClick={close}>
|
||||
<LedgerButton type="button" data-action="material-rolling-close" className="quiet" onClick={close}>
|
||||
关闭
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
@@ -434,11 +428,11 @@ export function ReviewForm({ r, state, actions }: { r: Change; state: LedgerStat
|
||||
>
|
||||
<label>
|
||||
处理意见(批准时选填,驳回时必填)
|
||||
<textarea name="note" maxLength={200} rows={2} disabled={blocked || stale} />
|
||||
<LedgerTextArea name="note" maxLength={200} rows={2} disabled={blocked || stale} />
|
||||
</label>
|
||||
{approve && (
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required disabled={blocked || stale} />
|
||||
<LedgerInput type="checkbox" name="verified" required disabled={blocked || stale} />
|
||||
已核对原购料凭据、申请值与关联订单影响,确认批准本次更正。
|
||||
</label>
|
||||
)}
|
||||
@@ -447,7 +441,7 @@ export function ReviewForm({ r, state, actions }: { r: Change; state: LedgerStat
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
{closeButton}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="danger"
|
||||
data-action="material-change-reject"
|
||||
@@ -455,11 +449,11 @@ export function ReviewForm({ r, state, actions }: { r: Change; state: LedgerStat
|
||||
onClick={e => review(e.currentTarget.form!, 'reject')}
|
||||
>
|
||||
驳回申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{approve && (
|
||||
<button type="submit" className="primary" disabled={blocked || stale}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked || stale}>
|
||||
批准购料更正
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useRef, useEffect, type ReactNode } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { LedgerButton, LedgerDialog } from '../../components/BusinessControls';
|
||||
export function Dialog({
|
||||
id,
|
||||
label,
|
||||
@@ -12,16 +13,9 @@ export function Dialog({
|
||||
children: ReactNode;
|
||||
ownClose?: boolean;
|
||||
}) {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current!;
|
||||
node.showModal();
|
||||
return () => node.close();
|
||||
}, []);
|
||||
return (
|
||||
<dialog
|
||||
<LedgerDialog
|
||||
id={id}
|
||||
ref={ref}
|
||||
aria-label={label}
|
||||
onCancel={event => {
|
||||
event.preventDefault();
|
||||
@@ -29,11 +23,17 @@ export function Dialog({
|
||||
}}
|
||||
>
|
||||
{!ownClose && (
|
||||
<button type="button" className="dialog-close" data-action="close-dialog" aria-label={label} onClick={close}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
data-action="close-dialog"
|
||||
aria-label={label}
|
||||
onClick={close}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
{children}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
@@ -6,6 +6,7 @@ import { orderViews } from './orderViews';
|
||||
import { Dialog } from './Dialog';
|
||||
import { useRead } from './orderReads';
|
||||
import type { IndependentRequest } from './orderData';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
interface SaleProps {
|
||||
client: LedgerClient;
|
||||
@@ -241,23 +242,23 @@ export function IndependentAfterSale({
|
||||
}
|
||||
}
|
||||
const reread = (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
disabled={client.busy}
|
||||
data-action={review ? 'after-sale-change-open' : 'after-sale-edit'}
|
||||
data-id={id}
|
||||
>
|
||||
{review ? '重新读取申请并复核' : '重新读取售后'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
const feedback = error && (
|
||||
<div className="error" role="alert">
|
||||
{error}{' '}
|
||||
{id &&
|
||||
(client.pending() ? (
|
||||
<button type="button" data-action="retry" disabled={client.busy}>
|
||||
<LedgerButton type="button" data-action="retry" disabled={client.busy}>
|
||||
恢复原操作
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
reread
|
||||
))}
|
||||
@@ -269,18 +270,18 @@ export function IndependentAfterSale({
|
||||
if (receipt || (path && (review ? !request : !detail))) {
|
||||
content = (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="dialog-close"
|
||||
data-action={review ? 'after-sale-changes-close' : 'close-after-sale'}
|
||||
aria-label={review ? '关闭售后修改复核' : '关闭售后记录'}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2>{receipt || (review ? '售后修改复核' : '修改售后')}</h2>
|
||||
{read.error || error ? (
|
||||
<div className="error" role="alert">
|
||||
{read.error || error} {reread}
|
||||
{review && <button data-action="after-sale-changes-reload">返回申请列表</button>}
|
||||
{review && <LedgerButton data-action="after-sale-changes-reload">返回申请列表</LedgerButton>}
|
||||
</div>
|
||||
) : (
|
||||
<p role="status">{receipt ? '正在刷新…' : review ? '正在读取申请…' : '正在读取售后记录…'}</p>
|
||||
|
||||
@@ -36,6 +36,7 @@ type UpdateInput = (fields: Partial<EditInputs>) => void;
|
||||
import { Calc as LedgerCalc, Fees, Model, Values } from '../../shared';
|
||||
import { Button } from '../Settings/controls';
|
||||
import { Input, Choice } from './EditFields';
|
||||
import { LedgerButton, LedgerInput, LedgerTextArea } from '../../components/BusinessControls';
|
||||
const { yuan, grams, validateOrderIdentity } = Model;
|
||||
const feeCategories: Record<string, string> = {
|
||||
jd: 'shipping',
|
||||
@@ -440,7 +441,7 @@ function EditableFees({
|
||||
return (
|
||||
<div key={kind} className="order-cost-box">
|
||||
<label className="order-cost-option">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name={'cost_' + kind}
|
||||
checked={checked}
|
||||
@@ -466,7 +467,7 @@ function EditableFees({
|
||||
{row.byQuantity && (
|
||||
<label className="order-cost-quantity">
|
||||
{configured ? '数量(个)' : '盒子数量(个)'}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
name={'cost_' + kind + '_quantity'}
|
||||
min="1"
|
||||
@@ -548,7 +549,7 @@ function EditableFees({
|
||||
</Button>
|
||||
)}
|
||||
{!automatic && row.funding && (
|
||||
<input
|
||||
<LedgerInput
|
||||
type="hidden"
|
||||
className="cost-funding"
|
||||
data-component="fee"
|
||||
@@ -736,7 +737,7 @@ function LockLine({
|
||||
/>
|
||||
</div>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="lock_material_verified"
|
||||
checked={!!mat.verified}
|
||||
@@ -781,7 +782,7 @@ function LockLine({
|
||||
/>
|
||||
</div>
|
||||
<label className="check" hidden={pooledExtra}>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="lock_extra_verified"
|
||||
checked={!!extra.verified}
|
||||
@@ -1021,7 +1022,7 @@ export function LockOrderEditor({
|
||||
['returning', '老客户'],
|
||||
].map(([key, text]) => (
|
||||
<label key={key} title={key === 'new' ? '首次成交' : '再次成交'}>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="radio"
|
||||
name="customer_type"
|
||||
value={key}
|
||||
@@ -1056,7 +1057,7 @@ export function LockOrderEditor({
|
||||
</p>
|
||||
<label>
|
||||
客户单备注
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
maxLength={240}
|
||||
rows={2}
|
||||
@@ -1066,7 +1067,7 @@ export function LockOrderEditor({
|
||||
</label>
|
||||
<label>
|
||||
内部备注(客户不可见)<span className="small muted">必填,至少3个字符(含#号),最多500字</span>
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="internal_note"
|
||||
ref={textarea}
|
||||
maxLength={500}
|
||||
@@ -1085,7 +1086,7 @@ export function LockOrderEditor({
|
||||
<div data-order-note-tags className="order-note-tag-options" aria-label="内部备注快捷标签">
|
||||
{filteredTags.length ? (
|
||||
filteredTags.map(tag => (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="quiet"
|
||||
key={tag}
|
||||
@@ -1100,7 +1101,7 @@ export function LockOrderEditor({
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))
|
||||
) : (
|
||||
<span className="small muted">
|
||||
@@ -1160,7 +1161,7 @@ export function LockOrderEditor({
|
||||
</div>
|
||||
<label>
|
||||
修改原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="edit_reason"
|
||||
required
|
||||
maxLength={200}
|
||||
@@ -1171,7 +1172,7 @@ export function LockOrderEditor({
|
||||
/>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="edit_verified"
|
||||
required
|
||||
@@ -1185,14 +1186,14 @@ export function LockOrderEditor({
|
||||
<Button action="cancel-order-edit" className="quiet" onClick={onCancel}>
|
||||
取消修改
|
||||
</Button>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="primary"
|
||||
type="submit"
|
||||
data-order-edit-submit
|
||||
disabled={client.busy || !!client.pending() || entry.conflicted}
|
||||
>
|
||||
{approval ? '提交修改申请' : '保存修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div id="order-error" aria-live="polite">
|
||||
{serverFeedback}
|
||||
|
||||
@@ -38,6 +38,7 @@ import { navigate } from '../../lib/router';
|
||||
import { orderViews } from './orderViews';
|
||||
import { Dialog } from './Dialog';
|
||||
import { queues, useRead } from './orderReads';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
const stop = (e: SyntheticEvent) => {
|
||||
e.stopPropagation();
|
||||
@@ -59,19 +60,19 @@ function DetailNavigation({
|
||||
const i = ids.indexOf(id);
|
||||
return (
|
||||
<div className="order-detail-navigation-row" role="group" aria-label="切换订单">
|
||||
<button data-action="order-detail-prev" disabled={blocked || i <= 0} onClick={() => open(ids[i - 1])}>
|
||||
<LedgerButton data-action="order-detail-prev" disabled={blocked || i <= 0} onClick={() => open(ids[i - 1])}>
|
||||
← 上一条
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<span aria-live="polite">
|
||||
{i + 1} / {ids.length}
|
||||
</span>
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="order-detail-next"
|
||||
disabled={blocked || i < 0 || i >= ids.length - 1}
|
||||
onClick={() => open(ids[i + 1])}
|
||||
>
|
||||
下一条 →
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<small>按当前筛选后的销售订单顺序查看</small>
|
||||
</div>
|
||||
);
|
||||
@@ -526,12 +527,12 @@ export function OrderActionDialog({
|
||||
panel = (
|
||||
<>
|
||||
<fieldset disabled>{panel}</fieldset>
|
||||
<button type="button" onClick={refreshDetail}>
|
||||
<LedgerButton type="button" onClick={refreshDetail}>
|
||||
重新读取订单
|
||||
</button>
|
||||
<button type="button" onClick={clearForm} disabled={client.busy}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="button" onClick={clearForm} disabled={client.busy}>
|
||||
收起
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
);
|
||||
return (
|
||||
@@ -539,7 +540,7 @@ export function OrderActionDialog({
|
||||
<div id="order-content" onClick={onClick} onChange={onChange} onSubmit={submit}>
|
||||
{details.error ? (
|
||||
<p role="alert">
|
||||
{details.error} <button onClick={refreshDetail}>重新读取</button>
|
||||
{details.error} <LedgerButton onClick={refreshDetail}>重新读取</LedgerButton>
|
||||
</p>
|
||||
) : !order ? (
|
||||
'正在读取订单…'
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useOrderForm } from '../CreateOrder/useOrderForm';
|
||||
import { EditLine, EditFees, Input, Choice } from './EditFields';
|
||||
import { isRecord, errorMessage, errorStatus } from './readOrder';
|
||||
import { useRead } from './orderReads';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput, LedgerTextArea } from '../../components/BusinessControls';
|
||||
|
||||
interface SavedEdit {
|
||||
id: string;
|
||||
@@ -160,25 +161,18 @@ function ConflictPanel({
|
||||
{order.date} · {order.customer || '未填客户称呼'} · 开单人 {order.salesperson} · {order.payment_account} ·
|
||||
成交 {Model.orderAmount(order.total, order.rounding_mode)}
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['商品', '克重/数量', '成交金额', '货品成本'].map(label => (
|
||||
<th key={label}>{label}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{order.lines.map((line, i) => (
|
||||
<tr key={i}>
|
||||
<td>{line.name}</td>
|
||||
<td>{line.unit === 'g' ? Model.grams(line.quantity) + 'g' : line.quantity + '件'}</td>
|
||||
<td>¥{Model.yuan(line.sale)}</td>
|
||||
<td>{line.cost == null ? '待补' : '¥' + Model.yuan(line.cost)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[{ title: '商品' }, { title: '克重/数量' }, { title: '成交金额' }, { title: '货品成本' }]}
|
||||
rows={order.lines.map((line, i) => ({
|
||||
key: i,
|
||||
cells: [
|
||||
line.name,
|
||||
line.unit === 'g' ? Model.grams(line.quantity) + 'g' : line.quantity + '件',
|
||||
<>¥{Model.yuan(line.sale)}</>,
|
||||
line.cost == null ? '待补' : '¥' + Model.yuan(line.cost),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
<p>
|
||||
实际费用 ¥{Model.yuan(order.directCost)};客户单备注:{order.note || '无'}
|
||||
</p>
|
||||
@@ -189,17 +183,17 @@ function ConflictPanel({
|
||||
)}
|
||||
<div className="actions">
|
||||
{order ? (
|
||||
<button disabled={disabled} data-action="keep-order-edit" onClick={() => read('keep')}>
|
||||
<LedgerButton disabled={disabled} data-action="keep-order-edit" onClick={() => read('keep')}>
|
||||
已核对,保留草稿继续修改
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
<button disabled={disabled} data-action="reload-order-edit" onClick={() => read('review')}>
|
||||
<LedgerButton disabled={disabled} data-action="reload-order-edit" onClick={() => read('review')}>
|
||||
读取最新订单供核对
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<button disabled={disabled} data-action="reset-order-edit" onClick={() => read('reset')}>
|
||||
<LedgerButton disabled={disabled} data-action="reset-order-edit" onClick={() => read('reset')}>
|
||||
改用当前订单内容
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
@@ -356,8 +350,8 @@ export function OrderEditPage({ client, state, session, refreshState, registerLe
|
||||
<div className="business-pages">
|
||||
<h1>订单修改已保存</h1>
|
||||
<p>已更新原订单,原单号保留。</p>
|
||||
<button onClick={go}>查看修改后的订单</button>
|
||||
<button onClick={() => navigate('orders')}>重新读取订单</button>
|
||||
<LedgerButton onClick={go}>查看修改后的订单</LedgerButton>
|
||||
<LedgerButton onClick={() => navigate('orders')}>重新读取订单</LedgerButton>
|
||||
{error && <p role="alert">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
@@ -366,24 +360,24 @@ export function OrderEditPage({ client, state, session, refreshState, registerLe
|
||||
<div className="business-pages">
|
||||
<h1>修改订单</h1>
|
||||
<p>{id ? error || '正在读取已记录的订单…' : '请选择要修改的订单。'}</p>
|
||||
<button disabled={reading} onClick={() => read()}>
|
||||
<LedgerButton disabled={reading} onClick={() => read()}>
|
||||
重新读取订单
|
||||
</button>
|
||||
<button onClick={() => navigate('orders')}>返回订单列表</button>
|
||||
</LedgerButton>
|
||||
<LedgerButton onClick={() => navigate('orders')}>返回订单列表</LedgerButton>
|
||||
</div>
|
||||
);
|
||||
const serverFeedback = error && (
|
||||
<div role="alert" className="error">
|
||||
{error}
|
||||
{entry.conflicted && !entry.latest && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="reload-order-edit"
|
||||
disabled={reading || client.busy || !!client.pending()}
|
||||
onClick={() => read('review')}
|
||||
>
|
||||
读取最新订单供核对
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
@@ -522,7 +516,7 @@ function EditForm({
|
||||
['returning', '老客户'],
|
||||
].map(([k, l]) => (
|
||||
<label key={k}>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="radio"
|
||||
name="customer_type"
|
||||
value={k}
|
||||
@@ -547,7 +541,7 @@ function EditForm({
|
||||
<>
|
||||
<label>
|
||||
内部备注(客户不可见)<span className="small muted">必填,至少3个字符(含#号),最多500字</span>
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="internal_note"
|
||||
rows={3}
|
||||
required
|
||||
@@ -559,20 +553,20 @@ function EditForm({
|
||||
/>
|
||||
</label>
|
||||
{(Model.filterNoteTags(tags.value?.tags || [], form.internal_note) || []).map(tag => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={tag}
|
||||
type="button"
|
||||
onClick={() => set('internal_note')(Model.insertNoteTag(form.internal_note, tag))}
|
||||
>
|
||||
{tag}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
const note = (
|
||||
<label>
|
||||
客户单备注
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
maxLength={240}
|
||||
rows={finance ? 2 : 3}
|
||||
@@ -591,9 +585,9 @@ function EditForm({
|
||||
{entry.order.paper_number || entry.order.number} · {entry.order.date}
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" onClick={go}>
|
||||
<LedgerButton type="button" onClick={go}>
|
||||
取消修改
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div className="note" id="order-edit-save-intro">
|
||||
{(approval ? '店主复核同意后' : '保存后') +
|
||||
@@ -608,9 +602,9 @@ function EditForm({
|
||||
>
|
||||
{finance ? (
|
||||
<>
|
||||
<input type="hidden" name="rounding_mode" value={form.rounding_mode} />
|
||||
<input type="hidden" name="orderId" value={entry.id} />
|
||||
<input type="hidden" name="revision" value={entry.revision} />
|
||||
<LedgerInput type="hidden" name="rounding_mode" value={form.rounding_mode} />
|
||||
<LedgerInput type="hidden" name="orderId" value={entry.id} />
|
||||
<LedgerInput type="hidden" name="revision" value={entry.revision} />
|
||||
<section className="panel">
|
||||
<div className="panel-title">
|
||||
<h2>客户与单据</h2>
|
||||
@@ -665,9 +659,9 @@ function EditForm({
|
||||
{...{ index, line, state, ctx, form, update: change, reloadPools: loadPools, error: setError }}
|
||||
/>
|
||||
))}
|
||||
<button type="button" onClick={() => change(f => Model.addLine(f, ctx))}>
|
||||
<LedgerButton type="button" onClick={() => change(f => Model.addLine(f, ctx))}>
|
||||
+ 添加商品
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{poolError && <p role="alert">{poolError}</p>}
|
||||
</section>
|
||||
<EditFees {...{ store, state, update: change }} />
|
||||
@@ -708,7 +702,7 @@ function EditForm({
|
||||
</p>
|
||||
<label>
|
||||
修改原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="edit_reason"
|
||||
required
|
||||
rows={2}
|
||||
@@ -719,7 +713,7 @@ function EditForm({
|
||||
/>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="edit_verified"
|
||||
required
|
||||
@@ -731,12 +725,12 @@ function EditForm({
|
||||
: '已核实客户称呼、开单人及备注的本次更正。'}
|
||||
</label>
|
||||
<div className="form-actions">
|
||||
<button type="button" onClick={go}>
|
||||
<LedgerButton type="button" onClick={go}>
|
||||
取消修改
|
||||
</button>
|
||||
<button data-order-edit-submit disabled={blocked} className="primary" type="submit">
|
||||
</LedgerButton>
|
||||
<LedgerButton data-order-edit-submit disabled={blocked} className="primary" type="submit">
|
||||
{approval ? '提交修改申请' : '保存修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</section>
|
||||
<div id="order-error" aria-live="polite">
|
||||
|
||||
@@ -27,6 +27,7 @@ import { useCallback, useEffect, useState } from 'react';
|
||||
import { navigate, searchParam } from '../../lib/router';
|
||||
import { orderViews } from './orderViews';
|
||||
import { OrderActionDialog, IndependentAfterSale } from './OrderDialogs';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
|
||||
function initialFilters(state: LedgerState): Filters {
|
||||
const defaults: Filters = { mode: 'today', date: '', from: '', to: '', q: '', status: '', member: '', pocket: '' };
|
||||
@@ -304,26 +305,26 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
</summary>
|
||||
<div className="order-review-options">
|
||||
{queues.map(([kind, , name, action, id], i) => (
|
||||
<button key={kind} type="button" id={id} data-action={action}>
|
||||
<LedgerButton key={kind} type="button" id={id} data-action={action}>
|
||||
{name}
|
||||
{kind === 'after-sale' ? (state.user.role === 'owner' ? '复核' : '申请') : ''}(
|
||||
{counts.value?.[i] ?? '…'})
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
</details>
|
||||
<button type="button" data-action="new-after-sale">
|
||||
<LedgerButton type="button" data-action="new-after-sale">
|
||||
新增售后费用
|
||||
</button>
|
||||
<button type="button" data-action="refresh">
|
||||
</LedgerButton>
|
||||
<LedgerButton type="button" data-action="refresh">
|
||||
刷新
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
<div className="order-book-dates">
|
||||
<div className="order-period-buttons" role="group" aria-label="订单日期">
|
||||
{views.orderBookPeriodOptions.map(([value, name]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
key={value}
|
||||
data-action="order-period"
|
||||
@@ -331,12 +332,12 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
aria-pressed={value === filters.mode}
|
||||
>
|
||||
{name}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
<label id="order-single-date" hidden={filters.mode !== 'date'}>
|
||||
指定日期
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
id="order-date"
|
||||
value={filters.mode === 'date' ? filters.date : range?.date || state.today}
|
||||
@@ -350,7 +351,7 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
{(['from', 'to'] as const).map((key, i) => (
|
||||
<label key={key}>
|
||||
{i ? '结束' : '开始'}日期
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
id={'order-' + key}
|
||||
value={filters[key]}
|
||||
@@ -372,7 +373,7 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
</details>
|
||||
<section className="panel order-book-panel">
|
||||
<div className="filters order-book-filters">
|
||||
<input
|
||||
<LedgerInput
|
||||
id="order-search"
|
||||
aria-label="搜索订单(单号、客户、商品或克重)"
|
||||
value={filters.q}
|
||||
@@ -380,35 +381,35 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
maxLength={100}
|
||||
onChange={e => filter({ q: e.target.value })}
|
||||
/>
|
||||
<select
|
||||
<LedgerSelect
|
||||
id="order-filter"
|
||||
aria-label="筛选状态"
|
||||
value={filters.status}
|
||||
onChange={e => filter({ status: e.target.value })}
|
||||
>
|
||||
{options(views.orderBookStatusOptions)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
<label>
|
||||
出货货盘
|
||||
<select
|
||||
<LedgerSelect
|
||||
id="order-pocket-filter"
|
||||
aria-label="出货货盘"
|
||||
value={filters.pocket}
|
||||
onChange={e => filter({ pocket: e.target.value })}
|
||||
>
|
||||
{options(views.orderBookPocketOptions())}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
{state.user.role === 'owner' && memberOptions.length > 0 && (
|
||||
<label>
|
||||
订单归属
|
||||
<select
|
||||
<LedgerSelect
|
||||
id="order-member-filter"
|
||||
value={filters.member}
|
||||
onChange={e => filter({ member: e.target.value })}
|
||||
>
|
||||
{options([['', '全部成员'], ...memberOptions])}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
)}
|
||||
<span id="order-book-count">{content?.count}</span>
|
||||
@@ -418,7 +419,7 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
<div id="order-list" aria-live="polite">
|
||||
{bookError ? (
|
||||
<p role="alert">
|
||||
{bookError} <button onClick={refresh}>重新读取</button>
|
||||
{bookError} <LedgerButton onClick={refresh}>重新读取</LedgerButton>
|
||||
</p>
|
||||
) : (
|
||||
(content?.list ?? '正在读取订单…')
|
||||
@@ -435,7 +436,7 @@ export function OrdersPage({ client, state, session, refreshState, saleListStatu
|
||||
<p className="small muted">{queueInfo[3]}</p>
|
||||
{list.error ? (
|
||||
<p>
|
||||
{list.error} <button onClick={refresh}>重新读取</button>
|
||||
{list.error} <LedgerButton onClick={refresh}>重新读取</LedgerButton>
|
||||
</p>
|
||||
) : (
|
||||
review || '正在读取…'
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useState } from 'react';
|
||||
import { Calc as LedgerCalc } from '../../../shared';
|
||||
import type { OrderLine } from '../orderData';
|
||||
import type { SharedViews } from '../viewTypes';
|
||||
import { LedgerInput, LedgerSelect } from '../../../components/BusinessControls';
|
||||
type CostModeKey = 'material' | 'labor';
|
||||
type CostInputs = Record<string, string>;
|
||||
type LineProps = { line: OrderLine; index: number; members: SharedViews['teamMemberOptions']; fallback: string } & Pick<
|
||||
@@ -64,7 +65,7 @@ export function LegacyCostRow({ line, index, members, fallback, choice, opts, gr
|
||||
const amount = (key: string, title: string, value: string, gram = false) => (
|
||||
<label>
|
||||
{title}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
name={prefix + key}
|
||||
min="0"
|
||||
@@ -116,7 +117,7 @@ export function LegacyCostRow({ line, index, members, fallback, choice, opts, gr
|
||||
<div className="grid purchase-cost-grid">
|
||||
<label>
|
||||
{material ? '进货料费方式' : '进货工费方式'}
|
||||
<select
|
||||
<LedgerSelect
|
||||
name={prefix + key + 'Mode'}
|
||||
value={modes[key]}
|
||||
onChange={event => updateMode(key, event.target.value, value)}
|
||||
@@ -125,11 +126,11 @@ export function LegacyCostRow({ line, index, members, fallback, choice, opts, gr
|
||||
{material ? '按克料价' : '克工费'}
|
||||
</option>
|
||||
<option value="total">{material ? '直接填总料费' : '总工费'}</option>
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
<label hidden={!gram}>
|
||||
{material ? '进货料价(元/克)' : '进货克工费(元/克)'}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
name={prefix + key + 'Rate'}
|
||||
min="0"
|
||||
@@ -144,7 +145,7 @@ export function LegacyCostRow({ line, index, members, fallback, choice, opts, gr
|
||||
{amount(key, material ? '料费成本合计(元)' : '进货总工费(元)', value, gram)}
|
||||
<label className="purchase-payer">
|
||||
{material ? '料费付款人' : '进货工费付款人'}
|
||||
<select
|
||||
<LedgerSelect
|
||||
required
|
||||
name={prefix + key + 'Payer'}
|
||||
defaultValue={options.some(([id]) => id === payer) ? payer : ''}
|
||||
@@ -155,7 +156,7 @@ export function LegacyCostRow({ line, index, members, fallback, choice, opts, gr
|
||||
</option>
|
||||
)}
|
||||
{opts(options)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
</div>
|
||||
<p className="purchase-formula small muted" aria-live="polite">
|
||||
|
||||
@@ -10,6 +10,14 @@ import type {
|
||||
import type { OrderContext, SharedViews } from '../viewTypes';
|
||||
import { Children } from 'react';
|
||||
import { Calc as LedgerCalc, Values } from '../../../shared';
|
||||
import {
|
||||
LedgerButton,
|
||||
LedgerDataTable,
|
||||
LedgerInput,
|
||||
LedgerSelect,
|
||||
LedgerTable,
|
||||
LedgerTextArea,
|
||||
} from '../../../components/BusinessControls';
|
||||
function object(value: unknown): value is Record<string, unknown> {
|
||||
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
||||
}
|
||||
@@ -84,11 +92,17 @@ export function afterSales(
|
||||
<h3>{kind === 'approve' ? '同意售后修改' : '驳回售后修改'}</h3>
|
||||
<label>
|
||||
{kind === 'approve' ? '复核备注(选填)' : '驳回意见'}
|
||||
<textarea disabled={ui.blocked} name="note" rows={2} maxLength={200} required={kind === 'reject'}></textarea>
|
||||
<LedgerTextArea
|
||||
disabled={ui.blocked}
|
||||
name="note"
|
||||
rows={2}
|
||||
maxLength={200}
|
||||
required={kind === 'reject'}
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
{kind === 'approve' ? (
|
||||
<label className="check">
|
||||
<input disabled={ui.blocked} type="checkbox" name="verified" required />
|
||||
<LedgerInput disabled={ui.blocked} type="checkbox" name="verified" required />
|
||||
已核对原值、申请值、日期、金额和付款人。
|
||||
</label>
|
||||
) : (
|
||||
@@ -96,9 +110,9 @@ export function afterSales(
|
||||
)}
|
||||
<div className="form-actions">
|
||||
{button('取消', 'after-sale-review-cancel', 'quiet', { disabled: ui.busy })}
|
||||
<button type="submit" disabled={ui.blocked} className={kind === 'approve' ? 'primary' : ''}>
|
||||
<LedgerButton type="submit" disabled={ui.blocked} className={kind === 'approve' ? 'primary' : ''}>
|
||||
{kind === 'approve' ? '确认同意修改' : '确认驳回申请'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
@@ -107,9 +121,9 @@ export function afterSales(
|
||||
const canReview = state.user.role === 'owner' && request.status === 'pending';
|
||||
return (
|
||||
<>
|
||||
<button className="dialog-close" data-action="after-sale-changes-close" aria-label="关闭售后修改复核">
|
||||
<LedgerButton className="dialog-close" data-action="after-sale-changes-close" aria-label="关闭售后修改复核">
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id="after-sale-changes-title">售后修改{request.status === 'pending' ? '复核' : '记录'}</h2>
|
||||
<div className="actions">{button('返回申请列表', 'after-sale-changes-reload', 'quiet')}</div>
|
||||
<p>
|
||||
@@ -247,7 +261,7 @@ export function afterSales(
|
||||
};
|
||||
return (
|
||||
<div className="table-wrap after-sale-comparison">
|
||||
<table className="order-change-table" aria-label="售后修改原值与申请值对照">
|
||||
<LedgerTable className="order-change-table" aria-label="售后修改原值与申请值对照">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>核对项目</th>
|
||||
@@ -262,7 +276,7 @@ export function afterSales(
|
||||
{pair('金额', 'amount', value => '¥' + yuan(Number(value)))}
|
||||
{pair('谁支付', 'payer', teamMemberName)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -288,9 +302,9 @@ export function afterSales(
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<button className="dialog-close" data-action="close-after-sale" aria-label="关闭售后记录">
|
||||
<LedgerButton className="dialog-close" data-action="close-after-sale" aria-label="关闭售后记录">
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id="after-sale-title">修改售后</h2>
|
||||
{detail.permissions.canEdit ? (
|
||||
<form id="after-sale-edit-form" data-id={record.id} data-approval={String(ui.approval)}>
|
||||
@@ -321,7 +335,12 @@ export function afterSales(
|
||||
</div>
|
||||
<label>
|
||||
修改说明(选填)
|
||||
<textarea name="reason" rows={2} maxLength={200} placeholder="例如:售后金额或付款人录错。"></textarea>
|
||||
<LedgerTextArea
|
||||
name="reason"
|
||||
rows={2}
|
||||
maxLength={200}
|
||||
placeholder="例如:售后金额或付款人录错。"
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</fieldset>
|
||||
<div id="after-sale-edit-error" aria-live="polite">
|
||||
@@ -331,9 +350,9 @@ export function afterSales(
|
||||
<span className="small muted">金额可填 0。归属沿用原记录。</span>
|
||||
<div className="actions">
|
||||
{button('取消', 'close-after-sale', 'quiet', { disabled: ui.busy })}
|
||||
<button type="submit" disabled={ui.blocked} className="primary">
|
||||
<LedgerButton type="submit" disabled={ui.blocked} className="primary">
|
||||
{ui.approval ? '提交修改申请' : '直接保存修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -364,17 +383,17 @@ export function afterSales(
|
||||
) : (
|
||||
<label>
|
||||
订单归属(经营款与业绩)
|
||||
<input defaultValue={teamMemberName(selected)} readOnly />
|
||||
<input type="hidden" name="member" defaultValue={selected} />
|
||||
<LedgerInput defaultValue={teamMemberName(selected)} readOnly />
|
||||
<LedgerInput type="hidden" name="member" defaultValue={selected} />
|
||||
</label>
|
||||
);
|
||||
}
|
||||
function newIndependentSale() {
|
||||
return (
|
||||
<>
|
||||
<button className="dialog-close" data-action="close-after-sale" aria-label="关闭新增售后">
|
||||
<LedgerButton className="dialog-close" data-action="close-after-sale" aria-label="关闭新增售后">
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id="after-sale-title">新增售后</h2>
|
||||
<p className="small muted">售后费用计入所选日期,并扣减当天利润。</p>
|
||||
<form id="after-sale-form">
|
||||
@@ -397,12 +416,12 @@ export function afterSales(
|
||||
{orderMemberField()}
|
||||
<label>
|
||||
谁支付
|
||||
<select name="payer" required defaultValue="">
|
||||
<LedgerSelect name="payer" required defaultValue="">
|
||||
<option value="" disabled>
|
||||
请选择
|
||||
</option>
|
||||
{opts(teamMemberOptions())}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
</div>
|
||||
<div id="after-sale-error" aria-live="polite">
|
||||
@@ -412,9 +431,9 @@ export function afterSales(
|
||||
<span className="small muted">金额可填 0,请按实际支出填写。</span>
|
||||
<div className="actions">
|
||||
{button('取消', 'close-after-sale', 'quiet')}
|
||||
<button className="primary" type="submit">
|
||||
<LedgerButton className="primary" type="submit">
|
||||
保存售后
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -648,13 +667,13 @@ export function afterSales(
|
||||
})}
|
||||
<label>
|
||||
售后原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="reason"
|
||||
rows={2}
|
||||
maxLength={200}
|
||||
required
|
||||
placeholder="填写客户实际退货退款原因。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</div>
|
||||
<section className="order-after-sale-products">
|
||||
@@ -678,13 +697,13 @@ export function afterSales(
|
||||
</div>
|
||||
<label>
|
||||
扣留款原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="deduction_reason"
|
||||
required={ui.reasonRequired}
|
||||
rows={2}
|
||||
maxLength={200}
|
||||
placeholder="有扣留款时填写,如约定扣除不可退工费或实际损耗。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
<p className="small muted">扣留款与支付渠道手续费分开核对。原单已经发生的支付手续费、邮费等成本继续保留。</p>
|
||||
</section>
|
||||
@@ -697,9 +716,14 @@ export function afterSales(
|
||||
<div id="order-after-sale-expenses">{ui.expenses}</div>
|
||||
</section>
|
||||
<div className="form-actions">
|
||||
<button type="button" className="primary" data-action="order-after-sale-preview" disabled={ui.previewLoading}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="primary"
|
||||
data-action="order-after-sale-preview"
|
||||
disabled={ui.previewLoading}
|
||||
>
|
||||
核对售后预览
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<span className="small muted" id="order-after-sale-preview-status" aria-live="polite">
|
||||
{ui.previewStatus || '填好后先预览,核对回库、回料、退款和利润。'}
|
||||
</span>
|
||||
@@ -711,23 +735,23 @@ export function afterSales(
|
||||
})}
|
||||
</div>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required disabled={!ui.preview} />
|
||||
<LedgerInput type="checkbox" name="verified" required disabled={!ui.preview} />
|
||||
已按实际退回商品、退款凭据和新增成本,核对以下预览。
|
||||
</label>
|
||||
<div id="order-after-sale-error" aria-live="polite">
|
||||
{ui.afterError && (
|
||||
<div className="error">
|
||||
{ui.afterError}{' '}
|
||||
<button type="button" data-action="reload-order-change">
|
||||
<LedgerButton type="button" data-action="reload-order-change">
|
||||
重新读取订单
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="primary" data-order-after-sale-submit="" disabled={!ui.preview}>
|
||||
<LedgerButton type="submit" className="primary" data-order-after-sale-submit="" disabled={!ui.preview}>
|
||||
{orderAfterSaleApproval(ui.date) ? '提交售后申请' : '确认并保存售后'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('收起', 'order-after-sale-close', 'quiet')}
|
||||
</div>
|
||||
</form>
|
||||
@@ -826,49 +850,43 @@ export function afterSales(
|
||||
</div>
|
||||
{rows.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="change-list-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>售后记录</th>
|
||||
<th>修改后日期</th>
|
||||
<th>申请人</th>
|
||||
<th>申请时间</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
rows.map(request => (
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{request.before.customer}</strong>
|
||||
<div className="small muted">
|
||||
{request.before.date} · {request.before.project}
|
||||
</div>
|
||||
</td>
|
||||
<td>{request.after.date}</td>
|
||||
<td>{request.requesterName || '未提供'}</td>
|
||||
<td>{afterSaleTime(request.created)}</td>
|
||||
<td>
|
||||
{afterSaleStatus(request)}
|
||||
{request.stale ? <div className="small danger-text">原记录已有变动</div> : ''}
|
||||
</td>
|
||||
<td>
|
||||
{button(
|
||||
state.user.role === 'owner' && request.status === 'pending' ? '查看并复核' : '查看修改',
|
||||
'after-sale-change-open',
|
||||
'',
|
||||
{
|
||||
'data-id': request.id,
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="change-list-table"
|
||||
columns={[
|
||||
{ title: '售后记录' },
|
||||
{ title: '修改后日期' },
|
||||
{ title: '申请人' },
|
||||
{ title: '申请时间' },
|
||||
{ title: '状态' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={rows.map((request, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
<>
|
||||
<strong>{request.before.customer}</strong>
|
||||
<div className="small muted">
|
||||
{request.before.date} · {request.before.project}
|
||||
</div>
|
||||
</>,
|
||||
request.after.date,
|
||||
request.requesterName || '未提供',
|
||||
afterSaleTime(request.created),
|
||||
<>
|
||||
{afterSaleStatus(request)}
|
||||
{request.stale ? <div className="small danger-text">原记录已有变动</div> : ''}
|
||||
</>,
|
||||
button(
|
||||
state.user.role === 'owner' && request.status === 'pending' ? '查看并复核' : '查看修改',
|
||||
'after-sale-change-open',
|
||||
'',
|
||||
{
|
||||
'data-id': request.id,
|
||||
},
|
||||
),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="empty">没有符合状态的售后修改申请。</p>
|
||||
|
||||
@@ -13,6 +13,7 @@ interface ActionInput extends Record<string, unknown> {
|
||||
import type { OrderContext, SharedViews } from '../viewTypes';
|
||||
import { Children } from 'react';
|
||||
import { Cards as CreditCardFees, Calc as LedgerCalc } from '../../../shared';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect, LedgerTextArea } from '../../../components/BusinessControls';
|
||||
export function orderActions(
|
||||
{ currentOrder, ui = {}, state }: OrderContext,
|
||||
{
|
||||
@@ -143,18 +144,18 @@ export function orderActions(
|
||||
) : (
|
||||
<label>
|
||||
<span id="order-action-reason-label">{approval ? '申请原因' : '登记原因'}</span>
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="change_reason"
|
||||
maxLength={200}
|
||||
rows={2}
|
||||
required
|
||||
placeholder="写清本次需要登记或更正的原因。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
)}
|
||||
{['cost', 'expense'].includes(kind) ? (
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实本次金额、实际付款人与凭据一致。
|
||||
</label>
|
||||
) : (
|
||||
@@ -217,7 +218,7 @@ export function orderActions(
|
||||
<div className="credit-card-fields">
|
||||
<label>
|
||||
手续费(元,自动)
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
@@ -229,9 +230,9 @@ export function orderActions(
|
||||
</label>
|
||||
<label>
|
||||
手续费付款人
|
||||
<select name="credit_card_fee_payer" defaultValue={payer} required={!!visible} disabled={!visible}>
|
||||
<LedgerSelect name="credit_card_fee_payer" defaultValue={payer} required={!!visible} disabled={!visible}>
|
||||
{opts(teamMemberOptions())}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
</div>
|
||||
<p className="small muted" data-credit-card-formula="" aria-live="polite">
|
||||
@@ -284,7 +285,7 @@ export function orderActions(
|
||||
{choice('收款方式', 'payment_method', methods, identity?.channel || '微信')}
|
||||
<label>
|
||||
收款人
|
||||
<select
|
||||
<LedgerSelect
|
||||
name="payment_recipient"
|
||||
key={card ? 'card' : 'standard'}
|
||||
defaultValue={card ? '麦麦' : ui.recipient || prefix}
|
||||
@@ -293,7 +294,7 @@ export function orderActions(
|
||||
disabled={card}
|
||||
>
|
||||
{opts(recipients)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
{creditCardAvailable() ? (
|
||||
<small className="small muted payment-account-note" hidden={!card}>
|
||||
信用卡统一由{teamMemberName('owner')}收款。
|
||||
@@ -346,7 +347,7 @@ export function orderActions(
|
||||
)}
|
||||
</div>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实实际支付,没有发生的费用已填0。
|
||||
</label>
|
||||
</>
|
||||
@@ -378,7 +379,7 @@ export function orderActions(
|
||||
placeholder: '交易凭据末几位或说明',
|
||||
})}
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已在实际账户核实{action === 'receipt' ? '到账' : '退款成功'},不是仅收到客户截图。
|
||||
</label>
|
||||
</>
|
||||
@@ -445,7 +446,7 @@ export function orderActions(
|
||||
补齐这张旧单的销售记账:按填写金额记录实际费用、从原货盘扣减黄金并计入销售与利润。款项未收齐或成本金额有空白时,请先补齐。
|
||||
</p>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实全额收款、商品已交付,所填费用为实际已付金额,没有发生的已填0。
|
||||
</label>
|
||||
</>
|
||||
@@ -494,7 +495,7 @@ export function orderActions(
|
||||
本入口办理整单退货,原销售额与货品成本在退货日冲回。已花费的运费等仍保留。换货先退原单,再开新单;部分退货暂未开放。
|
||||
</div>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实本单全部商品退回,所选去向与实际一致。
|
||||
</label>
|
||||
</>
|
||||
@@ -539,7 +540,7 @@ export function orderActions(
|
||||
: `货款待结 ¥${yuan(o.costDue)};利润待结 ¥${yuan(o.profitDue)}(负数为${teamMemberName('owner')}需转回)。`}
|
||||
</p>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实各人实际转账,不是仅记录计划交款。
|
||||
</label>
|
||||
</>
|
||||
@@ -590,9 +591,9 @@ export function orderActions(
|
||||
{moneyField('更正后金额(元)', 'amount')}
|
||||
<label>
|
||||
更正后收退款账户(仅收退款)
|
||||
<select name="account" defaultValue="助理微信">
|
||||
<LedgerSelect name="account" defaultValue="助理微信">
|
||||
{opts(activePaymentAccounts())}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
<small className="small muted correction-card-note" hidden={!isCreditCardAccount(ui.values?.account)}>
|
||||
信用卡统一由{teamMemberName('owner')}收款。
|
||||
</small>
|
||||
@@ -622,7 +623,7 @@ export function orderActions(
|
||||
maxLength: 200,
|
||||
})}
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实原凭据,这次是修正登记错误。
|
||||
</label>
|
||||
</>
|
||||
@@ -662,9 +663,9 @@ export function orderActions(
|
||||
<div className="error">
|
||||
{ui.actionError}
|
||||
{ui.retryKey && (
|
||||
<button type="submit" formNoValidate data-retry-key={ui.retryKey} disabled={!!ui.retryBusy}>
|
||||
<LedgerButton type="submit" formNoValidate data-retry-key={ui.retryKey} disabled={!!ui.retryBusy}>
|
||||
恢复原操作
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
{ui.stale && <> {button('重新读取订单后申请', 'reload-order-change')}</>}
|
||||
</div>
|
||||
@@ -675,7 +676,7 @@ export function orderActions(
|
||||
html
|
||||
)}
|
||||
<div className="form-actions">
|
||||
<button
|
||||
<LedgerButton
|
||||
className="primary"
|
||||
disabled={!!ui.stale || !!ui.actionBlocked}
|
||||
{...(changeForm
|
||||
@@ -685,7 +686,7 @@ export function orderActions(
|
||||
: {})}
|
||||
>
|
||||
{requiresApproval ? '提交变更申请' : changeForm ? '核实并保存' : '确认保存'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('收起', 'hide-action', 'quiet')}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { BookData, BookRow, BookSummary, LockActivity, MoneyKey } from '../
|
||||
import type { OrderContext, SharedViews } from '../viewTypes';
|
||||
import { Children, Fragment } from 'react';
|
||||
import { Values } from '../../../shared';
|
||||
import { LedgerButton, LedgerDataTable, LedgerTable } from '../../../components/BusinessControls';
|
||||
export function orderBook(
|
||||
{ orderBookFilters, state }: OrderContext,
|
||||
{
|
||||
@@ -84,37 +85,34 @@ export function orderBook(
|
||||
<details>
|
||||
<summary>查看 {rows.length} 项收付记录</summary>
|
||||
<div className="table-wrap">
|
||||
<table className="lock-activity-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期/锁价单</th>
|
||||
<th>项目/客户</th>
|
||||
<th>账户/付款人</th>
|
||||
<th className="number">金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
rows.map(item => (
|
||||
<tr>
|
||||
<td>
|
||||
{item.date}
|
||||
<br />
|
||||
<button className="link-button" data-action="open-price-lock" data-id={item.price_lock_id}>
|
||||
{item.number || '锁价记录'}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
{item.activityType} · {item.activityName}
|
||||
<div className="small muted">{item.customer}</div>
|
||||
</td>
|
||||
<td>{item.who}</td>
|
||||
<td className="number">{item.amount == null ? '待补齐' : '¥' + yuan(item.amount)}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="lock-activity-table"
|
||||
columns={[
|
||||
{ title: '日期/锁价单' },
|
||||
{ title: '项目/客户' },
|
||||
{ title: '账户/付款人' },
|
||||
{ title: '金额', headerClassName: 'number' },
|
||||
]}
|
||||
rows={rows.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, undefined, 'number'],
|
||||
cells: [
|
||||
<>
|
||||
{item.date}
|
||||
<br />
|
||||
<LedgerButton className="link-button" data-action="open-price-lock" data-id={item.price_lock_id}>
|
||||
{item.number || '锁价记录'}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
<>
|
||||
{item.activityType} · {item.activityName}
|
||||
<div className="small muted">{item.customer}</div>
|
||||
</>,
|
||||
item.who,
|
||||
item.amount == null ? '待补齐' : '¥' + yuan(item.amount),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
@@ -383,7 +381,7 @@ export function orderBook(
|
||||
function orderBookIdentity(row: BookRow, version: number | undefined = undefined) {
|
||||
if (row.kind === 'orderAfterSale')
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="open-order"
|
||||
data-id={row.order_id || row.id}
|
||||
@@ -391,12 +389,12 @@ export function orderBook(
|
||||
<strong className="order-book-customer-name">{row.customer || '未填称呼'}</strong>
|
||||
<span className="order-book-secondary muted">订单售后 · {row.paper_number || row.number}</span>
|
||||
<span className="small muted">查看原单售后结果</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
if (row.kind === 'recovery')
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="recovery-open"
|
||||
data-id={row.recovery_id || row.id}
|
||||
@@ -407,7 +405,7 @@ export function orderBook(
|
||||
</span>
|
||||
<span className="order-book-secondary muted">{row.number}</span>
|
||||
<span className="order-book-recovery-payment">回收付款 ¥{yuan(row.cashPayment)}</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('打印', 'recovery-print', 'quiet order-book-recovery-print', {
|
||||
'data-id': row.recovery_id || row.id,
|
||||
'aria-label': '打印 ' + (row.customer || '客户') + ' 的回收单',
|
||||
@@ -434,7 +432,7 @@ export function orderBook(
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="open-order"
|
||||
data-id={row.id}
|
||||
@@ -442,7 +440,7 @@ export function orderBook(
|
||||
>
|
||||
{customer}
|
||||
<span className="order-book-secondary muted">{row.paper_number || row.number}</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
if (row.kind === 'afterSale')
|
||||
@@ -454,7 +452,7 @@ export function orderBook(
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link"
|
||||
data-action="open-order"
|
||||
data-id={row.id}
|
||||
@@ -462,7 +460,7 @@ export function orderBook(
|
||||
>
|
||||
<strong>{row.paper_number || row.number}</strong>
|
||||
<span>{row.customer || '未填称呼'}</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
const card = (title: string, value: ReactNode, hint: ReactNode = '', emphasis = false) => (
|
||||
@@ -659,7 +657,7 @@ export function orderBook(
|
||||
}
|
||||
const table = (
|
||||
<div className="table-wrap order-book-table-wrap">
|
||||
<table className="order-book-table" aria-label={range.name + '订单账本'}>
|
||||
<LedgerTable className="order-book-table" aria-label={range.name + '订单账本'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th className="order-index">序号</th>
|
||||
@@ -805,7 +803,7 @@ export function orderBook(
|
||||
<td></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
);
|
||||
return {
|
||||
|
||||
@@ -6,6 +6,7 @@ type CostRow = ReturnType<typeof import('../../../../../public/calculations.js')
|
||||
import type { OrderContext, SharedViews } from '../viewTypes';
|
||||
import { Children, Fragment } from 'react';
|
||||
import { Calc as LedgerCalc } from '../../../shared';
|
||||
import { LedgerDataTable, LedgerTable } from '../../../components/BusinessControls';
|
||||
export function orderDetail(
|
||||
{ currentOrder, state, detailForm, error, navigation }: OrderContext,
|
||||
{
|
||||
@@ -84,30 +85,19 @@ export function orderDetail(
|
||||
].sort((a, b) => a.date.localeCompare(b.date));
|
||||
return rows.length ? (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>业务</th>
|
||||
<th>金额</th>
|
||||
<th>账户/经办人</th>
|
||||
<th>说明</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
rows.map(r => (
|
||||
<tr>
|
||||
<td>{r.date}</td>
|
||||
<td>{r.type}</td>
|
||||
<td>¥{yuan(r.amount)}</td>
|
||||
<td>{r.who}</td>
|
||||
<td>{r.note}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '日期' },
|
||||
{ title: '业务' },
|
||||
{ title: '金额' },
|
||||
{ title: '账户/经办人' },
|
||||
{ title: '说明' },
|
||||
]}
|
||||
rows={rows.map((r, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [r.date, r.type, <>¥{yuan(r.amount)}</>, r.who, r.note],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="muted">还没有收退款、费用或交款记录。</p>
|
||||
@@ -224,7 +214,7 @@ export function orderDetail(
|
||||
const names = Object.fromEntries(teamMemberKeys().map(member => [member, teamMemberName(member)]));
|
||||
return (
|
||||
<div className="table-wrap">
|
||||
<table className="detail-cost-table" aria-label={label}>
|
||||
<LedgerTable className="detail-cost-table" aria-label={label}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>成本项目</th>
|
||||
@@ -284,7 +274,7 @@ export function orderDetail(
|
||||
}),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,13 @@
|
||||
import type { CancellationRequest, OwnershipRequest, ChangeRequest, ReviewList, CancelSummary } from '../orderData';
|
||||
import type { OrderContext, SharedViews } from '../viewTypes';
|
||||
import { Children } from 'react';
|
||||
import {
|
||||
LedgerButton,
|
||||
LedgerDataTable,
|
||||
LedgerInput,
|
||||
LedgerSelect,
|
||||
LedgerTextArea,
|
||||
} from '../../../components/BusinessControls';
|
||||
export function orderReviews(
|
||||
{
|
||||
state,
|
||||
@@ -67,64 +74,58 @@ export function orderReviews(
|
||||
</div>
|
||||
{result.requests.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="cancellation-list-table" aria-label="全部日期的取消申请">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>原订单/日期</th>
|
||||
<th>经办/申请人及时间</th>
|
||||
<th>取消原因</th>
|
||||
<th>状态/处理记录</th>
|
||||
<th>查看</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
result.requests.map(request => (
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{request.order_number}</strong>
|
||||
<div className="small muted">{request.order_date}</div>
|
||||
<div className="small">原成交 ¥{yuan(request.summary.total)}</div>
|
||||
</td>
|
||||
<td>
|
||||
{request.direct === true ? '经办人:' : ''}
|
||||
{request.operator_name || request.requester_name}
|
||||
<div className="small muted">
|
||||
{orderCancellationTime(request.executedAt || request.created)}
|
||||
</div>
|
||||
</td>
|
||||
<td className="cancellation-reason">{request.reason}</td>
|
||||
<td>
|
||||
{orderCancellationRecordStatus(request)}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">原单已有变动,需驳回后重新申请</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <div className="small cancellation-reason">{request.note}</div> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderCancellationTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{button(
|
||||
owner && request.status === 'pending' ? '查看并复核' : '查看订单',
|
||||
'open-cancellation-order',
|
||||
'',
|
||||
{
|
||||
'data-id': request.order_id,
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="cancellation-list-table"
|
||||
aria-label="全部日期的取消申请"
|
||||
columns={[
|
||||
{ title: '原订单/日期' },
|
||||
{ title: '经办/申请人及时间' },
|
||||
{ title: '取消原因' },
|
||||
{ title: '状态/处理记录' },
|
||||
{ title: '查看' },
|
||||
]}
|
||||
rows={result.requests.map((request, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, 'cancellation-reason', undefined, undefined],
|
||||
cells: [
|
||||
<>
|
||||
<strong>{request.order_number}</strong>
|
||||
<div className="small muted">{request.order_date}</div>
|
||||
<div className="small">原成交 ¥{yuan(request.summary.total)}</div>
|
||||
</>,
|
||||
<>
|
||||
{request.direct === true ? '经办人:' : ''}
|
||||
{request.operator_name || request.requester_name}
|
||||
<div className="small muted">{orderCancellationTime(request.executedAt || request.created)}</div>
|
||||
</>,
|
||||
request.reason,
|
||||
<>
|
||||
{orderCancellationRecordStatus(request)}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">原单已有变动,需驳回后重新申请</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <div className="small cancellation-reason">{request.note}</div> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderCancellationTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</>,
|
||||
button(
|
||||
owner && request.status === 'pending' ? '查看并复核' : '查看订单',
|
||||
'open-cancellation-order',
|
||||
'',
|
||||
{
|
||||
'data-id': request.order_id,
|
||||
},
|
||||
),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="empty">全部日期均无此状态的取消申请。</p>
|
||||
@@ -158,65 +159,60 @@ export function orderReviews(
|
||||
</div>
|
||||
{result.requests.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="change-list-table" aria-label="全部日期的归属申请">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>订单/日期</th>
|
||||
<th>归属修改</th>
|
||||
<th>申请人/原因</th>
|
||||
<th>复核结果</th>
|
||||
<th>查看</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
result.requests.map(request => (
|
||||
<tr>
|
||||
<td>
|
||||
<strong className="order-ownership-list-customer">
|
||||
{request.order_customer || '未填客户称呼'}
|
||||
</strong>
|
||||
<div className="small muted">
|
||||
{request.order_number} · {request.order_date}
|
||||
</div>
|
||||
</td>
|
||||
<td>{orderOwnershipPairHTML(request)}</td>
|
||||
<td>
|
||||
{request.requester_name}
|
||||
<div className="small muted">{orderOwnershipTime(request.created)}</div>
|
||||
<p className="change-reason">{request.reason}</p>
|
||||
</td>
|
||||
<td>
|
||||
{orderOwnershipStatus[request.status]}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">订单已有变动,需驳回后重申</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <p className="small change-reason">{request.note}</p> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderOwnershipTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{button(
|
||||
owner && request.status === 'pending' ? '查看并复核' : '查看订单',
|
||||
'order-ownership-open-order',
|
||||
'',
|
||||
{
|
||||
'data-id': request.order_id,
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="change-list-table"
|
||||
aria-label="全部日期的归属申请"
|
||||
columns={[
|
||||
{ title: '订单/日期' },
|
||||
{ title: '归属修改' },
|
||||
{ title: '申请人/原因' },
|
||||
{ title: '复核结果' },
|
||||
{ title: '查看' },
|
||||
]}
|
||||
rows={result.requests.map((request, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
<>
|
||||
<strong className="order-ownership-list-customer">
|
||||
{request.order_customer || '未填客户称呼'}
|
||||
</strong>
|
||||
<div className="small muted">
|
||||
{request.order_number} · {request.order_date}
|
||||
</div>
|
||||
</>,
|
||||
orderOwnershipPairHTML(request),
|
||||
<>
|
||||
{request.requester_name}
|
||||
<div className="small muted">{orderOwnershipTime(request.created)}</div>
|
||||
<p className="change-reason">{request.reason}</p>
|
||||
</>,
|
||||
<>
|
||||
{orderOwnershipStatus[request.status]}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">订单已有变动,需驳回后重申</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <p className="small change-reason">{request.note}</p> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderOwnershipTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</>,
|
||||
button(
|
||||
owner && request.status === 'pending' ? '查看并复核' : '查看订单',
|
||||
'order-ownership-open-order',
|
||||
'',
|
||||
{
|
||||
'data-id': request.order_id,
|
||||
},
|
||||
),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="empty">全部日期均无此状态的归属申请。</p>
|
||||
@@ -250,69 +246,60 @@ export function orderReviews(
|
||||
</div>
|
||||
{result.requests.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="change-list-table" aria-label="全部日期的变更申请">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>原订单/日期</th>
|
||||
<th>申请人/申请时间</th>
|
||||
<th>动作/申请原因</th>
|
||||
<th>状态/复核意见</th>
|
||||
<th>查看</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
result.requests.map(request => (
|
||||
<tr>
|
||||
<td>
|
||||
<strong>{request.order_number}</strong>
|
||||
<div className="small muted">{request.order_date}</div>
|
||||
<div className="small">
|
||||
原成交 {orderChangeMoney(request.summary.before.total)}
|
||||
<br />
|
||||
申请成交 {orderChangeMoney(request.summary.after.total)}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{request.requester_name}
|
||||
<div className="small muted">{orderChangeTime(request.created)}</div>
|
||||
</td>
|
||||
<td className="change-reason">
|
||||
<strong>{orderChangeActionLabel(request)}</strong>
|
||||
<br />
|
||||
{request.reason}
|
||||
</td>
|
||||
<td>
|
||||
{orderChangeStatus[request.status]}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">原单已有变动,需驳回后重新申请</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <div className="small change-reason">{request.note}</div> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderChangeTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{button(
|
||||
owner && request.status === 'pending' ? '查看并复核' : '查看订单',
|
||||
'open-change-order',
|
||||
'',
|
||||
{
|
||||
'data-id': request.order_id,
|
||||
},
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="change-list-table"
|
||||
aria-label="全部日期的变更申请"
|
||||
columns={[
|
||||
{ title: '原订单/日期' },
|
||||
{ title: '申请人/申请时间' },
|
||||
{ title: '动作/申请原因' },
|
||||
{ title: '状态/复核意见' },
|
||||
{ title: '查看' },
|
||||
]}
|
||||
rows={result.requests.map((request, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, 'change-reason', undefined, undefined],
|
||||
cells: [
|
||||
<>
|
||||
<strong>{request.order_number}</strong>
|
||||
<div className="small muted">{request.order_date}</div>
|
||||
<div className="small">
|
||||
原成交 {orderChangeMoney(request.summary.before.total)}
|
||||
<br />
|
||||
申请成交 {orderChangeMoney(request.summary.after.total)}
|
||||
</div>
|
||||
</>,
|
||||
<>
|
||||
{request.requester_name}
|
||||
<div className="small muted">{orderChangeTime(request.created)}</div>
|
||||
</>,
|
||||
<>
|
||||
<strong>{orderChangeActionLabel(request)}</strong>
|
||||
<br />
|
||||
{request.reason}
|
||||
</>,
|
||||
<>
|
||||
{orderChangeStatus[request.status]}
|
||||
{request.stale && request.status === 'pending' ? (
|
||||
<div className="small danger-text">原单已有变动,需驳回后重新申请</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{request.note ? <div className="small change-reason">{request.note}</div> : ''}
|
||||
{request.reviewer_name ? (
|
||||
<div className="small muted">
|
||||
{request.reviewer_name} · {orderChangeTime(request.reviewed)}
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</>,
|
||||
button(owner && request.status === 'pending' ? '查看并复核' : '查看订单', 'open-change-order', '', {
|
||||
'data-id': request.order_id,
|
||||
}),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="empty">全部日期均无此状态的变更申请。</p>
|
||||
@@ -330,7 +317,7 @@ export function orderReviews(
|
||||
'这笔历史记录未记录对数,当前对数按实际盘点基准保留。本次旧重量冲回不自动更改当前对数,如实物有变化请另做当天对数调整。'}
|
||||
</div>
|
||||
<label className="check">
|
||||
<input name="legacyCountVerified" type="checkbox" required />
|
||||
<LedgerInput name="legacyCountVerified" type="checkbox" required />
|
||||
已核对当前对数基准,理解本次更正对历史对数的处理
|
||||
</label>
|
||||
</>
|
||||
@@ -404,32 +391,25 @@ export function orderReviews(
|
||||
{summary.legacyCountNotice ? <p className="note">{summary.legacyCountNotice}</p> : ''}
|
||||
{summary.inventory.length ? (
|
||||
<div className="table-wrap">
|
||||
<table aria-label="取消后库存冲回摘要">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>原日期</th>
|
||||
<th>货盘</th>
|
||||
<th className="number">恢复/冲回克重</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
summary.inventory.map(item => (
|
||||
<tr>
|
||||
<td>{item.date}</td>
|
||||
<td>{pocketLabel(item.pocket)}</td>
|
||||
<td className="number">
|
||||
{item.mg > 0 ? '+' : ''}
|
||||
{grams(item.mg)}g
|
||||
{inventoryCountHTML(item, {
|
||||
signed: true,
|
||||
})}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
aria-label="取消后库存冲回摘要"
|
||||
columns={[{ title: '原日期' }, { title: '货盘' }, { title: '恢复/冲回克重', headerClassName: 'number' }]}
|
||||
rows={summary.inventory.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, 'number'],
|
||||
cells: [
|
||||
item.date,
|
||||
pocketLabel(item.pocket),
|
||||
<>
|
||||
{item.mg > 0 ? '+' : ''}
|
||||
{grams(item.mg)}g
|
||||
{inventoryCountHTML(item, {
|
||||
signed: true,
|
||||
})}
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="small muted">本单没有需要冲回的库存出入。</p>
|
||||
@@ -471,20 +451,20 @@ export function orderReviews(
|
||||
这张订单是今天开的,核实后直接按录错作废,无需另行审批。业务日期:{data.directActionDate}
|
||||
。本入口不办理真实退货或退款。
|
||||
</div>
|
||||
<input type="hidden" name="date" defaultValue={data.directActionDate} />
|
||||
<LedgerInput type="hidden" name="date" defaultValue={data.directActionDate} />
|
||||
{orderCancellationSummaryDataHTML(data.summary)}
|
||||
<label>
|
||||
取消原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="reason"
|
||||
rows={3}
|
||||
required
|
||||
maxLength={200}
|
||||
placeholder="写清这张单录错的原因,例如:同一笔销售重复录入。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实这是录错作废,并确认撤销上述记账和冲回库存;本次不登记真实退货退款。
|
||||
</label>
|
||||
</>
|
||||
@@ -500,13 +480,13 @@ export function orderReviews(
|
||||
<p className="small muted">真实退货请从“整单退货”办理;这里不会发起真实退款。</p>
|
||||
<label>
|
||||
取消原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="reason"
|
||||
rows={3}
|
||||
required
|
||||
maxLength={200}
|
||||
placeholder="写清这张单录错的原因,例如:同一笔销售重复录入。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
@@ -521,10 +501,10 @@ export function orderReviews(
|
||||
<p className="cancellation-reason">取消原因:{request.reason}</p>
|
||||
{orderCancellationSummaryHTML(request)}
|
||||
<label>
|
||||
复核备注(选填)<textarea name="note" maxLength={200} rows={2}></textarea>
|
||||
复核备注(选填)<LedgerTextArea name="note" maxLength={200} rows={2}></LedgerTextArea>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实这是录错作废,并确认撤销上述记账和冲回库存;本次不登记真实退货退款。
|
||||
</label>
|
||||
</>
|
||||
@@ -538,13 +518,13 @@ export function orderReviews(
|
||||
<p className="small muted">驳回后原订单继续计账,申请人可核对后重新申请。</p>
|
||||
<label>
|
||||
驳回意见
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
rows={3}
|
||||
required
|
||||
maxLength={200}
|
||||
placeholder="写清需要补充或重新核对的地方。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
@@ -564,13 +544,13 @@ export function orderReviews(
|
||||
{html}
|
||||
<div id="order-cancellation-error" aria-live="polite"></div>
|
||||
<div className="form-actions">
|
||||
<button
|
||||
<LedgerButton
|
||||
type="submit"
|
||||
data-order-cancellation-submit=""
|
||||
className={['approve', 'direct'].includes(kind) ? 'danger' : 'primary'}
|
||||
>
|
||||
{submit}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('收起', 'close-order-cancellation-form', 'quiet')}
|
||||
</div>
|
||||
</form>
|
||||
@@ -608,16 +588,16 @@ export function orderReviews(
|
||||
<div className="grid two">
|
||||
<label>
|
||||
当前归属
|
||||
<input defaultValue={before.label} readOnly />
|
||||
<LedgerInput defaultValue={before.label} readOnly />
|
||||
</label>
|
||||
<label>
|
||||
修改为
|
||||
<select name="member" required defaultValue="">
|
||||
<LedgerSelect name="member" required defaultValue="">
|
||||
{opts([
|
||||
['', '请选择新归属'],
|
||||
...members.map((member): [string, string] => [member.member, member.label]),
|
||||
])}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
</div>
|
||||
<p className="order-ownership-selection" id="order-ownership-selection" aria-live="polite">
|
||||
@@ -626,16 +606,16 @@ export function orderReviews(
|
||||
{orderOwnershipEffectHTML(data.member)}
|
||||
<label>
|
||||
修改原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="reason"
|
||||
required
|
||||
maxLength={200}
|
||||
rows={3}
|
||||
placeholder="写清原归属录错的原因及正确归属。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核对原归属、新归属和修改原因,确认本次归属{direct ? '更正' : '申请'}。
|
||||
</label>
|
||||
</>
|
||||
@@ -654,10 +634,10 @@ export function orderReviews(
|
||||
<>
|
||||
{orderOwnershipEffectHTML(request.before.member)}
|
||||
<label>
|
||||
复核备注(选填)<textarea name="note" maxLength={200} rows={2}></textarea>
|
||||
复核备注(选填)<LedgerTextArea name="note" maxLength={200} rows={2}></LedgerTextArea>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核对原归属、新归属和原因,同意后按新归属统计,并更新原助理的查看权限。
|
||||
</label>
|
||||
</>
|
||||
@@ -666,13 +646,13 @@ export function orderReviews(
|
||||
<p className="small muted">驳回后保留原归属,申请人可核对后重新申请。</p>
|
||||
<label>
|
||||
驳回意见
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
required
|
||||
maxLength={200}
|
||||
rows={3}
|
||||
placeholder="写清需要重新核对的地方。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</>
|
||||
)}
|
||||
@@ -685,9 +665,9 @@ export function orderReviews(
|
||||
{html}
|
||||
<div id="order-ownership-error" aria-live="polite"></div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="primary">
|
||||
<LedgerButton type="submit" className="primary">
|
||||
{submit}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('收起', 'order-ownership-close-form', 'quiet')}
|
||||
</div>
|
||||
</form>
|
||||
@@ -723,10 +703,10 @@ export function orderReviews(
|
||||
{orderChangeActionSummaryHTML(request)}
|
||||
{orderChangeComparisonHTML(request)}
|
||||
<label>
|
||||
复核备注(选填)<textarea name="note" maxLength={200} rows={2}></textarea>
|
||||
复核备注(选填)<LedgerTextArea name="note" maxLength={200} rows={2}></LedgerTextArea>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核对本次申请动作、金额、日期、账户或付款人、退货去向及库存,确认原值与申请值,以及以上关联订单的本次修改。
|
||||
</label>
|
||||
</>
|
||||
@@ -736,13 +716,13 @@ export function orderReviews(
|
||||
<p>驳回后原单继续计账,申请人可按最新原单重新申请。</p>
|
||||
<label>
|
||||
驳回意见
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
required
|
||||
maxLength={200}
|
||||
rows={3}
|
||||
placeholder="写清需要重新核对或补充的地方。"
|
||||
></textarea>
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
</>
|
||||
);
|
||||
@@ -752,9 +732,9 @@ export function orderReviews(
|
||||
{html}
|
||||
<div id="order-change-error" aria-live="polite"></div>
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="primary">
|
||||
<LedgerButton type="submit" className="primary">
|
||||
{kind === 'approve' ? '同意变更并更新原单' : '确认驳回'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{button('收起', 'close-order-change-form', 'quiet')}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -18,6 +18,13 @@ import type {
|
||||
} from '../orderData';
|
||||
import { Children, Fragment } from 'react';
|
||||
import { Calc as LedgerCalc, Cards as CreditCardFees, Values } from '../../../shared';
|
||||
import {
|
||||
LedgerButton,
|
||||
LedgerDataTable,
|
||||
LedgerInput,
|
||||
LedgerSelect,
|
||||
LedgerTable,
|
||||
} from '../../../components/BusinessControls';
|
||||
export function sharedViews({
|
||||
state,
|
||||
session,
|
||||
@@ -80,7 +87,7 @@ export function sharedViews({
|
||||
return (
|
||||
<label className="stock-count-field" data-stock-count-field="" hidden={!visible}>
|
||||
{title}
|
||||
<input
|
||||
<LedgerInput
|
||||
name={name}
|
||||
readOnly={readOnly}
|
||||
defaultValue={value ?? ''}
|
||||
@@ -136,9 +143,9 @@ export function sharedViews({
|
||||
return (
|
||||
<label>
|
||||
{title}
|
||||
<select name={name} defaultValue={selected}>
|
||||
<LedgerSelect name={name} defaultValue={selected}>
|
||||
{opts(values)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
);
|
||||
};
|
||||
@@ -157,7 +164,7 @@ export function sharedViews({
|
||||
) => (
|
||||
<label>
|
||||
{title}
|
||||
<input type={type} name={name} defaultValue={value} {...props} />
|
||||
<LedgerInput type={type} name={name} defaultValue={value} {...props} />
|
||||
</label>
|
||||
);
|
||||
const opts = (values: Options) =>
|
||||
@@ -280,7 +287,10 @@ export function sharedViews({
|
||||
{lock.customer ? ' · ' + lock.customer : ''}
|
||||
</h3>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table material-change-comparison" aria-label="关联锁价单成本影响">
|
||||
<LedgerTable
|
||||
className="material-detail-table material-change-comparison"
|
||||
aria-label="关联锁价单成本影响"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>核对项目</th>
|
||||
@@ -310,7 +320,7 @@ export function sharedViews({
|
||||
: ''}
|
||||
{pair('自动付款归属', sources(lock.before), sources(lock.after))}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</>
|
||||
)),
|
||||
@@ -338,7 +348,7 @@ export function sharedViews({
|
||||
<h3>{title}</h3>
|
||||
{rows.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="order-change-inventory">
|
||||
<LedgerTable className="order-change-inventory">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
@@ -365,7 +375,7 @@ export function sharedViews({
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
) : (
|
||||
<p className="small muted">{changes ? '本次没有黄金货盘净变动。' : '没有本单库存流水。'}</p>
|
||||
@@ -745,7 +755,7 @@ export function sharedViews({
|
||||
原值为申请时快照,申请值由服务器按本次变更试算。批准前请核对客户实付、商品、成本、费用及付款人。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table className="order-change-table" aria-label="变更申请原值与申请值对照">
|
||||
<LedgerTable className="order-change-table" aria-label="变更申请原值与申请值对照">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>核对项目</th>
|
||||
@@ -777,7 +787,7 @@ export function sharedViews({
|
||||
orderChangeExpensesValue(after),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
{orderChangeInventoryHTML(request.summary.inventory)}
|
||||
{related}
|
||||
@@ -888,42 +898,38 @@ export function sharedViews({
|
||||
)}
|
||||
</dl>
|
||||
<div className="table-wrap">
|
||||
<table aria-label="逐件售后回库与成本">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品与实际去向</th>
|
||||
<th>实际退回</th>
|
||||
<th>回料成本</th>
|
||||
<th>保留工费</th>
|
||||
<th>成本损失</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
record.lines.map(line => (
|
||||
<tr>
|
||||
<td>
|
||||
{line.name || '商品 ' + (line.lineIndex + 1)}
|
||||
<div className="small muted">
|
||||
{pocketLabel(line.pocket)} · {line.disposition === 'stock' ? '完好现货' : '旧料/损坏'}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{grams(line.quantity)}g
|
||||
{line.disposition === 'stock' && pocketCountsEnabled(line.pocket) ? (
|
||||
<div className="small">{stockCountText(line.stockCount)}</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</td>
|
||||
<td>{money(line.materialReturnedCost)}</td>
|
||||
<td>{money(line.laborRestockedCost)}</td>
|
||||
<td>{money(line.costLoss)}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
aria-label="逐件售后回库与成本"
|
||||
columns={[
|
||||
{ title: '商品与实际去向' },
|
||||
{ title: '实际退回' },
|
||||
{ title: '回料成本' },
|
||||
{ title: '保留工费' },
|
||||
{ title: '成本损失' },
|
||||
]}
|
||||
rows={record.lines.map((line, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
<>
|
||||
{line.name || '商品 ' + (line.lineIndex + 1)}
|
||||
<div className="small muted">
|
||||
{pocketLabel(line.pocket)} · {line.disposition === 'stock' ? '完好现货' : '旧料/损坏'}
|
||||
</div>
|
||||
</>,
|
||||
<>
|
||||
{grams(line.quantity)}g
|
||||
{line.disposition === 'stock' && pocketCountsEnabled(line.pocket) ? (
|
||||
<div className="small">{stockCountText(line.stockCount)}</div>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</>,
|
||||
money(line.materialReturnedCost),
|
||||
money(line.laborRestockedCost),
|
||||
money(line.costLoss),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
<p className="small muted">
|
||||
实退材料按原成本回售后日料池,不新增采购付款。完好现货工费留在退回现货批次;旧料工费与未退回材料成本计损失。原单实际费用继续保留。
|
||||
@@ -1209,9 +1215,9 @@ export function sharedViews({
|
||||
[key: `data-${string}`]: string | number | boolean | undefined;
|
||||
} = {},
|
||||
) => (
|
||||
<button type="button" data-action={action} className={cls} {...props}>
|
||||
<LedgerButton type="button" data-action={action} className={cls} {...props}>
|
||||
{text}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
function teamMemberName(member: string | undefined) {
|
||||
return (
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { StockSelection, EditLine } from './deliveryTypes';
|
||||
import type { useLockPool } from './useLockPool';
|
||||
import { Model } from '../../shared';
|
||||
import { Act, Field, Money, Choice, Check, Charges } from './formParts';
|
||||
import { LedgerInput } from '../../components/BusinessControls';
|
||||
export function DeliveryFields({
|
||||
views,
|
||||
state,
|
||||
@@ -289,7 +290,7 @@ export function DeliveryFields({
|
||||
/>
|
||||
<p className="purchase-formula">{line.view?.laborFormula}</p>
|
||||
{Model.teamMode(state) && p.costFundings?.labor && (
|
||||
<input
|
||||
<LedgerInput
|
||||
type="hidden"
|
||||
className="cost-funding"
|
||||
data-component="labor"
|
||||
@@ -297,9 +298,9 @@ export function DeliveryFields({
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<input type="hidden" name="cost-accessories" value={p.accessories} />
|
||||
<input type="hidden" name="cost-other" value={p.other} />
|
||||
<input type="hidden" name="payer" value={line.payer} />
|
||||
<LedgerInput type="hidden" name="cost-accessories" value={p.accessories} />
|
||||
<LedgerInput type="hidden" name="cost-other" value={p.other} />
|
||||
<LedgerInput type="hidden" name="payer" value={line.payer} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -470,7 +471,7 @@ export function FeeFields({
|
||||
移除费用
|
||||
</Act>
|
||||
{Model.teamMode(state) && r.funding && (
|
||||
<input
|
||||
<LedgerInput
|
||||
type="hidden"
|
||||
className="cost-funding"
|
||||
data-component="fee"
|
||||
|
||||
@@ -2,29 +2,15 @@ import { savedCreate } from './draftInput';
|
||||
import { lockEditKey, lockDraftKey } from './receipts';
|
||||
import type { FormEvent } from 'react';
|
||||
import type { LedgerState, SessionInfo } from '../../shared';
|
||||
import type { LockPayment } from './formParts';
|
||||
import type { LockPayment } from './formValues';
|
||||
import type { InputLine, LockEdit, LockProps, LockViews, PreviewRow, SaveLock, InputMaterial } from './types';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Model, Calc } from '../../shared';
|
||||
import { navigate } from '../../lib/router';
|
||||
import {
|
||||
Act,
|
||||
Field,
|
||||
Money,
|
||||
Choice,
|
||||
Check,
|
||||
Heading,
|
||||
Charges,
|
||||
AccountFields,
|
||||
CardPreview,
|
||||
amountPreview,
|
||||
safeEstimate,
|
||||
saleCharges,
|
||||
initialPayment,
|
||||
paymentPayload,
|
||||
readDraft,
|
||||
} from './formParts';
|
||||
import { Act, Field, Money, Choice, Check, Heading, Charges, AccountFields, CardPreview } from './formParts';
|
||||
import { amountPreview, safeEstimate, saleCharges, initialPayment, paymentPayload, readDraft } from './formValues';
|
||||
import { useLockPool } from './useLockPool';
|
||||
import { LedgerButton, LedgerInput, LedgerTextArea } from '../../components/BusinessControls';
|
||||
|
||||
function PoolQuote({
|
||||
q,
|
||||
@@ -370,8 +356,8 @@ export function LockCreate({
|
||||
) : (
|
||||
<label>
|
||||
订单归属(经营款与业绩)
|
||||
<input value={Model.memberName(state, d.member)} readOnly />
|
||||
<input type="hidden" name="member" value={d.member} />
|
||||
<LedgerInput value={Model.memberName(state, d.member)} readOnly />
|
||||
<LedgerInput type="hidden" name="member" value={d.member} />
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
@@ -628,7 +614,7 @@ export function LockCreate({
|
||||
)}
|
||||
<label>
|
||||
修改原因
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="pending_edit_reason"
|
||||
required
|
||||
maxLength={200}
|
||||
@@ -655,7 +641,7 @@ export function LockCreate({
|
||||
/>
|
||||
<label>
|
||||
客户可见备注
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
maxLength={170}
|
||||
rows={2}
|
||||
@@ -681,9 +667,14 @@ export function LockCreate({
|
||||
</div>
|
||||
<div className="small muted">待交付,不计利润</div>
|
||||
</div>
|
||||
<button className="primary" type="submit" data-lock-create-submit="" disabled={blocked || d.conflicted}>
|
||||
<LedgerButton
|
||||
className="primary"
|
||||
type="submit"
|
||||
data-lock-create-submit=""
|
||||
disabled={blocked || d.conflicted}
|
||||
>
|
||||
{edit ? (approval ? '提交修改申请' : '保存锁价修改') : '保存锁价待交付'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div id="price-lock-error" aria-live="polite">
|
||||
{error && <div className="error">{error}</div>}
|
||||
|
||||
@@ -3,26 +3,16 @@ import { lockDeliveryKey } from './receipts';
|
||||
import type { FormEvent } from 'react';
|
||||
import type { OrderForm, SyncContext } from '../../shared';
|
||||
import type { LockRecord, LockProps, LockViews, SaveLock, DeliveryCost } from './types';
|
||||
import type { LockPayment } from './formParts';
|
||||
import type { LockPayment } from './formValues';
|
||||
import type { DeliveryForm, DeliveryLine, SavedLine } from './deliveryTypes';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Model, Calc, Cards } from '../../shared';
|
||||
import { navigate } from '../../lib/router';
|
||||
import {
|
||||
Heading,
|
||||
Act,
|
||||
Field,
|
||||
Money,
|
||||
Check,
|
||||
AccountFields,
|
||||
CardPreview,
|
||||
initialPayment,
|
||||
paymentPayload,
|
||||
readDraft,
|
||||
safeEstimate,
|
||||
} from './formParts';
|
||||
import { Heading, Act, Field, Money, Check, AccountFields, CardPreview } from './formParts';
|
||||
import { initialPayment, paymentPayload, readDraft, safeEstimate } from './formValues';
|
||||
import { DeliveryFields, FeeFields } from './DeliveryFields';
|
||||
import { useLockPool } from './useLockPool';
|
||||
import { LedgerButton, LedgerInput } from '../../components/BusinessControls';
|
||||
|
||||
const uuid = () => crypto.randomUUID();
|
||||
function initialize(lock: LockRecord, views: LockViews, ctx: SyncContext, key: string): DeliveryForm {
|
||||
@@ -293,7 +283,7 @@ export function LockDelivery({
|
||||
['returning', '老客户'],
|
||||
].map(([k, l]) => (
|
||||
<label key={k} title={k === 'new' ? '首次成交' : '再次成交'}>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="radio"
|
||||
name="customer_type"
|
||||
value={k}
|
||||
@@ -440,9 +430,9 @@ export function LockDelivery({
|
||||
</Check>
|
||||
<div className="form-actions">
|
||||
<span className="small muted">保存后才记销售、完整成本和利润,可打印正式客户单据。</span>
|
||||
<button type="submit" className="primary" disabled={blocked}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked}>
|
||||
确认整单交付并生成销售单
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div id="price-lock-error" aria-live="polite">
|
||||
{error && <div className="error">{error}</div>}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { clearMatching, type DraftSubmission } from '../../lib/receipt';
|
||||
import { lockReceipt } from './receipts';
|
||||
import { useEffect, useMemo, useRef, useState, type FormEvent, type MouseEvent, type ReactNode } from 'react';
|
||||
import { useEffect, useMemo, useState, type FormEvent, type MouseEvent, type ReactNode } from 'react';
|
||||
import type { LedgerClient } from '../../lib/api';
|
||||
import type { LedgerState } from '../../shared';
|
||||
import { loadState } from '../../lib/session';
|
||||
@@ -12,6 +12,7 @@ import { lockViews } from './lockViews';
|
||||
import { Act, Heading } from './formParts';
|
||||
import { LockCreate } from './LockCreate';
|
||||
import { LockDelivery } from './LockDelivery';
|
||||
import { LedgerButton, LedgerDialog } from '../../components/BusinessControls';
|
||||
|
||||
type DialogKind = 'changes' | 'review' | 'cancel' | 'detail';
|
||||
type LocalDialog = { kind: DialogKind; id?: string };
|
||||
@@ -142,24 +143,16 @@ function readChanges(r: unknown) {
|
||||
const modalId = (k: DialogKind) =>
|
||||
['changes', 'review'].includes(k) ? 'price-lock-changes-dialog' : 'price-lock-dialog';
|
||||
function Modal({ children, kind, close }: { children: ReactNode; kind: DialogKind; close: () => void }) {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
useEffect(() => {
|
||||
const root = ref.current;
|
||||
if (!root) return;
|
||||
root.showModal();
|
||||
return () => root.close();
|
||||
}, []);
|
||||
return (
|
||||
<dialog
|
||||
<LedgerDialog
|
||||
id={modalId(kind)}
|
||||
ref={ref}
|
||||
onCancel={e => {
|
||||
e.preventDefault();
|
||||
close();
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
const previousFilters = new WeakMap<LedgerClient, { user: string; list: string; changes: string }>();
|
||||
@@ -458,9 +451,9 @@ export function LockPage({ client, state, session, route, onState, onRecoverOthe
|
||||
const waiting = resource.error ? (
|
||||
<div className="error">
|
||||
{resource.error}{' '}
|
||||
<button type="button" onClick={reload}>
|
||||
<LedgerButton type="button" onClick={reload}>
|
||||
重新读取
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : (
|
||||
<p>正在读取锁价记录…</p>
|
||||
@@ -471,9 +464,9 @@ export function LockPage({ client, state, session, route, onState, onRecoverOthe
|
||||
{formPending && !client.busy && (
|
||||
<div className="note" role="alert">
|
||||
上次提交结果尚未确认。
|
||||
<button type="button" data-action="retry" disabled={client.busy} onClick={retry}>
|
||||
<LedgerButton type="button" data-action="retry" disabled={client.busy} onClick={retry}>
|
||||
恢复原操作
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
)}
|
||||
{message && (
|
||||
@@ -588,9 +581,14 @@ export function LockPage({ client, state, session, route, onState, onRecoverOthe
|
||||
<Modal key={kind + '-' + id} kind={dialog.kind} close={close}>
|
||||
{kind === 'changes' ? (
|
||||
<>
|
||||
<button type="button" className="dialog-close" data-action="price-lock-changes-close" aria-label="关闭">
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
data-action="price-lock-changes-close"
|
||||
aria-label="关闭"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2>锁价修改与作废申请</h2>
|
||||
<div className="actions">
|
||||
{['pending', 'all'].map(s => (
|
||||
@@ -608,9 +606,14 @@ export function LockPage({ client, state, session, route, onState, onRecoverOthe
|
||||
</>
|
||||
) : kind === 'detail' ? (
|
||||
<>
|
||||
<button type="button" className="dialog-close" data-action="close-price-lock" aria-label="关闭锁价记录">
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
data-action="close-price-lock"
|
||||
aria-label="关闭锁价记录"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<div id="price-lock-detail">{lock ? views.detailView(lock) : waiting}</div>
|
||||
</>
|
||||
) : (kind === 'cancel' ? cancel : review) ? (
|
||||
@@ -636,15 +639,15 @@ export function LockPage({ client, state, session, route, onState, onRecoverOthe
|
||||
{error && (
|
||||
<div role="alert" className="error">
|
||||
{error}{' '}
|
||||
<button type="button" onClick={reload}>
|
||||
<LedgerButton type="button" onClick={reload}>
|
||||
重新读取
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
)}
|
||||
{stale && (
|
||||
<button type="button" onClick={close}>
|
||||
<LedgerButton type="button" onClick={close}>
|
||||
关闭
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</Modal>
|
||||
)}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { LineState, OrderForm } from '../../shared';
|
||||
import type { LockPayment, SavedPayment } from './formParts';
|
||||
import type { LockPayment, SavedPayment } from './formValues';
|
||||
|
||||
// 锁价交付在本地保存可提交的商品行。早期单件草稿将商品放在顶层的 line。
|
||||
export interface DeliveryLine {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { LockCreateDraft, InputLine } from './types';
|
||||
import type { SavedPayment } from './formParts';
|
||||
import type { SavedPayment } from './formValues';
|
||||
import type { DeliveryDraft, SavedLine } from './deliveryTypes';
|
||||
|
||||
const record = (value: unknown): value is Record<string, unknown> =>
|
||||
|
||||
@@ -17,25 +17,14 @@ interface CheckProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'value'
|
||||
value?: boolean;
|
||||
update: (v: boolean) => void;
|
||||
}
|
||||
export interface LockPayment {
|
||||
method: string;
|
||||
recipient: string;
|
||||
payer: string;
|
||||
verified: boolean;
|
||||
amount: string;
|
||||
}
|
||||
export interface SavedPayment {
|
||||
account?: string;
|
||||
credit_card_fee_payer?: string;
|
||||
verified?: boolean;
|
||||
amount?: string;
|
||||
}
|
||||
import type { LockPayment } from './formValues';
|
||||
interface PaymentProps {
|
||||
state: LedgerState;
|
||||
payment: LockPayment;
|
||||
change: (p: LockPayment) => void;
|
||||
}
|
||||
import { Model, Cards, Calc } from '../../shared';
|
||||
import { Model, Cards } from '../../shared';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
|
||||
export function Field({
|
||||
label,
|
||||
@@ -50,7 +39,7 @@ export function Field({
|
||||
return (
|
||||
<label hidden={hidden}>
|
||||
{label}
|
||||
<input
|
||||
<LedgerInput
|
||||
type={type}
|
||||
name={name}
|
||||
value={value ?? ''}
|
||||
@@ -68,7 +57,12 @@ export function Choice({ label, name, value, options, update, children, hidden,
|
||||
return (
|
||||
<label hidden={hidden}>
|
||||
{label}
|
||||
<select name={name} value={value ?? ''} {...props} onChange={update ? e => update(e.target.value) : undefined}>
|
||||
<LedgerSelect
|
||||
name={name}
|
||||
value={value ?? ''}
|
||||
{...props}
|
||||
onChange={update ? e => update(e.target.value) : undefined}
|
||||
>
|
||||
{options.map(v => {
|
||||
const [k, title, disabled] = typeof v === 'string' ? [v, v] : v;
|
||||
return (
|
||||
@@ -77,7 +71,7 @@ export function Choice({ label, name, value, options, update, children, hidden,
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
{children}
|
||||
</label>
|
||||
);
|
||||
@@ -85,16 +79,16 @@ export function Choice({ label, name, value, options, update, children, hidden,
|
||||
export function Check({ name, value, update, children, hidden, ...props }: CheckProps) {
|
||||
return (
|
||||
<label className="check" hidden={hidden}>
|
||||
<input type="checkbox" name={name} checked={!!value} onChange={e => update(e.target.checked)} {...props} />
|
||||
<LedgerInput type="checkbox" name={name} checked={!!value} onChange={e => update(e.target.checked)} {...props} />
|
||||
{children}
|
||||
</label>
|
||||
);
|
||||
}
|
||||
export function Act({ name, onClick, children, className = '', ...props }: ButtonHTMLAttributes<HTMLButtonElement>) {
|
||||
return (
|
||||
<button type="button" className={className} data-action={name} onClick={onClick} {...props}>
|
||||
<LedgerButton type="button" className={className} data-action={name} onClick={onClick} {...props}>
|
||||
{children}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
export function Heading({
|
||||
@@ -246,7 +240,7 @@ export function CardPreview({
|
||||
<div className="credit-card-fields">
|
||||
<label>
|
||||
手续费(元,自动)
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
min="0"
|
||||
step="0.01"
|
||||
@@ -284,53 +278,3 @@ export function CardPreview({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
export function amountPreview(raw: string) {
|
||||
try {
|
||||
return Calc.cents(raw);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function safeEstimate<T>(fn: () => T): { result: T; error?: undefined } | { result?: undefined; error: string } {
|
||||
try {
|
||||
return { result: fn() };
|
||||
} catch (error) {
|
||||
return { error: error instanceof Error ? error.message : String(error) };
|
||||
}
|
||||
}
|
||||
export function readDraft<T>(key: string, valid: (v: unknown) => v is T): T | null {
|
||||
try {
|
||||
const value: unknown = JSON.parse(localStorage.getItem(key) || 'null');
|
||||
return valid(value) ? value : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function saleCharges(charges: ChargeState[]) {
|
||||
return charges.map(r => ({
|
||||
id: r.id,
|
||||
nameType: r.type,
|
||||
customName: r.customName,
|
||||
name: r.type === '其他' ? r.customName : r.type,
|
||||
amount: r.amount,
|
||||
chargePrices: r.prices,
|
||||
...(r.costRemoved ? { costRemoved: true } : {}),
|
||||
}));
|
||||
}
|
||||
export function initialPayment(state: LedgerState, p: SavedPayment | undefined, member: string): LockPayment {
|
||||
const id = Model.accountIdentity(state, p?.account || '');
|
||||
return {
|
||||
method: id?.channel || '微信',
|
||||
recipient: Model.memberAccountPrefix(id?.member || (Model.teamMode(state) ? member : 'assistant')),
|
||||
payer: p?.credit_card_fee_payer || 'owner',
|
||||
verified: !!p?.verified,
|
||||
amount: p?.amount ?? '',
|
||||
};
|
||||
}
|
||||
export function paymentPayload(payment: LockPayment) {
|
||||
return {
|
||||
account: Cards.normalizeAccount((payment.method === '信用卡' ? '麦麦' : payment.recipient) + payment.method),
|
||||
credit_card_fee_payer: payment.payer,
|
||||
verified: payment.verified,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import { Cards, Calc, Model, type ChargeState, type LedgerState } from '../../shared';
|
||||
export interface LockPayment {
|
||||
method: string;
|
||||
recipient: string;
|
||||
payer: string;
|
||||
verified: boolean;
|
||||
amount: string;
|
||||
}
|
||||
export interface SavedPayment {
|
||||
account?: string;
|
||||
credit_card_fee_payer?: string;
|
||||
verified?: boolean;
|
||||
amount?: string;
|
||||
}
|
||||
export function amountPreview(raw: string) {
|
||||
try {
|
||||
return Calc.cents(raw);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function safeEstimate<T>(fn: () => T): { result: T; error?: undefined } | { result?: undefined; error: string } {
|
||||
try {
|
||||
return { result: fn() };
|
||||
} catch (error) {
|
||||
return { error: error instanceof Error ? error.message : String(error) };
|
||||
}
|
||||
}
|
||||
export function readDraft<T>(key: string, valid: (v: unknown) => v is T): T | null {
|
||||
try {
|
||||
const value: unknown = JSON.parse(localStorage.getItem(key) || 'null');
|
||||
return valid(value) ? value : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
export function saleCharges(charges: ChargeState[]) {
|
||||
return charges.map(r => ({
|
||||
id: r.id,
|
||||
nameType: r.type,
|
||||
customName: r.customName,
|
||||
name: r.type === '其他' ? r.customName : r.type,
|
||||
amount: r.amount,
|
||||
chargePrices: r.prices,
|
||||
...(r.costRemoved ? { costRemoved: true } : {}),
|
||||
}));
|
||||
}
|
||||
export function initialPayment(state: LedgerState, p: SavedPayment | undefined, member: string): LockPayment {
|
||||
const id = Model.accountIdentity(state, p?.account || '');
|
||||
return {
|
||||
method: id?.channel || '微信',
|
||||
recipient: Model.memberAccountPrefix(id?.member || (Model.teamMode(state) ? member : 'assistant')),
|
||||
payer: p?.credit_card_fee_payer || 'owner',
|
||||
verified: !!p?.verified,
|
||||
amount: p?.amount ?? '',
|
||||
};
|
||||
}
|
||||
export function paymentPayload(payment: LockPayment) {
|
||||
return {
|
||||
account: Cards.normalizeAccount((payment.method === '信用卡' ? '麦麦' : payment.recipient) + payment.method),
|
||||
credit_card_fee_payer: payment.payer,
|
||||
verified: payment.verified,
|
||||
};
|
||||
}
|
||||
@@ -16,6 +16,13 @@ import type {
|
||||
import { Children, Fragment } from 'react';
|
||||
import { describeMaterialSources, validateMaterialQuote as checkMaterialQuote } from '../../lib/materialQuote';
|
||||
import { Model, Calc as LedgerCalc, Values } from '../../shared';
|
||||
import {
|
||||
LedgerButton,
|
||||
LedgerDataTable,
|
||||
LedgerInput,
|
||||
LedgerTable,
|
||||
LedgerTextArea,
|
||||
} from '../../components/BusinessControls';
|
||||
function isInputSnapshot(value: LockRecord | LockCreateDraft): value is LockCreateDraft {
|
||||
const first = value.lines?.[0];
|
||||
return !!first && !('line' in first);
|
||||
@@ -442,9 +449,9 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
const id = result.lock.id;
|
||||
return (
|
||||
<>
|
||||
<button className={'dialog-close'} data-action={'close-price-lock'} aria-label={'关闭'}>
|
||||
<LedgerButton className={'dialog-close'} data-action={'close-price-lock'} aria-label={'关闭'}>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<div className={'order-header'}>
|
||||
<div className={'eyebrow'}>VOID PRICE LOCK</div>
|
||||
<h2>
|
||||
@@ -461,10 +468,10 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
</div>
|
||||
<form id={'price-lock-cancel-form'}>
|
||||
<label>
|
||||
作废原因<textarea name={'reason'} required={true} maxLength={200} rows={2}></textarea>
|
||||
作废原因<LedgerTextArea name={'reason'} required={true} maxLength={200} rows={2}></LedgerTextArea>
|
||||
</label>
|
||||
<label className={'check'}>
|
||||
<input name={'verified'} type={'checkbox'} required={true} />
|
||||
<LedgerInput name={'verified'} type={'checkbox'} required={true} />
|
||||
已核实这是一张录错的待交付锁价单,确认整单作废。
|
||||
</label>
|
||||
{approval ? (
|
||||
@@ -478,9 +485,9 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
{button('返回锁价详情', 'open-price-lock', 'quiet', {
|
||||
'data-id': id,
|
||||
})}
|
||||
<button className={'danger'} type={'submit'}>
|
||||
<LedgerButton className={'danger'} type={'submit'}>
|
||||
{approval ? '提交作废申请' : '确认整单作废'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div id={'price-lock-action-error'} aria-live={'polite'}></div>
|
||||
</form>
|
||||
@@ -495,34 +502,23 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
<section className={'lock-related-orders'}>
|
||||
<h3>受影响的销售单({rows.length}张)</h3>
|
||||
<div className={'table-wrap'}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>订单</th>
|
||||
<th>货品成本:当前 → 生效后</th>
|
||||
<th>利润:当前 → 生效后</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
rows.map(row => (
|
||||
<>
|
||||
<tr>
|
||||
<td>
|
||||
{row.date} · {row.number || row.id}
|
||||
</td>
|
||||
<td>
|
||||
{money(row.before?.goodsCost)} → {money(row.after?.goodsCost)}
|
||||
</td>
|
||||
<td>
|
||||
{money(row.before?.profit)} → {money(row.after?.profit)}
|
||||
</td>
|
||||
</tr>
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[{ title: '订单' }, { title: '货品成本:当前 → 生效后' }, { title: '利润:当前 → 生效后' }]}
|
||||
rows={rows.map((row, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
<>
|
||||
{row.date} · {row.number || row.id}
|
||||
</>,
|
||||
<>
|
||||
{money(row.before?.goodsCost)} → {money(row.after?.goodsCost)}
|
||||
</>,
|
||||
<>
|
||||
{money(row.before?.profit)} → {money(row.after?.profit)}
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
@@ -593,7 +589,7 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
{lock.customer ? ' · ' + lock.customer : ''}
|
||||
</h3>
|
||||
<div className={'table-wrap'}>
|
||||
<table
|
||||
<LedgerTable
|
||||
className={'material-detail-table material-change-comparison'}
|
||||
aria-label={'关联锁价单成本影响'}
|
||||
>
|
||||
@@ -626,7 +622,7 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
: ''}
|
||||
{pair('自动付款归属', sources(lock.before), sources(lock.after))}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</>
|
||||
)),
|
||||
@@ -647,7 +643,7 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
return (
|
||||
<>
|
||||
<div className={'table-wrap price-lock-items'}>
|
||||
<table aria-label={'锁价商品明细'}>
|
||||
<LedgerTable aria-label={'锁价商品明细'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品</th>
|
||||
@@ -746,7 +742,7 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
}),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -795,53 +791,44 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
{value.date || ''} · {value.customer || ''} · 开单人 {value.salesperson || '未提供'}
|
||||
</p>
|
||||
<div className={'table-wrap'}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品</th>
|
||||
<th>锁重/售价</th>
|
||||
<th>销售工费/附加项目</th>
|
||||
<th>原锁料费/付款人</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
rows.map(row => (
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '商品' },
|
||||
{ title: '锁重/售价' },
|
||||
{ title: '销售工费/附加项目' },
|
||||
{ title: '原锁料费/付款人' },
|
||||
]}
|
||||
rows={rows.map((row, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
row.name || '未提供',
|
||||
<>
|
||||
{row.quantity || '未提供'}g<br />¥{row.goldPrice ?? '未提供'}/克
|
||||
</>,
|
||||
<>
|
||||
{row.laborMode === 'piece' ? '件工费' : '克工费'} ¥{row.laborRate ?? '未提供'}
|
||||
{row.laborMode === 'piece' ? ' × ' + (row.pieces || 1) + '件' : '/克'}
|
||||
{Children.toArray(
|
||||
(row.charges || []).map(charge => (
|
||||
<>
|
||||
<br />
|
||||
{charge.name} ¥{charge.amount}
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</>,
|
||||
row.material?.source === 'pool' ? (
|
||||
'当日加权料池'
|
||||
) : (
|
||||
<>
|
||||
<tr>
|
||||
<td>{row.name || '未提供'}</td>
|
||||
<td>
|
||||
{row.quantity || '未提供'}g<br />¥{row.goldPrice ?? '未提供'}/克
|
||||
</td>
|
||||
<td>
|
||||
{row.laborMode === 'piece' ? '件工费' : '克工费'} ¥{row.laborRate ?? '未提供'}
|
||||
{row.laborMode === 'piece' ? ' × ' + (row.pieces || 1) + '件' : '/克'}
|
||||
{Children.toArray(
|
||||
(row.charges || []).map(charge => (
|
||||
<>
|
||||
<br />
|
||||
{charge.name} ¥{charge.amount}
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{row.material?.source === 'pool' ? (
|
||||
'当日加权料池'
|
||||
) : (
|
||||
<>
|
||||
手填 ¥{row.material?.rate ?? '未提供'}/克
|
||||
<br />
|
||||
{priceLockPayerName(row.material?.payer)}
|
||||
</>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
手填 ¥{row.material?.rate ?? '未提供'}/克
|
||||
<br />
|
||||
{priceLockPayerName(row.material?.payer)}
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
<p>
|
||||
客户实际付款 ¥{value.payment?.amount ?? '未提供'} · {accountDisplayName(value.payment?.account || '')} ·
|
||||
@@ -861,9 +848,9 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
function changeDetail(result: LockChange, canReview: boolean) {
|
||||
return (
|
||||
<>
|
||||
<button className={'dialog-close'} data-action={'price-lock-changes-close'} aria-label={'关闭'}>
|
||||
<LedgerButton className={'dialog-close'} data-action={'price-lock-changes-close'} aria-label={'关闭'}>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<div className={'eyebrow'}>PRICE LOCK REVIEW</div>
|
||||
<h2>{result.action === 'cancel' ? '录错作废' : '整单修改'}申请</h2>
|
||||
<p>
|
||||
@@ -912,12 +899,17 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
<form id={'price-lock-review-form'}>
|
||||
<label>
|
||||
复核备注
|
||||
<textarea name={'review_note'} maxLength={240} rows={2} placeholder={'驳回时必填'}></textarea>
|
||||
<LedgerTextArea
|
||||
name={'review_note'}
|
||||
maxLength={240}
|
||||
rows={2}
|
||||
placeholder={'驳回时必填'}
|
||||
></LedgerTextArea>
|
||||
</label>
|
||||
{canReview ? (
|
||||
<>
|
||||
<label className={'check'}>
|
||||
<input type={'checkbox'} name={'verified'} />
|
||||
<LedgerInput type={'checkbox'} name={'verified'} />
|
||||
已逐件核对商品、收款、购料与关联影响,确认批准本次申请。
|
||||
</label>
|
||||
</>
|
||||
@@ -927,16 +919,16 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
<div className={'actions'}>
|
||||
{canReview ? (
|
||||
<>
|
||||
<button className={'primary'} name={'decision'} value={'approve'} type={'submit'}>
|
||||
<LedgerButton className={'primary'} name={'decision'} value={'approve'} type={'submit'}>
|
||||
批准申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
<button className={'danger'} name={'decision'} value={'reject'} type={'submit'}>
|
||||
<LedgerButton className={'danger'} name={'decision'} value={'reject'} type={'submit'}>
|
||||
驳回申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<div id={'price-lock-action-error'} aria-live={'polite'}></div>
|
||||
</form>
|
||||
@@ -951,51 +943,41 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
return result.rows.length ? (
|
||||
<>
|
||||
<div className={'table-wrap'}>
|
||||
<table className={'price-lock-change-list'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>原锁价单/客户</th>
|
||||
<th>申请</th>
|
||||
<th>申请人/日期</th>
|
||||
<th>状态</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
result.rows.map(row => (
|
||||
<>
|
||||
<tr>
|
||||
<td>
|
||||
{row.number || row.before?.number || '锁价单'}
|
||||
<div className={'small muted'}>{row.customer || row.before?.customer || ''}</div>
|
||||
</td>
|
||||
<td>
|
||||
{row.action === 'cancel' ? '录错作废' : '修改整单'}
|
||||
<div className={'small muted'}>{row.reason || ''}</div>
|
||||
</td>
|
||||
<td>
|
||||
{row.requester_name || row.requester || ''}
|
||||
<div className={'small muted'}>{row.created || ''}</div>
|
||||
</td>
|
||||
<td>
|
||||
{{
|
||||
pending: '待店主复核',
|
||||
approved: '已批准',
|
||||
rejected: '已驳回',
|
||||
}[row.status] || row.status}
|
||||
</td>
|
||||
<td>
|
||||
{button('查看申请', 'price-lock-change-open', '', {
|
||||
'data-id': row.requestId || row.id,
|
||||
})}
|
||||
</td>
|
||||
</tr>
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className={'price-lock-change-list'}
|
||||
columns={[
|
||||
{ title: '原锁价单/客户' },
|
||||
{ title: '申请' },
|
||||
{ title: '申请人/日期' },
|
||||
{ title: '状态' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={result.rows.map((row, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cells: [
|
||||
<>
|
||||
{row.number || row.before?.number || '锁价单'}
|
||||
<div className={'small muted'}>{row.customer || row.before?.customer || ''}</div>
|
||||
</>,
|
||||
<>
|
||||
{row.action === 'cancel' ? '录错作废' : '修改整单'}
|
||||
<div className={'small muted'}>{row.reason || ''}</div>
|
||||
</>,
|
||||
<>
|
||||
{row.requester_name || row.requester || ''}
|
||||
<div className={'small muted'}>{row.created || ''}</div>
|
||||
</>,
|
||||
{
|
||||
pending: '待店主复核',
|
||||
approved: '已批准',
|
||||
rejected: '已驳回',
|
||||
}[row.status] || row.status,
|
||||
button('查看申请', 'price-lock-change-open', '', {
|
||||
'data-id': row.requestId || row.id,
|
||||
}),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
@@ -1019,9 +1001,9 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
);
|
||||
}
|
||||
const button = (text: string, action: string, cls = '', props: Record<string, string | boolean | null> = {}) => (
|
||||
<button type="button" data-action={action} className={cls} {...props}>
|
||||
<LedgerButton type="button" data-action={action} className={cls} {...props}>
|
||||
{text}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
const materialSourceSegmentsText = (sources: SourceDescription[]) => describeMaterialSources(sources, teamMemberName);
|
||||
function priceLockMaterialAllocations(lock: LockRecord) {
|
||||
@@ -1120,85 +1102,72 @@ export function lockViews(state: LedgerState, session: SessionInfo) {
|
||||
return result.rows.length ? (
|
||||
<>
|
||||
<div className={'table-wrap'}>
|
||||
<table className={'price-lock-list'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>锁价日期/客户</th>
|
||||
<th>黄金商品</th>
|
||||
<th className={'number'}>锁定克重</th>
|
||||
<th className={'number'}>销售金价</th>
|
||||
<th className={'number'}>已收净额</th>
|
||||
<th>{status === 'cancelled' ? '原录入成本(已撤销记账)' : '原料来源/成本'}</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{Children.toArray(
|
||||
result.rows.map(lock => (
|
||||
<>
|
||||
<tr>
|
||||
<td>
|
||||
{lock.date}
|
||||
<br />
|
||||
{lock.customer}
|
||||
</td>
|
||||
<td>
|
||||
{priceLockLines(lock)
|
||||
.map(row => row.line?.name || '黄金')
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{part}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
<td className={'number'}>
|
||||
{grams(priceLockLines(lock).reduce((sum, row) => sum + row.locked_mg, 0))}g
|
||||
</td>
|
||||
<td className={'number'}>
|
||||
{priceLockLines(lock)
|
||||
.map(row => '¥' + yuan(row.sell_rate) + '/克')
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{part}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
<td className={'number'}>¥{yuan(lock.netReceived)}</td>
|
||||
<td>
|
||||
{priceLockLines(lock)
|
||||
.map(row => renderPriceLockItemFacts(row))
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <hr className="lock-row-divider" />}
|
||||
{part}
|
||||
</Fragment>
|
||||
))}
|
||||
</td>
|
||||
<td>
|
||||
<div className={'actions'}>
|
||||
{button('查看', 'open-price-lock', '', {
|
||||
'data-id': lock.id,
|
||||
})}
|
||||
{lock.status === 'pending' ? (
|
||||
<>
|
||||
{button('交付', 'deliver-price-lock', 'primary', {
|
||||
'data-id': lock.id,
|
||||
})}
|
||||
{renderPriceLockPendingButtons(lock)}
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className={'price-lock-list'}
|
||||
columns={[
|
||||
{ title: '锁价日期/客户' },
|
||||
{ title: '黄金商品' },
|
||||
{ title: '锁定克重', headerClassName: 'number' },
|
||||
{ title: '销售金价', headerClassName: 'number' },
|
||||
{ title: '已收净额', headerClassName: 'number' },
|
||||
{ title: status === 'cancelled' ? '原录入成本(已撤销记账)' : '原料来源/成本' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={result.rows.map((lock, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, 'number', 'number', 'number', undefined, undefined],
|
||||
cells: [
|
||||
<>
|
||||
{lock.date}
|
||||
<br />
|
||||
{lock.customer}
|
||||
</>,
|
||||
priceLockLines(lock)
|
||||
.map(row => row.line?.name || '黄金')
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{part}
|
||||
</Fragment>
|
||||
)),
|
||||
<>{grams(priceLockLines(lock).reduce((sum, row) => sum + row.locked_mg, 0))}g</>,
|
||||
priceLockLines(lock)
|
||||
.map(row => '¥' + yuan(row.sell_rate) + '/克')
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <br />}
|
||||
{part}
|
||||
</Fragment>
|
||||
)),
|
||||
<>¥{yuan(lock.netReceived)}</>,
|
||||
priceLockLines(lock)
|
||||
.map(row => renderPriceLockItemFacts(row))
|
||||
.map((part, i) => (
|
||||
<Fragment key={i}>
|
||||
{i > 0 && <hr className="lock-row-divider" />}
|
||||
{part}
|
||||
</Fragment>
|
||||
)),
|
||||
<>
|
||||
<div className={'actions'}>
|
||||
{button('查看', 'open-price-lock', '', {
|
||||
'data-id': lock.id,
|
||||
})}
|
||||
{lock.status === 'pending' ? (
|
||||
<>
|
||||
{button('交付', 'deliver-price-lock', 'primary', {
|
||||
'data-id': lock.id,
|
||||
})}
|
||||
{renderPriceLockPendingButtons(lock)}
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</div>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
) : status === 'cancelled' ? (
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { LedgerClient } from '../../lib/api';
|
||||
import type { LedgerState, SessionInfo, LockCostEstimate } from '../../shared';
|
||||
import type { Allocation, Impact } from '../MaterialPools/model';
|
||||
import type { QuoteBalance, QuoteEntry, QuoteSource } from '../../lib/materialQuote';
|
||||
import type { SavedPayment } from './formParts';
|
||||
import type { SavedPayment } from './formValues';
|
||||
import type { lockViews } from './lockViews';
|
||||
|
||||
export interface LockProps {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { LockViews, PreviewRow } from './types';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Calc, Model } from '../../shared';
|
||||
import { validatePools, poolRows } from '../MaterialPools/model';
|
||||
import { safeEstimate } from './formParts';
|
||||
import { safeEstimate } from './formValues';
|
||||
|
||||
// 公共料池以采购付款顺序分摊。先扣已用与本单前序行,余款才归本行。
|
||||
function publicQuote(pool: Pool | undefined, entries: QuoteEntry[], all: Pool[], state: LedgerState): PreviewRow[] {
|
||||
|
||||
@@ -4,7 +4,8 @@ type Cell = string | number | null | undefined;
|
||||
import { Model } from '../../shared';
|
||||
import { yuan } from '../../lib/format';
|
||||
import { count as stockCountText } from '../Inventory/data';
|
||||
import { rowLabel } from './controls';
|
||||
import { rowLabel } from './presentation';
|
||||
import { LedgerDataTable } from '../../components/BusinessControls';
|
||||
export function Comparison({ request, state }: { request: ChangeRequest; state: LedgerState }) {
|
||||
const before = request.before,
|
||||
after = request.after,
|
||||
@@ -212,24 +213,19 @@ export function Comparison({ request, state }: { request: ChangeRequest; state:
|
||||
</p>
|
||||
)}
|
||||
<div className="table-wrap">
|
||||
<table aria-label="回收更正原值与申请值">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>核对项目</th>
|
||||
<th>原值</th>
|
||||
<th>{request.action === 'cancel' ? '取消后' : '申请值'}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map(([t, a, b]) => (
|
||||
<tr key={t} className={String(a ?? '') !== String(b ?? '') ? 'modified' : undefined}>
|
||||
<th scope="row">{t}</th>
|
||||
<td>{a == null || a === '' ? '未提供' : a}</td>
|
||||
<td>{b == null || b === '' ? '未提供' : b}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
aria-label="回收更正原值与申请值"
|
||||
columns={[
|
||||
{ title: '核对项目', rowScope: 'row' },
|
||||
{ title: '原值' },
|
||||
{ title: request.action === 'cancel' ? '取消后' : '申请值' },
|
||||
]}
|
||||
rows={rows.map(([t, a, b]) => ({
|
||||
key: t,
|
||||
attributes: { className: String(a ?? '') !== String(b ?? '') ? 'modified' : undefined },
|
||||
cells: [t, a == null || a === '' ? '未提供' : a, b == null || b === '' ? '未提供' : b],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -5,14 +5,7 @@ import type { FormEvent } from 'react';
|
||||
import type { PageProps, RecoveryModel, DepositListData } from './types';
|
||||
import { useState } from 'react';
|
||||
import { grams } from '../../lib/format';
|
||||
export function validateDeposits(r: DepositListData) {
|
||||
if (
|
||||
!Array.isArray(r.rows) ||
|
||||
!Number.isSafeInteger(r.remainingMg) ||
|
||||
r.rows.some(i => !Number.isSafeInteger(i.remainingMg) || i.remainingMg < 0 || !Array.isArray(i.events))
|
||||
)
|
||||
throw new Error('寄存资料未完整返回');
|
||||
}
|
||||
import { LedgerButton, LedgerInput, LedgerTable } from '../../components/BusinessControls';
|
||||
export function DepositList({
|
||||
data,
|
||||
error,
|
||||
@@ -29,19 +22,19 @@ export function DepositList({
|
||||
<div className="panel-title">
|
||||
<h2>客户寄存料</h2>
|
||||
<div>
|
||||
<button data-action="customer-material-new" onClick={start}>
|
||||
<LedgerButton data-action="customer-material-new" onClick={start}>
|
||||
寄存,暂不结算
|
||||
</button>
|
||||
<button data-action="customer-material-refresh" onClick={refresh}>
|
||||
</LedgerButton>
|
||||
<LedgerButton data-action="customer-material-refresh" onClick={refresh}>
|
||||
刷新寄存记录
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
<p>公共寄存台账,仅按克重和备忘记录;不计入自有库存、购料成本或可用料池。</p>
|
||||
<div id="customer-material-list">
|
||||
{error ? (
|
||||
<div>
|
||||
{error} <button onClick={refresh}>重新读取</button>
|
||||
{error} <LedgerButton onClick={refresh}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : !data ? (
|
||||
'正在读取寄存记录…'
|
||||
@@ -53,7 +46,7 @@ export function DepositList({
|
||||
{'\u3000'}已用于置换<strong>{grams(data.usedMg)}g</strong>
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<LedgerTable>
|
||||
<thead>
|
||||
<tr>
|
||||
{['日期/寄存号', '备忘', '寄存', '已用', '剩余', '经办人/记录'].map(t => (
|
||||
@@ -97,7 +90,7 @@ export function DepositList({
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
@@ -143,11 +136,11 @@ export function DepositForm({ client, state, model, saved }: PageProps & { model
|
||||
<div className="recovery-row">
|
||||
<label>
|
||||
寄存日期
|
||||
<input type="date" name="date" defaultValue={draft.date || state.today} required max={state.today} />
|
||||
<LedgerInput type="date" name="date" defaultValue={draft.date || state.today} required max={state.today} />
|
||||
</label>
|
||||
<label>
|
||||
寄存克重(g)
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
name="grams"
|
||||
defaultValue={draft.grams || ''}
|
||||
@@ -159,7 +152,7 @@ export function DepositForm({ client, state, model, saved }: PageProps & { model
|
||||
</label>
|
||||
<label>
|
||||
备忘
|
||||
<input
|
||||
<LedgerInput
|
||||
type="text"
|
||||
name="memo"
|
||||
defaultValue={draft.memo || ''}
|
||||
@@ -170,16 +163,16 @@ export function DepositForm({ client, state, model, saved }: PageProps & { model
|
||||
</label>
|
||||
<label>
|
||||
经办人
|
||||
<input value={state.user.label || state.user.name} readOnly />
|
||||
<LedgerInput value={state.user.label || state.user.name} readOnly />
|
||||
</label>
|
||||
</div>
|
||||
<label>
|
||||
<input type="checkbox" name="verified" required defaultChecked={!!draft.verified} />
|
||||
<LedgerInput type="checkbox" name="verified" required defaultChecked={!!draft.verified} />
|
||||
已确认寄存克重和备忘,本次不结算
|
||||
</label>
|
||||
<button className="primary" type="submit" disabled={client.busy || !!client.pending()}>
|
||||
<LedgerButton className="primary" type="submit" disabled={client.busy || !!client.pending()}>
|
||||
保存寄存记录
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<div id="customer-material-error">{error}</div>
|
||||
</form>
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import type {
|
||||
ExtraKinds,
|
||||
PoolChoice,
|
||||
} from './types';
|
||||
import type { Choice } from './controls';
|
||||
import type { Choice } from './presentation';
|
||||
interface Fields {
|
||||
text(title: string, key: TextField, limit: number, props?: InputHTMLAttributes<HTMLInputElement>): ReactNode;
|
||||
num(title: string, key: TextField, places?: number, props?: InputHTMLAttributes<HTMLInputElement>): ReactNode;
|
||||
@@ -27,8 +27,10 @@ interface Fields {
|
||||
}
|
||||
import { Model } from '../../shared';
|
||||
import { grams } from '../../lib/format';
|
||||
import { pocketOptions, Settlement, money } from './controls';
|
||||
import { Settlement } from './controls';
|
||||
import { pocketOptions, money } from './presentation';
|
||||
import { describeMaterialSources } from '../../lib/materialQuote';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
// 早期的置换单按每件新货分别核算来料、差重和余料。修改时沿用原单结构。
|
||||
export function IndependentItems({
|
||||
@@ -86,14 +88,14 @@ export function IndependentItems({
|
||||
<section className="panel" key={i} data-recovery-item={i} data-recovery-product={i ? index : undefined}>
|
||||
<h2>置换商品 {i + 1}</h2>
|
||||
{i > 0 && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-remove-product"
|
||||
data-index={index}
|
||||
onClick={() => remove(index)}
|
||||
>
|
||||
移除商品
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<div className="recovery-row">
|
||||
{f.select('旧料来源', 'old_source', [
|
||||
@@ -173,14 +175,14 @@ export function IndependentItems({
|
||||
{f.num('折旧费单价(元/g)', 'depreciation_rate', 2, { required: true })}
|
||||
{f.num('折旧计费克重(g,可改)', 'depreciation_weight', 3, { required: true })}
|
||||
</div>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-item-reset-depreciation"
|
||||
data-index={i}
|
||||
onClick={() => setField('depreciation_manual', false, index)}
|
||||
>
|
||||
恢复本件默认折旧克重
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<div hidden={!hasBuy}>
|
||||
<h3>本件余料处理</h3>
|
||||
{f.select(
|
||||
@@ -201,14 +203,14 @@ export function IndependentItems({
|
||||
<div hidden={saveSurplus}>
|
||||
{f.rateField('回收单价(元/g)', 'buy_rate', true, { disabled: !hasBuy || saveSurplus })}
|
||||
{f.num('余料回收款(元,可改)', 'buy_total', 2, { required: true, disabled: !hasBuy || saveSurplus })}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-item-reset-buy"
|
||||
disabled={!hasBuy || saveSurplus}
|
||||
onClick={() => setField('buy_total_manual', false, index)}
|
||||
>
|
||||
恢复本件自动回收款
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</div>
|
||||
<h3>本件内部成本</h3>
|
||||
@@ -282,9 +284,9 @@ export function IndependentItems({
|
||||
</section>
|
||||
);
|
||||
})}
|
||||
<button type="button" data-action="recovery-add-product" onClick={add}>
|
||||
<LedgerButton type="button" data-action="recovery-add-product" onClick={add}>
|
||||
+ 添加置换新货
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<section className="panel">
|
||||
<h3>整单收费与费用</h3>
|
||||
<div className="recovery-row">
|
||||
|
||||
@@ -17,8 +17,17 @@ import { useCallback, useState } from 'react';
|
||||
import { Model } from '../../shared';
|
||||
import { grams } from '../../lib/format';
|
||||
import { useRead, dateValid, count } from '../Inventory/data';
|
||||
import { LegacyCount, Modal, Settlement, money, options, rowLabel } from './controls';
|
||||
import { LegacyCount, Modal, Settlement } from './controls';
|
||||
import { money, options, rowLabel } from './presentation';
|
||||
import { Comparison } from './Comparison';
|
||||
import {
|
||||
LedgerButton,
|
||||
LedgerDataTable,
|
||||
LedgerInput,
|
||||
LedgerSelect,
|
||||
LedgerTable,
|
||||
LedgerTextArea,
|
||||
} from '../../components/BusinessControls';
|
||||
const modes = { direct: '直接回收', exchange: '置换' };
|
||||
const status = (r: ChangeRequest) =>
|
||||
({ pending: '待店主复核', approved: r.action === 'cancel' ? '已同意取消' : '已同意修改', rejected: '已驳回' })[
|
||||
@@ -27,9 +36,9 @@ const status = (r: ChangeRequest) =>
|
||||
const print = (id: string) => window.open('/print/recoveries/' + encodeURIComponent(id), '_blank', 'noopener');
|
||||
export function PrintButton({ id, title = '客户预览/打印' }: { id: string; title?: string }) {
|
||||
return (
|
||||
<button data-action="recovery-print" data-id={id} onClick={() => print(id)}>
|
||||
<LedgerButton data-action="recovery-print" data-id={id} onClick={() => print(id)}>
|
||||
{title}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
function PrintBadge({ row, statuses }: { row: SummaryRow; statuses: PrintStatuses }) {
|
||||
@@ -81,9 +90,9 @@ export function Records({
|
||||
<section className="panel" id="recovery-history">
|
||||
<div className="panel-title">
|
||||
<h2>回收/置换记录</h2>
|
||||
<button data-action="recovery-refresh-list" onClick={() => retry(n => n + 1)}>
|
||||
<LedgerButton data-action="recovery-refresh-list" onClick={() => retry(n => n + 1)}>
|
||||
刷新记录
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<form
|
||||
id="recovery-filter-form"
|
||||
@@ -101,7 +110,7 @@ export function Records({
|
||||
).map(([k, t]) => (
|
||||
<label key={k}>
|
||||
{t}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
required
|
||||
max={state.today}
|
||||
@@ -113,25 +122,29 @@ export function Records({
|
||||
))}
|
||||
<label>
|
||||
业务类型
|
||||
<select name="mode" value={draft.mode} onChange={e => setDraft({ ...draft, mode: e.target.value })}>
|
||||
<LedgerSelect name="mode" value={draft.mode} onChange={e => setDraft({ ...draft, mode: e.target.value })}>
|
||||
{options([['', '全部'], ...Object.entries(modes)])}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
{state.user.role === 'owner' && (
|
||||
<label>
|
||||
归属成员
|
||||
<select name="member" value={draft.member} onChange={e => setDraft({ ...draft, member: e.target.value })}>
|
||||
<LedgerSelect
|
||||
name="member"
|
||||
value={draft.member}
|
||||
onChange={e => setDraft({ ...draft, member: e.target.value })}
|
||||
>
|
||||
{options([['', '全部成员'], ...Model.memberOptions(state)])}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
)}
|
||||
<button type="submit">查询</button>
|
||||
<LedgerButton type="submit">查询</LedgerButton>
|
||||
</form>
|
||||
<div id="recovery-list">
|
||||
{!valid || r?.error ? (
|
||||
<div>
|
||||
{r?.error || '日期请选今天或之前,开始日期不能晚于结束日期。'}{' '}
|
||||
<button onClick={() => retry(n => n + 1)}>重新读取</button>
|
||||
<LedgerButton onClick={() => retry(n => n + 1)}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : !r ? (
|
||||
'正在读取回收/置换记录…'
|
||||
@@ -141,46 +154,47 @@ export function Records({
|
||||
</p>
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['日期/单号', '客户/开单人', '类型/归属', '折后旧重', '新货克重', '实际收付', '操作'].map(t => (
|
||||
<th key={t}>{t}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{r.value!.rows.map(v => (
|
||||
<tr key={v.id}>
|
||||
<td>
|
||||
{v.date}
|
||||
<div>{v.number}</div>
|
||||
</td>
|
||||
<td>
|
||||
{v.customer}
|
||||
<div>{v.salesperson}</div>
|
||||
</td>
|
||||
<td>
|
||||
{modes[v.mode]}
|
||||
<div>{Model.memberName(state, v.member)}</div>
|
||||
</td>
|
||||
<td>{grams(v.oldMg)}g</td>
|
||||
<td>{v.mode === 'exchange' ? grams(v.newMg) + 'g' : '—'}</td>
|
||||
<td>
|
||||
{v.netSettlement > 0 ? '客户补款' : v.netSettlement < 0 ? '店里付款' : '无需现金'}
|
||||
<div>{money(Math.abs(v.netSettlement))}</div>
|
||||
</td>
|
||||
<td>
|
||||
<PrintBadge row={v} statuses={printStatuses} />
|
||||
<button data-action="recovery-open" data-id={v.id} onClick={() => detail(v.id)}>
|
||||
查看
|
||||
</button>
|
||||
<PrintButton title="打印" id={v.id} />
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '日期/单号' },
|
||||
{ title: '客户/开单人' },
|
||||
{ title: '类型/归属' },
|
||||
{ title: '折后旧重' },
|
||||
{ title: '新货克重' },
|
||||
{ title: '实际收付' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={r.value!.rows.map(v => ({
|
||||
key: v.id,
|
||||
cells: [
|
||||
<>
|
||||
{v.date}
|
||||
<div>{v.number}</div>
|
||||
</>,
|
||||
<>
|
||||
{v.customer}
|
||||
<div>{v.salesperson}</div>
|
||||
</>,
|
||||
<>
|
||||
{modes[v.mode]}
|
||||
<div>{Model.memberName(state, v.member)}</div>
|
||||
</>,
|
||||
<>{grams(v.oldMg)}g</>,
|
||||
v.mode === 'exchange' ? grams(v.newMg) + 'g' : '—',
|
||||
<>
|
||||
{v.netSettlement > 0 ? '客户补款' : v.netSettlement < 0 ? '店里付款' : '无需现金'}
|
||||
<div>{money(Math.abs(v.netSettlement))}</div>
|
||||
</>,
|
||||
<>
|
||||
<PrintBadge row={v} statuses={printStatuses} />
|
||||
<LedgerButton data-action="recovery-open" data-id={v.id} onClick={() => detail(v.id)}>
|
||||
查看
|
||||
</LedgerButton>
|
||||
<PrintButton title="打印" id={v.id} />
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -263,7 +277,7 @@ export function Detail({
|
||||
<Modal id="recovery-dialog" title={v?.customer || '回收/置换单'} action="recovery-close" close={close}>
|
||||
{response?.error ? (
|
||||
<div>
|
||||
{response.error} <button onClick={() => retry(n => n + 1)}>重新读取</button>
|
||||
{response.error} <LedgerButton onClick={() => retry(n => n + 1)}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : !v || !data ? (
|
||||
<p>正在读取单据…</p>
|
||||
@@ -276,14 +290,14 @@ export function Detail({
|
||||
<small>点击客户预览里的“打印”后自动记录。</small>
|
||||
<div className="actions">
|
||||
{data.permissions.canEdit && (
|
||||
<button data-id={id} data-action="recovery-edit-open" onClick={() => edit(id)}>
|
||||
<LedgerButton data-id={id} data-action="recovery-edit-open" onClick={() => edit(id)}>
|
||||
修改
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
{data.permissions.canCancel && (
|
||||
<button data-id={id} data-action="recovery-edit-cancel" onClick={() => cancel(id)}>
|
||||
<LedgerButton data-id={id} data-action="recovery-edit-cancel" onClick={() => cancel(id)}>
|
||||
取消这笔记录
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<PrintButton id={id} />
|
||||
{v.order_id && (
|
||||
@@ -302,26 +316,25 @@ export function Detail({
|
||||
</p>
|
||||
))}
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
{['旧料', '来料(g)', '熔后(g)', '成色', '折后(g)'].map(t => (
|
||||
<th key={t}>{t}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{v.old_lines.map((r, i) => (
|
||||
<tr key={i}>
|
||||
<td>{r.name || 'Au旧料'}</td>
|
||||
<td>{grams(r.incomingMg)}</td>
|
||||
<td>{grams(r.meltedMg)}</td>
|
||||
<td>{r.purity}%</td>
|
||||
<td>{grams(r.foldedMg)}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
columns={[
|
||||
{ title: '旧料' },
|
||||
{ title: '来料(g)' },
|
||||
{ title: '熔后(g)' },
|
||||
{ title: '成色' },
|
||||
{ title: '折后(g)' },
|
||||
]}
|
||||
rows={v.old_lines.map((r, i) => ({
|
||||
key: i,
|
||||
cells: [
|
||||
r.name || 'Au旧料',
|
||||
grams(r.incomingMg),
|
||||
grams(r.meltedMg),
|
||||
<>{r.purity}%</>,
|
||||
grams(r.foldedMg),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
<section className="panel">
|
||||
@@ -413,9 +426,9 @@ export function Detail({
|
||||
<h3>待店主复核</h3>
|
||||
<p>原记录仍生效,申请尚未记账。</p>
|
||||
<Comparison request={data.pending} state={state} />
|
||||
<button data-action="recovery-change-open" onClick={() => review(data.pending!.id)}>
|
||||
<LedgerButton data-action="recovery-change-open" onClick={() => review(data.pending!.id)}>
|
||||
{state.user.role === 'owner' ? '查看并复核' : '查看申请'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</section>
|
||||
)}
|
||||
{!!data.history.length && (
|
||||
@@ -424,9 +437,9 @@ export function Detail({
|
||||
{data.history.map(h => (
|
||||
<p key={h.id}>
|
||||
{status(h)} · {h.reason}{' '}
|
||||
<button data-action="recovery-change-open" onClick={() => review(h.id)}>
|
||||
<LedgerButton data-action="recovery-change-open" onClick={() => review(h.id)}>
|
||||
查看申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</p>
|
||||
))}
|
||||
</details>
|
||||
@@ -543,7 +556,7 @@ export function ChangeDialog({
|
||||
>
|
||||
{reply?.error ? (
|
||||
<div>
|
||||
{reply.error} <button onClick={reread}>重新读取</button>
|
||||
{reply.error} <LedgerButton onClick={reread}>重新读取</LedgerButton>
|
||||
</div>
|
||||
) : !r ? (
|
||||
'正在读取…'
|
||||
@@ -558,7 +571,7 @@ export function ChangeDialog({
|
||||
['all', '全部'],
|
||||
] as const
|
||||
).map(([k, t]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
key={k}
|
||||
data-action="recovery-changes-filter"
|
||||
data-status={k}
|
||||
@@ -567,10 +580,10 @@ export function ChangeDialog({
|
||||
>
|
||||
{t}
|
||||
{k !== 'all' && '(' + r.counts[k] + ')'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
</div>
|
||||
<table>
|
||||
<LedgerTable>
|
||||
<thead>
|
||||
<tr>
|
||||
{['原记录', '动作', '申请人', '状态', '操作'].map(t => (
|
||||
@@ -588,9 +601,12 @@ export function ChangeDialog({
|
||||
<td>{row.requesterName}</td>
|
||||
<td>{status(row)}</td>
|
||||
<td>
|
||||
<button data-action="recovery-change-open" onClick={() => select({ kind: 'request', id: row.id })}>
|
||||
<LedgerButton
|
||||
data-action="recovery-change-open"
|
||||
onClick={() => select({ kind: 'request', id: row.id })}
|
||||
>
|
||||
查看
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
@@ -600,7 +616,7 @@ export function ChangeDialog({
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
) : 'permissions' in r ? (
|
||||
<>
|
||||
@@ -613,25 +629,25 @@ export function ChangeDialog({
|
||||
<LegacyCount value={r.permissions} />
|
||||
<label>
|
||||
取消原因
|
||||
<textarea name="reason" required maxLength={200} rows={2} />
|
||||
<LedgerTextArea name="reason" required maxLength={200} rows={2} />
|
||||
</label>
|
||||
<label>
|
||||
<input type="checkbox" name="verified" required />
|
||||
<LedgerInput type="checkbox" name="verified" required />
|
||||
已核实这笔记录需要取消,并核对关联用料自动重算与实际收付款。
|
||||
</label>
|
||||
<button type="button" data-action="recovery-changes-close" onClick={close}>
|
||||
<LedgerButton type="button" data-action="recovery-changes-close" onClick={close}>
|
||||
返回
|
||||
</button>
|
||||
<button type="submit" disabled={stale || client.busy || !!client.pending()}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" disabled={stale || client.busy || !!client.pending()}>
|
||||
{r.permissions.requiresApproval ? '提交取消申请' : '确认取消记录'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</form>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<button data-action="recovery-changes-open" onClick={() => select({ kind: 'list' })}>
|
||||
<LedgerButton data-action="recovery-changes-open" onClick={() => select({ kind: 'list' })}>
|
||||
返回申请列表
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<p>
|
||||
{status(r)} · {r.requesterName}提交{r.reviewerName && ' · ' + r.reviewerName + '复核'}
|
||||
</p>
|
||||
@@ -645,40 +661,40 @@ export function ChangeDialog({
|
||||
{!decision ? (
|
||||
<>
|
||||
{r.canApprove && !r.stale && (
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="recovery-change-decision"
|
||||
data-kind="approve"
|
||||
onClick={() => setDecision('approve')}
|
||||
>
|
||||
同意申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="recovery-change-decision"
|
||||
data-kind="reject"
|
||||
onClick={() => setDecision('reject')}
|
||||
>
|
||||
驳回申请
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
) : (
|
||||
<form id="recovery-change-review-form" data-kind={decision} onSubmit={submit}>
|
||||
<label>
|
||||
{decision === 'reject' ? '驳回意见' : '复核备注(选填)'}
|
||||
<textarea name="note" maxLength={200} rows={2} required={decision === 'reject'} />
|
||||
<LedgerTextArea name="note" maxLength={200} rows={2} required={decision === 'reject'} />
|
||||
</label>
|
||||
{decision === 'approve' && (
|
||||
<label>
|
||||
<input name="verified" type="checkbox" required />
|
||||
<LedgerInput name="verified" type="checkbox" required />
|
||||
已核对申请内容及关联账务,确认同意。
|
||||
</label>
|
||||
)}
|
||||
<button type="button" onClick={() => setDecision('')}>
|
||||
<LedgerButton type="button" onClick={() => setDecision('')}>
|
||||
返回
|
||||
</button>
|
||||
<button type="submit" disabled={stale || client.busy || !!client.pending()}>
|
||||
</LedgerButton>
|
||||
<LedgerButton type="submit" disabled={stale || client.busy || !!client.pending()}>
|
||||
{decision === 'approve' ? '确认同意' : '确认驳回'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</form>
|
||||
)}
|
||||
</div>
|
||||
@@ -687,7 +703,7 @@ export function ChangeDialog({
|
||||
)}
|
||||
{message && (
|
||||
<p role="alert">
|
||||
{message} {stale && <button onClick={reread}>重新读取</button>}
|
||||
{message} {stale && <LedgerButton onClick={reread}>重新读取</LedgerButton>}
|
||||
</p>
|
||||
)}
|
||||
</Modal>
|
||||
|
||||
@@ -5,12 +5,13 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useRead } from '../Inventory/data';
|
||||
import { useClientSnapshot } from '../../lib/useClient';
|
||||
import { usePrintStatuses } from '../../lib/printStatus';
|
||||
import { recoveryModel } from './model';
|
||||
import { recoveryModel, validateDeposits } from './model';
|
||||
import { Head } from './controls';
|
||||
import { RecoveryForm } from './RecoveryForm';
|
||||
import { DepositForm, DepositList, validateDeposits } from './Deposit';
|
||||
import { DepositForm, DepositList } from './Deposit';
|
||||
import { Records, Detail, ChangeDialog, PrintButton } from './Records';
|
||||
import './recoveries.css';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
const lastQuery = new WeakMap<LedgerClient, { user: string; value: Filters }>();
|
||||
export function RecoveriesPage({ client, state, search = window.location.search }: PageProps & { search?: string }) {
|
||||
@@ -133,7 +134,7 @@ export function RecoveriesPage({ client, state, search = window.location.search
|
||||
{page === 'deposit' ? (
|
||||
<>
|
||||
<Head eye="CUSTOMER MATERIAL" title="寄存,暂不结算" sub="只记已确认克重与备忘,不按当天金价结算。">
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="customer-material-back"
|
||||
onClick={() => {
|
||||
setPage('new');
|
||||
@@ -141,7 +142,7 @@ export function RecoveriesPage({ client, state, search = window.location.search
|
||||
}}
|
||||
>
|
||||
返回回收/置换
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</Head>
|
||||
<DepositForm
|
||||
key={formKey}
|
||||
@@ -172,13 +173,13 @@ export function RecoveriesPage({ client, state, search = window.location.search
|
||||
? '购料和回收旧料库存已经一并登记。'
|
||||
: '等重实物、补金差重和余料已按本单结算登记。'}
|
||||
</p>
|
||||
<button data-action="recovery-open" onClick={() => setDetail(result.r.id)}>
|
||||
<LedgerButton data-action="recovery-open" onClick={() => setDetail(result.r.id)}>
|
||||
查看已保存单据
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<PrintButton id={result.r.id} />
|
||||
<button data-action="recovery-new" onClick={newForm}>
|
||||
<LedgerButton data-action="recovery-new" onClick={newForm}>
|
||||
继续开另一单
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
@@ -190,20 +191,20 @@ export function RecoveriesPage({ client, state, search = window.location.search
|
||||
>
|
||||
{!edit && (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
data-action="recovery-scroll-list"
|
||||
onClick={() => historyRef.current?.scrollIntoView({ behavior: 'smooth' })}
|
||||
>
|
||||
查看记录
|
||||
</button>
|
||||
<button
|
||||
</LedgerButton>
|
||||
<LedgerButton
|
||||
id="recovery-changes-entry"
|
||||
data-action="recovery-changes-open"
|
||||
onClick={() => select({ kind: 'list' })}
|
||||
>
|
||||
{state.user.role === 'owner' ? '回收更正复核' : '回收更正申请'}(
|
||||
{count?.value?.counts.pending ?? (count?.error ? '读取失败' : '…')})
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
)}
|
||||
</Head>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { recoveryDraftKey, recoveryEditKey } from './receipts';
|
||||
import { derive } from './derive';
|
||||
import type { ChangeEvent, FormEvent, InputHTMLAttributes, SelectHTMLAttributes } from 'react';
|
||||
import type { ApiError } from '../../lib/api';
|
||||
import type { Choice } from './controls';
|
||||
import type { Choice } from './presentation';
|
||||
import type {
|
||||
EditDetail,
|
||||
Draft,
|
||||
@@ -24,10 +24,12 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Model, Cards } from '../../shared';
|
||||
import { grams } from '../../lib/format';
|
||||
import { memberAccountPrefix, recoveryModel } from './model';
|
||||
import { LegacyCount, Settlement, money, options, pocketOptions, rowLabel } from './controls';
|
||||
import { LegacyCount, Settlement } from './controls';
|
||||
import { money, options, pocketOptions, rowLabel } from './presentation';
|
||||
import { IndependentItems } from './IndependentItems';
|
||||
import { localMaterialNote, quotedMaterialNote } from './materialPreview';
|
||||
import { useRead } from '../Inventory/data';
|
||||
import { LedgerButton, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
|
||||
function RecoveryCardFee({ state, edit, net }: { state: PageProps['state']; edit: EditDetail | null; net: number }) {
|
||||
const rate = edit ? edit.record.credit_card_rate_permille : state.shopSettings?.creditCardRatePermille;
|
||||
@@ -48,6 +50,32 @@ function RecoveryCardFee({ state, edit, net }: { state: PageProps['state']; edit
|
||||
}
|
||||
|
||||
const basicMethods = ['微信', '支付宝', '现金'];
|
||||
function DailyRateButton({
|
||||
field,
|
||||
index,
|
||||
prefix,
|
||||
disabled,
|
||||
apply,
|
||||
}: {
|
||||
field: TextField;
|
||||
index: number;
|
||||
prefix: string;
|
||||
disabled: boolean;
|
||||
apply: (field: TextField, index: number) => Promise<void>;
|
||||
}) {
|
||||
return (
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-use-daily-rate"
|
||||
data-rate-field={prefix + field}
|
||||
disabled={disabled}
|
||||
onClick={() => void apply(field, index)}
|
||||
>
|
||||
使用当日加权料价
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
|
||||
export function RecoveryForm({
|
||||
client,
|
||||
state,
|
||||
@@ -252,7 +280,7 @@ export function RecoveryForm({
|
||||
) => (
|
||||
<label>
|
||||
{title}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="text"
|
||||
{...attrs(k)}
|
||||
value={(index < 0 ? raw : raw.extra_products![index])[k] ?? ''}
|
||||
@@ -264,7 +292,7 @@ export function RecoveryForm({
|
||||
const num = (title: string, k: TextField, places = 2, props: InputHTMLAttributes<HTMLInputElement> = {}) => (
|
||||
<label>
|
||||
{title}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
min="0"
|
||||
step={places === 3 ? '0.001' : '0.01'}
|
||||
@@ -282,15 +310,15 @@ export function RecoveryForm({
|
||||
) => (
|
||||
<label>
|
||||
{title}
|
||||
<select {...attrs(k)} {...props}>
|
||||
<LedgerSelect {...attrs(k)} {...props}>
|
||||
{options(choices)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
);
|
||||
const pairs = (title: string, k: TextField, pocket: string, visible = true, optional = false) => (
|
||||
<label hidden={!visible || !Model.pocketCountsEnabled(state, pocket)}>
|
||||
{title}
|
||||
<input
|
||||
<LedgerInput
|
||||
type="number"
|
||||
min="1"
|
||||
max="1000000000"
|
||||
@@ -308,15 +336,7 @@ export function RecoveryForm({
|
||||
{num(title, k, 2, { required: true, ...props })}
|
||||
{use && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
data-action="recovery-use-daily-rate"
|
||||
data-rate-field={prefix + k}
|
||||
disabled={off}
|
||||
onClick={() => daily(k, index)}
|
||||
>
|
||||
使用当日加权料价
|
||||
</button>
|
||||
<DailyRateButton field={k} index={index} prefix={prefix} disabled={off} apply={daily} />
|
||||
<p data-rate-status>{rate.name === k && rate.index === index ? rate.text : ''}</p>
|
||||
</>
|
||||
)}
|
||||
@@ -339,9 +359,14 @@ export function RecoveryForm({
|
||||
>
|
||||
<h3>置换新货 {index + 2}</h3>
|
||||
{index >= 0 && (
|
||||
<button type="button" data-action="recovery-remove-product" data-index={index} onClick={() => remove(index)}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-remove-product"
|
||||
data-index={index}
|
||||
onClick={() => remove(index)}
|
||||
>
|
||||
移除商品
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<div className="recovery-row">
|
||||
{f.text('新货商品', 'new_name', 60, { list: 'recovery-product-names', required: true })}
|
||||
@@ -458,11 +483,15 @@ export function RecoveryForm({
|
||||
: '费用名称'
|
||||
: t}
|
||||
{k === 'payer' ? (
|
||||
<select name={name} value={String(r[k] || '')} onChange={e => change(i + 1, k, e.target.value)}>
|
||||
<LedgerSelect
|
||||
name={name}
|
||||
value={String(r[k] || '')}
|
||||
onChange={e => change(i + 1, k, e.target.value)}
|
||||
>
|
||||
{options(members)}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
) : (
|
||||
<input
|
||||
<LedgerInput
|
||||
name={name}
|
||||
type={number ? 'number' : 'text'}
|
||||
required
|
||||
@@ -478,7 +507,7 @@ export function RecoveryForm({
|
||||
</label>
|
||||
);
|
||||
})}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-edit-remove-row"
|
||||
data-kind={kind}
|
||||
@@ -486,25 +515,25 @@ export function RecoveryForm({
|
||||
onClick={() => updateRows(rows.filter((_, j) => j !== i + 1))}
|
||||
>
|
||||
移除这项
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-edit-add-row"
|
||||
data-kind={kind}
|
||||
onClick={() => updateRows([...(rows.length ? rows : [defaults]), { ...defaults }])}
|
||||
>
|
||||
+ 添加{caption}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<form id="recovery-form" data-recovery-edit={edit ? 'true' : undefined} onSubmit={submit}>
|
||||
{local.invalid !== null && <p role="alert">{unreadableDraft}</p>}
|
||||
<input type="hidden" name="mode" value={d.mode} />
|
||||
<input type="hidden" name="shared_old_notice" value={d.shared_old_notice || ''} />
|
||||
<LedgerInput type="hidden" name="mode" value={d.mode} />
|
||||
<LedgerInput type="hidden" name="shared_old_notice" value={d.shared_old_notice || ''} />
|
||||
{!edit && (
|
||||
<div className="actions">
|
||||
{(
|
||||
@@ -513,7 +542,7 @@ export function RecoveryForm({
|
||||
['exchange', '置换'],
|
||||
] as const
|
||||
).map(([mode, name]) => (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
key={mode}
|
||||
data-action="recovery-mode"
|
||||
@@ -522,11 +551,11 @@ export function RecoveryForm({
|
||||
onClick={() => setRaw({ ...d, mode, buy_total_manual: false, buy_total: '', verified: false })}
|
||||
>
|
||||
{name}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
))}
|
||||
<button type="button" data-action="customer-material-new" onClick={deposit}>
|
||||
<LedgerButton type="button" data-action="customer-material-new" onClick={deposit}>
|
||||
寄存,暂不结算
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
)}
|
||||
<section className="panel">
|
||||
@@ -535,7 +564,7 @@ export function RecoveryForm({
|
||||
<div className="recovery-row">
|
||||
<label>
|
||||
业务日期
|
||||
<input type="date" {...attrs('date')} max={state.today} required />
|
||||
<LedgerInput type="date" {...attrs('date')} max={state.today} required />
|
||||
</label>
|
||||
{text('客户称呼/代号', 'customer', 60, { required: true, placeholder: '必填' })}
|
||||
{exchange && (
|
||||
@@ -546,7 +575,7 @@ export function RecoveryForm({
|
||||
['returning', '老客户'],
|
||||
].map(([k, t]) => (
|
||||
<label key={k}>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="radio"
|
||||
name="customer_type"
|
||||
value={k}
|
||||
@@ -565,8 +594,8 @@ export function RecoveryForm({
|
||||
) : (
|
||||
<label>
|
||||
归属成员
|
||||
<input value={Model.memberName(state, d.member)} readOnly />
|
||||
<input type="hidden" name="member" value={d.member} />
|
||||
<LedgerInput value={Model.memberName(state, d.member)} readOnly />
|
||||
<LedgerInput type="hidden" name="member" value={d.member} />
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
@@ -679,9 +708,9 @@ export function RecoveryForm({
|
||||
</datalist>
|
||||
{product(d, -1)}
|
||||
{d.extra_products?.map((r, i) => product(r, i))}
|
||||
<button type="button" data-action="recovery-add-product" onClick={add} disabled={!exchange}>
|
||||
<LedgerButton type="button" data-action="recovery-add-product" onClick={add} disabled={!exchange}>
|
||||
+ 添加置换新货
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<span>补金、折旧和余料按新货总克重结算;每件可选不同货盘或外配。</span>
|
||||
<h3>整单差重与折旧</h3>
|
||||
<div className="recovery-row">
|
||||
@@ -694,14 +723,14 @@ export function RecoveryForm({
|
||||
{num('折旧费单价(元/g)', 'depreciation_rate', 2, { required: true, disabled: !exchange })}
|
||||
{num('折旧计费克重(g,可改)', 'depreciation_weight', 3, { required: true, disabled: !exchange })}
|
||||
</div>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-reset-depreciation"
|
||||
disabled={!exchange}
|
||||
onClick={() => setField('depreciation_manual', false)}
|
||||
>
|
||||
恢复默认克重
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<details>
|
||||
<summary>其他收费与优惠(选填)</summary>
|
||||
<div className="recovery-row">
|
||||
@@ -761,14 +790,14 @@ export function RecoveryForm({
|
||||
required: true,
|
||||
disabled: !hasBuy || surplusDeposit,
|
||||
})}
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-reset-buy"
|
||||
disabled={!hasBuy || surplusDeposit}
|
||||
onClick={() => setField('buy_total_manual', false)}
|
||||
>
|
||||
恢复自动金额
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<p>
|
||||
{q
|
||||
@@ -885,7 +914,7 @@ export function RecoveryForm({
|
||||
{conflict && (
|
||||
<div>
|
||||
记录已有变动,填写已保留,请核对最新记录。
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-edit-reload"
|
||||
onClick={async () => {
|
||||
@@ -897,9 +926,9 @@ export function RecoveryForm({
|
||||
}}
|
||||
>
|
||||
重新读取并核对
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{conflict.latest && (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-edit-keep"
|
||||
onClick={() => {
|
||||
@@ -909,7 +938,7 @@ export function RecoveryForm({
|
||||
}}
|
||||
>
|
||||
已核对最新记录,保留填写继续
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
@@ -917,7 +946,7 @@ export function RecoveryForm({
|
||||
)}
|
||||
{text('备注(选填,可打印)', 'note', 240)}
|
||||
<label>
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="verified"
|
||||
required
|
||||
@@ -927,13 +956,13 @@ export function RecoveryForm({
|
||||
已核实重量、结算金额和实际收付款
|
||||
</label>
|
||||
{edit && (
|
||||
<button type="button" data-action="recovery-edit-close" onClick={exitEdit}>
|
||||
<LedgerButton type="button" data-action="recovery-edit-close" onClick={exitEdit}>
|
||||
取消修改
|
||||
</button>
|
||||
</LedgerButton>
|
||||
)}
|
||||
<button className="primary" id="recovery-save" type="submit" disabled={disabled || !!conflict}>
|
||||
<LedgerButton className="primary" id="recovery-save" type="submit" disabled={disabled || !!conflict}>
|
||||
{edit ? (approval ? '提交修改申请' : '保存修改') : '保存' + (exchange ? '置换' : '回收') + '单'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<span id="recovery-quote-status" aria-live="polite">
|
||||
{signature ? (quote.signature === signature ? quote.text : '正在核对结算…') : ''}
|
||||
</span>
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import type { LedgerState } from '../../shared';
|
||||
import type { Draft, Input, Totals, Permission } from './types';
|
||||
export type Choice = string | readonly (string | boolean)[];
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Model } from '../../shared';
|
||||
import { grams, yuan } from '../../lib/format';
|
||||
export const money = (value?: number | null) => (value == null ? '待填写' : '¥' + yuan(value));
|
||||
export const rowLabel = (s: LedgerState, key?: string) => s.pocketCatalog?.find(p => p.key === key)?.name || key;
|
||||
export function options(pairs: readonly Choice[]) {
|
||||
return pairs.map(opt => {
|
||||
const [value, text, disabled] = typeof opt === 'string' ? [opt, opt] : opt;
|
||||
return (
|
||||
<option key={String(value)} value={String(value)} disabled={!!disabled}>
|
||||
{text}
|
||||
</option>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
import { money } from './presentation';
|
||||
import { grams } from '../../lib/format';
|
||||
import { LedgerButton, LedgerDialog, LedgerInput } from '../../components/BusinessControls';
|
||||
export function Head({ eye, title, sub, children }: { eye: string; title: string; sub: string; children?: ReactNode }) {
|
||||
return (
|
||||
<header className="page-heading">
|
||||
@@ -42,27 +29,26 @@ export function Modal({
|
||||
action: string;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
useEffect(() => {
|
||||
const d = ref.current!;
|
||||
d.showModal();
|
||||
return () => d.close();
|
||||
}, []);
|
||||
return (
|
||||
<dialog
|
||||
ref={ref}
|
||||
<LedgerDialog
|
||||
id={id}
|
||||
onCancel={e => {
|
||||
e.preventDefault();
|
||||
close();
|
||||
}}
|
||||
>
|
||||
<button type="button" className="dialog-close" aria-label={'关闭' + title} data-action={action} onClick={close}>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
className="dialog-close"
|
||||
aria-label={'关闭' + title}
|
||||
data-action={action}
|
||||
onClick={close}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<h2 id={id === 'recovery-dialog' ? 'recovery-detail-title' : 'recovery-change-title'}>{title}</h2>
|
||||
{children}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
export function Settlement({ q, draft, input }: { q?: Totals | null; draft?: Draft; input?: Partial<Input> | null }) {
|
||||
@@ -157,23 +143,12 @@ export function Settlement({ q, draft, input }: { q?: Totals | null; draft?: Dra
|
||||
</>
|
||||
);
|
||||
}
|
||||
export function pocketOptions(state: LedgerState, key: string, historical: boolean, blank?: string) {
|
||||
const active = Model.activePocketKeys(state),
|
||||
result: (string | boolean)[][] = active.map(p => [p, rowLabel(state, p) || p]);
|
||||
if (key && !active.includes(key))
|
||||
result.push([
|
||||
key,
|
||||
rowLabel(state, key) + (historical ? '(已停用 · 原货盘)' : '(已停用,请重新选择)'),
|
||||
!historical,
|
||||
]);
|
||||
return blank ? [['', blank], ...result] : result;
|
||||
}
|
||||
export function LegacyCount({ value }: { value?: Permission }) {
|
||||
return value?.requiresLegacyCountVerified ? (
|
||||
<>
|
||||
<p>{value.legacyCountNotice || '这笔历史记录未记录对数,当前对数按实际盘点基准保留。'}</p>
|
||||
<label>
|
||||
<input type="checkbox" name="legacyCountVerified" required />
|
||||
<LedgerInput type="checkbox" name="legacyCountVerified" required />
|
||||
已核对当前对数基准,理解本次更正对历史对数的处理
|
||||
</label>
|
||||
</>
|
||||
|
||||
@@ -4,7 +4,7 @@ import type { Input, Draft, EditDetail, Calculation, QuoteItem, MaterialPool, Re
|
||||
import { Calc, Model } from '../../shared';
|
||||
import { grams } from '../../lib/format';
|
||||
import { describeMaterialBalance, describeMaterialSources, validateMaterialQuote } from '../../lib/materialQuote';
|
||||
import { money } from './controls';
|
||||
import { money } from './presentation';
|
||||
|
||||
// 与结算报价分开读取料池余额。余额暂不可用时仍可核对已算出的来源、成本和结算。
|
||||
export async function quotedMaterialNote(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { LedgerState } from '../../shared';
|
||||
import type { EditDetail } from './types';
|
||||
import type { EditDetail, DepositListData } from './types';
|
||||
import RecoveryRules from '@public/recovery-rules.js';
|
||||
import { Model, Calc, Values } from '../../shared';
|
||||
import { countValue, dateValid as validOrderDate } from '../Inventory/data';
|
||||
@@ -24,3 +24,12 @@ export function recoveryModel(state: LedgerState, editData: EditDetail | null =
|
||||
isSilver: Calc.isSilver,
|
||||
});
|
||||
}
|
||||
|
||||
export function validateDeposits(r: DepositListData) {
|
||||
if (
|
||||
!Array.isArray(r.rows) ||
|
||||
!Number.isSafeInteger(r.remainingMg) ||
|
||||
r.rows.some(i => !Number.isSafeInteger(i.remainingMg) || i.remainingMg < 0 || !Array.isArray(i.events))
|
||||
)
|
||||
throw new Error('寄存资料未完整返回');
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Model, type LedgerState } from '../../shared';
|
||||
import { yuan } from '../../lib/format';
|
||||
export type Choice = string | readonly (string | boolean)[];
|
||||
export const money = (value?: number | null) => (value == null ? '待填写' : '¥' + yuan(value));
|
||||
export const rowLabel = (s: LedgerState, key?: string) => s.pocketCatalog?.find(p => p.key === key)?.name || key;
|
||||
export function options(pairs: readonly Choice[]) {
|
||||
return pairs.map(opt => {
|
||||
const [value, text, disabled] = typeof opt === 'string' ? [opt, opt] : opt;
|
||||
return (
|
||||
<option key={String(value)} value={String(value)} disabled={!!disabled}>
|
||||
{text}
|
||||
</option>
|
||||
);
|
||||
});
|
||||
}
|
||||
export function pocketOptions(state: LedgerState, key: string, historical: boolean, blank?: string) {
|
||||
const active = Model.activePocketKeys(state),
|
||||
result: (string | boolean)[][] = active.map(p => [p, rowLabel(state, p) || p]);
|
||||
if (key && !active.includes(key))
|
||||
result.push([
|
||||
key,
|
||||
rowLabel(state, key) + (historical ? '(已停用 · 原货盘)' : '(已停用,请重新选择)'),
|
||||
!historical,
|
||||
]);
|
||||
return blank ? [['', blank], ...result] : result;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
.recoveries-page {
|
||||
color: var(--ink, #233832);
|
||||
color: var(--ink, var(--ink));
|
||||
min-width: 0;
|
||||
}
|
||||
.recoveries-page [hidden] {
|
||||
@@ -14,13 +14,13 @@
|
||||
font-size: clamp(1.9rem, 4vw, 3rem);
|
||||
}
|
||||
.recoveries-page p {
|
||||
color: var(--muted, #596963);
|
||||
color: var(--muted, var(--muted));
|
||||
line-height: 1.55;
|
||||
}
|
||||
.recoveries-page .panel,
|
||||
.recoveries-page .stock-review-status {
|
||||
background: var(--surface, #fff);
|
||||
border: 1px solid var(--line, #dce4df);
|
||||
background: var(--surface, var(--white));
|
||||
border: 1px solid var(--line, var(--border));
|
||||
border-radius: 12px;
|
||||
padding: 18px;
|
||||
margin-block: 14px;
|
||||
@@ -64,7 +64,7 @@
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 8px;
|
||||
border: 1px solid #b9c6bf;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
color: inherit;
|
||||
background: white;
|
||||
@@ -78,7 +78,7 @@
|
||||
}
|
||||
.recoveries-page button {
|
||||
cursor: pointer;
|
||||
border: 1px solid #b9c6bf;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 7px;
|
||||
background: white;
|
||||
color: inherit;
|
||||
@@ -91,7 +91,7 @@
|
||||
}
|
||||
.recoveries-page .primary,
|
||||
.recoveries-page button[aria-pressed='true'] {
|
||||
background: #254f46;
|
||||
background: var(--green);
|
||||
color: white;
|
||||
}
|
||||
.recoveries-page .table-wrap {
|
||||
@@ -105,7 +105,7 @@
|
||||
.recoveries-page td,
|
||||
.recoveries-page th {
|
||||
padding: 9px;
|
||||
border-bottom: 1px solid #dde4df;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: top;
|
||||
}
|
||||
.recoveries-page th {
|
||||
@@ -113,7 +113,7 @@
|
||||
}
|
||||
.recoveries-page dialog {
|
||||
position: fixed;
|
||||
border: 1px solid #dce4df;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 13px;
|
||||
max-width: min(720px, 94vw);
|
||||
width: 100%;
|
||||
@@ -124,13 +124,13 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.recoveries-page dialog::backdrop {
|
||||
background: #18332b55;
|
||||
background: color-mix(in srgb, var(--ink) 33%, transparent);
|
||||
}
|
||||
.recoveries-page .dialog-close {
|
||||
float: right;
|
||||
}
|
||||
.recoveries-page .error {
|
||||
color: #9a372c;
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.recoveries-page .recovery-net {
|
||||
@@ -142,12 +142,12 @@
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
.recoveries-page .modified {
|
||||
background: #fff8e7;
|
||||
background: var(--internal-bg);
|
||||
}
|
||||
.recoveries-page table td {
|
||||
white-space: pre-line;
|
||||
}
|
||||
.recoveries-page .recovery-new-product {
|
||||
border-top: 1px solid #dce4df;
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 10px;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import { useEffect, useEffectEvent, useLayoutEffect, useRef, useState } from 're
|
||||
import { Calc, Model } from '../../shared';
|
||||
import { Button, Choice, Dialog, Field } from '../Settings/controls';
|
||||
import { errorText } from '../Settings/settingsModel';
|
||||
import { LedgerButton, LedgerInput, LedgerTable, LedgerTextArea } from '../../components/BusinessControls';
|
||||
|
||||
type View = ReturnType<typeof reportPresentation>;
|
||||
interface Props {
|
||||
@@ -84,7 +85,7 @@ function PendingList({
|
||||
<h2>所有日期待复核报销单({list.counts.pending})</h2>
|
||||
<p className="small muted">点击原报销日期查看并复核;批准后回到该日期的应转合计。</p>
|
||||
<div className="table-wrap">
|
||||
<table className="daily-reimbursements-global-table" aria-label="所有日期待复核报销单">
|
||||
<LedgerTable className="daily-reimbursements-global-table" aria-label="所有日期待复核报销单">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>报销日期</th>
|
||||
@@ -123,7 +124,7 @@ function PendingList({
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<span className="small muted">
|
||||
@@ -480,7 +481,7 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
含未售现货采购及当天实际对外付款。不含客户退款(已从净收款扣除)、双方互转或报销转账。之前已经支付的货品,后续卖出不算一笔新支出。
|
||||
</p>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="verified"
|
||||
checked={out.verified}
|
||||
@@ -492,9 +493,9 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
</label>
|
||||
{errBox('daily-outlay-error', 'outlay')}
|
||||
<div className="actions">
|
||||
<button type="submit" className="primary" disabled={blocked}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked}>
|
||||
确认当天支出
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{data?.ready && btn('收起', 'daily-outlay-close')}
|
||||
</div>
|
||||
</form>
|
||||
@@ -570,7 +571,7 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
<div className="reimbursement-item-row" data-index={i} key={item.id || item.sourceKey || i}>
|
||||
<label>
|
||||
<span className="sr-only">项目 {i + 1}</span>
|
||||
<input
|
||||
<LedgerInput
|
||||
name="itemName"
|
||||
value={item.name}
|
||||
required
|
||||
@@ -583,7 +584,7 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
</label>
|
||||
<label>
|
||||
<span className="sr-only">金额 {i + 1}</span>
|
||||
<input
|
||||
<LedgerInput
|
||||
name="itemAmount"
|
||||
value={item.amount}
|
||||
type="number"
|
||||
@@ -656,9 +657,9 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
</p>
|
||||
{errBox('reimbursement-error', 'draft')}
|
||||
<div className="actions">
|
||||
<button className="primary" type="submit" disabled={blocked}>
|
||||
<LedgerButton className="primary" type="submit" disabled={blocked}>
|
||||
{draft.id ? '保存并重新提交复核' : '提交店主复核'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
@@ -679,7 +680,7 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
{view.renderReimbursementItems(row)}
|
||||
<label>
|
||||
{review.kind === 'reject' ? '驳回原因' : '复核备注(选填)'}
|
||||
<textarea
|
||||
<LedgerTextArea
|
||||
name="note"
|
||||
maxLength={300}
|
||||
rows={2}
|
||||
@@ -691,7 +692,7 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
</label>
|
||||
{review.kind === 'approve' && (
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
name="verified"
|
||||
checked={review.verified}
|
||||
@@ -706,9 +707,9 @@ export function Reimbursements({ client, state, view, data, query, changeDate, r
|
||||
)}
|
||||
{errBox('reimbursement-review-error', 'review')}
|
||||
<div className="actions">
|
||||
<button type="submit" className="primary" disabled={blocked}>
|
||||
<LedgerButton type="submit" className="primary" disabled={blocked}>
|
||||
{review.kind === 'approve' ? '同意报销' : '确认驳回'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
)}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { errorText } from '../Settings/settingsModel';
|
||||
import { reportPresentation } from './presentation';
|
||||
import { Reimbursements } from './Reimbursements';
|
||||
import './report.css';
|
||||
import { LedgerInput } from '../../components/BusinessControls';
|
||||
|
||||
type ReportProps = Pick<ReportContext, 'state' | 'session'> & { client: LedgerClient };
|
||||
type Reply = { query: ReportQuery; version: number } & (
|
||||
@@ -168,7 +169,7 @@ export function ReportPage({ client, state, session }: ReportProps) {
|
||||
)}
|
||||
<label>
|
||||
对账日期
|
||||
<input
|
||||
<LedgerInput
|
||||
type="date"
|
||||
id="report-date"
|
||||
value={query.date}
|
||||
@@ -178,7 +179,7 @@ export function ReportPage({ client, state, session }: ReportProps) {
|
||||
/>
|
||||
</label>
|
||||
<label className="check">
|
||||
<input
|
||||
<LedgerInput
|
||||
type="checkbox"
|
||||
id="report-month"
|
||||
checked={query.month}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
|
||||
import type * as T from './contracts';
|
||||
import { Children } from 'react';
|
||||
import { reportData } from './reportData';
|
||||
import { LedgerButton, LedgerDataTable, LedgerTable } from '../../components/BusinessControls';
|
||||
const withKeys = Children.toArray;
|
||||
const fallback = (rows: ReactNode[], empty: ReactNode) => (rows.length ? rows : empty);
|
||||
const e = (value: unknown) => (value == null ? '' : String(value));
|
||||
@@ -103,7 +104,7 @@ export function reportPresentation({
|
||||
<h2>按收款账户核对</h2>
|
||||
<p className="small muted">{reportPeriod(range)}普通订单当前收付,加上同期锁价实际收付。</p>
|
||||
<div className="table-wrap">
|
||||
<table aria-label="按收款账户核对">
|
||||
<LedgerTable aria-label="按收款账户核对">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>账户</th>
|
||||
@@ -139,7 +140,7 @@ export function reportPresentation({
|
||||
<td className="number">¥{yuan(receipts.net)}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
<p className="small muted report-cost-note">
|
||||
请按这些订单的收退款记录与微信、支付宝、现金、信用卡核对;系统尚未接入支付平台账单。
|
||||
@@ -173,14 +174,14 @@ export function reportPresentation({
|
||||
r.warnings.map(w => (
|
||||
<li>
|
||||
{w.id ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-order"
|
||||
data-id={w.id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{w.number}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
@@ -195,23 +196,23 @@ export function reportPresentation({
|
||||
<div className="form-actions">
|
||||
<div className={'small ' + (close?.stale ? 'danger-text' : 'muted')}>{closeStatus}</div>
|
||||
<div className="actions">
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="download-report"
|
||||
className=""
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'下载对账报告'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{state.user.role === 'owner' && !reportMonth ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="close-day"
|
||||
className="primary"
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'保存核对快照'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
@@ -255,7 +256,7 @@ export function reportPresentation({
|
||||
{reportPeriod(table)} · 按日期、订单归属人核对。勾选“汇总当月”可查看当月逐日利润。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table aria-label="每日利润明细">
|
||||
<LedgerTable aria-label="每日利润明细">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">日期</th>
|
||||
@@ -301,7 +302,7 @@ export function reportPresentation({
|
||||
{amounts(table.summary)}
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
<p className="small muted report-daily-profit-note">
|
||||
普通订单按开单日、锁价成单按交付日、售后按记录日归集。成本含实际耗用料费和费用;退货、作废沿原账冲回。
|
||||
@@ -349,7 +350,7 @@ export function reportPresentation({
|
||||
{!readOnly ? (
|
||||
<div className="actions">
|
||||
{row.canEdit && row.status !== 'approved' ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="reimbursement-edit"
|
||||
className=""
|
||||
@@ -357,13 +358,13 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{row.status === 'rejected' ? '修改后重新提交' : '修改报销单'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
{dailyFundsOwner() && row.canApprove && row.status === 'pending' ? (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="reimbursement-approve"
|
||||
className="primary"
|
||||
@@ -371,8 +372,8 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'复核通过'}
|
||||
</button>
|
||||
<button
|
||||
</LedgerButton>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="reimbursement-reject"
|
||||
className=""
|
||||
@@ -380,7 +381,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'驳回'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
@@ -413,7 +414,7 @@ export function reportPresentation({
|
||||
''
|
||||
)}
|
||||
<div className="table-wrap">
|
||||
<table className="daily-funds-month-table" aria-label="每日转账核对汇总">
|
||||
<LedgerTable className="daily-funds-month-table" aria-label="每日转账核对汇总">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
@@ -430,7 +431,7 @@ export function reportPresentation({
|
||||
data.days.map(day => (
|
||||
<tr>
|
||||
<td>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="daily-funds-open-date"
|
||||
className="link-button"
|
||||
@@ -438,7 +439,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{day.date}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</td>
|
||||
<td className="number">¥{yuan(day.ownerReceipts.net)}</td>
|
||||
<td className="number">{dailyFundsMoney(day.actualOutlay)}</td>
|
||||
@@ -455,7 +456,7 @@ export function reportPresentation({
|
||||
</tr>,
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -473,7 +474,7 @@ export function reportPresentation({
|
||||
按真实付款日期记录的费用、日购料和锁价采购等;不把普通订单耗用成本当作当天付款。完整总额以店主核实为准。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table aria-label={'' + teamMemberName('owner') + '已记录实际付款参考'}>
|
||||
<LedgerTable aria-label={'' + teamMemberName('owner') + '已记录实际付款参考'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>付款日期</th>
|
||||
@@ -502,7 +503,7 @@ export function reportPresentation({
|
||||
</tr>,
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</details>
|
||||
);
|
||||
@@ -666,7 +667,7 @@ export function reportPresentation({
|
||||
普通订单按开单日归集;每日购料按实际购买日期归集,订单耗用料费不再计一次支出;锁价料费、工费与费用按实际付款日归集,原锁料费不在交付时重复计入。实际支出可能与本期订单耗用成本不同。转账请以核实后的完整实际支出为准。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table className="report-payer-table" aria-label={'助理与' + teamMemberName('owner') + '支出成本'}>
|
||||
<LedgerTable className="report-payer-table" aria-label={'助理与' + teamMemberName('owner') + '支出成本'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>付款人</th>
|
||||
@@ -712,7 +713,7 @@ export function reportPresentation({
|
||||
<td className="number">{reportCostAmount(r.outlayTotal ?? r.goods + r.expense, missing + pending)}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
{withKeys(people.map(reportCostDetails))}
|
||||
<p className="small muted report-cost-note">
|
||||
@@ -750,42 +751,39 @@ export function reportPresentation({
|
||||
<details>
|
||||
<summary>查看 {rows.length} 项收付记录</summary>
|
||||
<div className="table-wrap">
|
||||
<table className="lock-activity-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期/锁价单</th>
|
||||
<th>项目/客户</th>
|
||||
<th>账户/付款人</th>
|
||||
<th className="number">金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{withKeys(
|
||||
rows.map(item => (
|
||||
<tr>
|
||||
<td>
|
||||
{item.date}
|
||||
<br />
|
||||
<button
|
||||
className="link-button"
|
||||
data-action="open-price-lock"
|
||||
data-id={item.price_lock_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.number || '锁价记录'}
|
||||
</button>
|
||||
</td>
|
||||
<td>
|
||||
{item.activityType} · {item.activityName}
|
||||
<div className="small muted">{item.customer}</div>
|
||||
</td>
|
||||
<td>{item.who}</td>
|
||||
<td className="number">{item.amount == null ? '待补齐' : '¥' + yuan(item.amount)}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="lock-activity-table"
|
||||
columns={[
|
||||
{ title: '日期/锁价单' },
|
||||
{ title: '项目/客户' },
|
||||
{ title: '账户/付款人' },
|
||||
{ title: '金额', headerClassName: 'number' },
|
||||
]}
|
||||
rows={rows.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, undefined, undefined, 'number'],
|
||||
cells: [
|
||||
<>
|
||||
{item.date}
|
||||
<br />
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-price-lock"
|
||||
data-id={item.price_lock_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.number || '锁价记录'}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
<>
|
||||
{item.activityType} · {item.activityName}
|
||||
<div className="small muted">{item.customer}</div>
|
||||
</>,
|
||||
item.who,
|
||||
item.amount == null ? '待补齐' : '¥' + yuan(item.amount),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
</section>
|
||||
@@ -801,39 +799,36 @@ export function reportPresentation({
|
||||
按实际购买日期计支出,与下方订单耗用成本分别核对;本表金额已包含在上方双方实际支出中。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>购料日期</th>
|
||||
<th className="number">购买克重</th>
|
||||
<th className="number">实际总价</th>
|
||||
<th>付款人</th>
|
||||
<th>备注</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{withKeys(
|
||||
activity.purchases.map(item => (
|
||||
<tr>
|
||||
<td>
|
||||
<button
|
||||
className="link-button"
|
||||
data-action="goto-material-pools"
|
||||
data-id={item.pool_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.date}
|
||||
</button>
|
||||
</td>
|
||||
<td className="number">{grams(item.mg)}g</td>
|
||||
<td className="number">¥{yuan(item.amount)}</td>
|
||||
<td>{materialPayerName(materialPurchasePayer(item))}</td>
|
||||
<td>{item.note}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="material-detail-table"
|
||||
columns={[
|
||||
{ title: '购料日期' },
|
||||
{ title: '购买克重', headerClassName: 'number' },
|
||||
{ title: '实际总价', headerClassName: 'number' },
|
||||
{ title: '付款人' },
|
||||
{ title: '备注' },
|
||||
]}
|
||||
rows={activity.purchases.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, 'number', 'number', undefined, undefined],
|
||||
cells: [
|
||||
<>
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="goto-material-pools"
|
||||
data-id={item.pool_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.date}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
<>{grams(item.mg)}g</>,
|
||||
<>¥{yuan(item.amount)}</>,
|
||||
materialPayerName(materialPurchasePayer(item)),
|
||||
item.note,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
@@ -849,7 +844,7 @@ export function reportPresentation({
|
||||
范围内,普通订单按开单日、锁价成单按交付日、售后按记录日期归集。这里显示订单完整耗用成本,与上方实际付款分开核对;旧草稿不计金额。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table className="report-order-table" aria-label="订单与售后净额明细">
|
||||
<LedgerTable className="report-order-table" aria-label="订单与售后净额明细">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期/单号或售后项目</th>
|
||||
@@ -905,7 +900,7 @@ export function reportPresentation({
|
||||
<td className="number">{reportSummaryAmount(s, 'profit')}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
@@ -978,7 +973,7 @@ export function reportPresentation({
|
||||
{teamMemberName('owner')}直收款的订单,先复核货款与利润归属。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table>
|
||||
<LedgerTable>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>订单</th>
|
||||
@@ -994,14 +989,14 @@ export function reportPresentation({
|
||||
r.unsettled.map(o => (
|
||||
<tr>
|
||||
<td>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-order"
|
||||
data-id={o.id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{o.number}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</td>
|
||||
<td className="number">{materialReportMoney(o.costDue)}</td>
|
||||
<td className="number">{materialReportMoney(o.profitDue)}</td>
|
||||
@@ -1015,7 +1010,7 @@ export function reportPresentation({
|
||||
</tr>,
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
@@ -1030,70 +1025,67 @@ export function reportPresentation({
|
||||
{teamMemberName('assistant')}垫付的未耗用材料单独核对;耗用后按订单分摊,避免在订单与剩余料款重复结算。
|
||||
</p>
|
||||
<div className="table-wrap">
|
||||
<table className="material-detail-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>购料日期</th>
|
||||
<th className="number">{teamMemberName('assistant')}垫付的剩余料款</th>
|
||||
<th className="number">实际已交净额</th>
|
||||
<th className="number">本批料款待结</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{withKeys(
|
||||
value.pools.map(item => (
|
||||
<tr>
|
||||
<td>
|
||||
<button
|
||||
className="link-button"
|
||||
data-action="goto-material-pools"
|
||||
data-id={item.id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.date}
|
||||
</button>
|
||||
</td>
|
||||
<td className="number">{materialReportMoney(item.assistantInventoryCredit)}</td>
|
||||
<td className="number">¥{yuan(item.transferred)}</td>
|
||||
<td className="number">
|
||||
{materialReportMoney(item.settlementDue)}
|
||||
{(item.settlementDue ?? 0) < 0 ? (
|
||||
<LedgerDataTable
|
||||
className="material-detail-table"
|
||||
columns={[
|
||||
{ title: '购料日期' },
|
||||
{ title: <>{teamMemberName('assistant')}垫付的剩余料款</>, headerClassName: 'number' },
|
||||
{ title: '实际已交净额', headerClassName: 'number' },
|
||||
{ title: '本批料款待结', headerClassName: 'number' },
|
||||
]}
|
||||
rows={value.pools.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
cellClasses: [undefined, 'number', 'number', 'number'],
|
||||
cells: [
|
||||
<>
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="goto-material-pools"
|
||||
data-id={item.id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.date}
|
||||
</LedgerButton>
|
||||
</>,
|
||||
materialReportMoney(item.assistantInventoryCredit),
|
||||
<>¥{yuan(item.transferred)}</>,
|
||||
<>
|
||||
{materialReportMoney(item.settlementDue)}
|
||||
{(item.settlementDue ?? 0) < 0 ? (
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<div className="small muted"></div>
|
||||
{teamMemberName('owner')}
|
||||
</>
|
||||
{' → '}
|
||||
</>
|
||||
{teamMemberName('assistant')}
|
||||
</>
|
||||
{'</div>'}
|
||||
</>
|
||||
) : (item.settlementDue ?? 0) > 0 ? (
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<div className="small muted"></div>
|
||||
{teamMemberName('assistant')}
|
||||
</>
|
||||
{' → '}
|
||||
</>
|
||||
<div className="small muted"></div>
|
||||
{teamMemberName('owner')}
|
||||
</>
|
||||
{'</div>'}
|
||||
{' → '}
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
{teamMemberName('assistant')}
|
||||
</>
|
||||
{'</div>'}
|
||||
</>
|
||||
) : (item.settlementDue ?? 0) > 0 ? (
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<>
|
||||
<div className="small muted"></div>
|
||||
{teamMemberName('assistant')}
|
||||
</>
|
||||
{' → '}
|
||||
</>
|
||||
{teamMemberName('owner')}
|
||||
</>
|
||||
{'</div>'}
|
||||
</>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
<p
|
||||
className="small muted"
|
||||
@@ -1185,7 +1177,7 @@ export function reportPresentation({
|
||||
</span>
|
||||
</summary>
|
||||
<div className="table-wrap" tabIndex={0} role="region" aria-label={person.name + name + '明细表'}>
|
||||
<table className="report-receipt-table" aria-label={person.name + name + '逐笔明细'}>
|
||||
<LedgerTable className="report-receipt-table" aria-label={person.name + name + '逐笔明细'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>实际{name}日/归集口径</th>
|
||||
@@ -1233,7 +1225,7 @@ export function reportPresentation({
|
||||
<td className="number">¥{yuan(person[kind])}</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</details>
|
||||
);
|
||||
@@ -1258,7 +1250,7 @@ export function reportPresentation({
|
||||
</span>
|
||||
</summary>
|
||||
<div className="table-wrap">
|
||||
<table className="report-cost-detail-table" aria-label={'' + cost.name + '支出成本逐项明细'}>
|
||||
<LedgerTable className="report-cost-detail-table" aria-label={'' + cost.name + '支出成本逐项明细'}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期/单号或客户</th>
|
||||
@@ -1312,7 +1304,7 @@ export function reportPresentation({
|
||||
</tr>,
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
</div>
|
||||
</details>
|
||||
);
|
||||
@@ -1321,7 +1313,7 @@ export function reportPresentation({
|
||||
function orderBookIdentity(row: T.Row, version?: string) {
|
||||
if (row.kind === 'orderAfterSale')
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="open-order"
|
||||
data-id={row.order_id || row.id}
|
||||
@@ -1330,12 +1322,12 @@ export function reportPresentation({
|
||||
<strong className="order-book-customer-name">{row.customer || '未填称呼'}</strong>
|
||||
<span className="order-book-secondary muted">订单售后 · {row.paper_number || row.number}</span>
|
||||
<span className="small muted">查看原单售后结果</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
if (row.kind === 'recovery')
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="recovery-open"
|
||||
data-id={row.recovery_id || row.id}
|
||||
@@ -1347,8 +1339,8 @@ export function reportPresentation({
|
||||
</span>
|
||||
<span className="order-book-secondary muted">{row.number}</span>
|
||||
<span className="order-book-recovery-payment">回收付款 ¥{yuan(row.cashPayment)}</span>
|
||||
</button>
|
||||
<button
|
||||
</LedgerButton>
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="recovery-print"
|
||||
className="quiet order-book-recovery-print"
|
||||
@@ -1357,7 +1349,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'打印'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</>
|
||||
);
|
||||
if (version !== undefined) {
|
||||
@@ -1380,7 +1372,7 @@ export function reportPresentation({
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link order-book-customer-first"
|
||||
data-action="open-order"
|
||||
data-id={row.id}
|
||||
@@ -1389,7 +1381,7 @@ export function reportPresentation({
|
||||
>
|
||||
{customer}
|
||||
<span className="order-book-secondary muted">{row.paper_number || row.number}</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
if (row.kind === 'afterSale')
|
||||
@@ -1401,7 +1393,7 @@ export function reportPresentation({
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button order-book-link"
|
||||
data-action="open-order"
|
||||
data-id={row.id}
|
||||
@@ -1410,7 +1402,7 @@ export function reportPresentation({
|
||||
>
|
||||
<strong>{row.paper_number || row.number}</strong>
|
||||
<span>{row.customer || '未填称呼'}</span>
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1517,31 +1509,30 @@ export function reportPresentation({
|
||||
)}
|
||||
{day.items.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="report-owner-advance-table" aria-label={day.date + ' ' + label}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>日期</th>
|
||||
<th>客户/单号</th>
|
||||
<th>成本项目</th>
|
||||
<th className="number">{teamMemberName('owner')}承担金额</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{withKeys(
|
||||
day.items.map(item => (
|
||||
<tr className={item.status === 'recorded' ? undefined : 'report-pending-cost'}>
|
||||
<td>{item.date}</td>
|
||||
<td>{reportOwnerAdvanceIdentity(item)}</td>
|
||||
<td>
|
||||
{item.name}
|
||||
{item.source ? <small className="muted">{item.source}</small> : ''}
|
||||
</td>
|
||||
<td className="number">{reportOwnerAdvanceItemAmount(item)}</td>
|
||||
</tr>
|
||||
)),
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="report-owner-advance-table"
|
||||
aria-label={day.date + ' ' + label}
|
||||
columns={[
|
||||
{ title: '日期' },
|
||||
{ title: '客户/单号' },
|
||||
{ title: '成本项目' },
|
||||
{ title: <>{teamMemberName('owner')}承担金额</>, headerClassName: 'number' },
|
||||
]}
|
||||
rows={day.items.map((item, rowIndex) => ({
|
||||
key: rowIndex,
|
||||
attributes: { className: item.status === 'recorded' ? undefined : 'report-pending-cost' },
|
||||
cellClasses: [undefined, undefined, undefined, 'number'],
|
||||
cells: [
|
||||
item.date,
|
||||
reportOwnerAdvanceIdentity(item),
|
||||
<>
|
||||
{item.name}
|
||||
{item.source ? <small className="muted">{item.source}</small> : ''}
|
||||
</>,
|
||||
reportOwnerAdvanceItemAmount(item),
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
@@ -1661,7 +1652,7 @@ export function reportPresentation({
|
||||
function renderReportReceiptIdentity(item: T.ReceiptItem) {
|
||||
const number = item.paper_number || item.number || (item.price_lock_id ? '锁价记录' : '订单记录');
|
||||
const identity = item.order_id ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="open-order"
|
||||
className="link-button"
|
||||
@@ -1669,9 +1660,9 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{number}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : item.price_lock_id ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="open-price-lock"
|
||||
className="link-button"
|
||||
@@ -1679,7 +1670,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{number}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
number
|
||||
);
|
||||
@@ -1691,7 +1682,7 @@ export function reportPresentation({
|
||||
</>
|
||||
{item.order_id && item.price_lock_id ? (
|
||||
<div className="small">
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="open-price-lock"
|
||||
className="link-button"
|
||||
@@ -1699,7 +1690,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'原锁价单'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
@@ -1710,14 +1701,14 @@ export function reportPresentation({
|
||||
|
||||
function materialReportCostLink(item: T.CostItem) {
|
||||
return item.materialPoolId ? (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="goto-material-pools"
|
||||
data-id={item.materialPoolId}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.materialPoolId} 购料
|
||||
</button>
|
||||
</LedgerButton>
|
||||
) : (
|
||||
priceLockCostLink(item)
|
||||
);
|
||||
@@ -1725,7 +1716,7 @@ export function reportPresentation({
|
||||
|
||||
function afterSaleEditButton(row: T.Row) {
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
type="button"
|
||||
data-action="after-sale-edit"
|
||||
className="after-sale-edit-button"
|
||||
@@ -1734,7 +1725,7 @@ export function reportPresentation({
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{'修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1776,14 +1767,14 @@ export function reportPresentation({
|
||||
function reportOwnerAdvanceIdentity(item: T.AdvanceItem) {
|
||||
return item.kind === 'order' ? (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-order"
|
||||
data-id={item.id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.customer || '未填客户'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<small className="muted">{item.paperNumber || item.number}</small>
|
||||
</>
|
||||
) : (
|
||||
@@ -1799,26 +1790,26 @@ export function reportPresentation({
|
||||
if (item.price_lock_id)
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-price-lock"
|
||||
data-id={item.price_lock_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.number || '锁价记录'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
{item.customer ? <div className="small muted">{item.customer}</div> : ''}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<button
|
||||
<LedgerButton
|
||||
className="link-button"
|
||||
data-action="open-order"
|
||||
data-id={item.order_id}
|
||||
onClick={event => onAction(event.currentTarget.dataset)}
|
||||
>
|
||||
{item.paper_number || item.number}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
.report-page {
|
||||
min-width: 0;
|
||||
line-height: 1.55;
|
||||
color: #233f32;
|
||||
color: var(--ink);
|
||||
font-size: 14px;
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
.report-page .panel,
|
||||
.report-page .stat {
|
||||
min-width: 0;
|
||||
background: #fff;
|
||||
border: 1px solid #d9e4df;
|
||||
background: var(--white);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
padding: clamp(14px, 2vw, 24px);
|
||||
margin: 12px 0;
|
||||
@@ -29,7 +29,7 @@
|
||||
.report-page h1,
|
||||
.report-page h2,
|
||||
.report-page h3 {
|
||||
color: #193c2e;
|
||||
color: var(--green);
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.report-page h1 {
|
||||
@@ -55,7 +55,7 @@
|
||||
.report-page select,
|
||||
.report-page textarea {
|
||||
font: inherit;
|
||||
border: 1px solid #b8cbbf;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
color: inherit;
|
||||
padding: 6px 9px;
|
||||
@@ -68,7 +68,7 @@
|
||||
}
|
||||
.report-page button.primary {
|
||||
color: white;
|
||||
background: #23583d;
|
||||
background: var(--green);
|
||||
}
|
||||
.report-page button:disabled {
|
||||
opacity: 0.5;
|
||||
@@ -77,7 +77,7 @@
|
||||
.report-page .muted,
|
||||
.report-page .eyebrow,
|
||||
.report-page .hint {
|
||||
color: #566d61;
|
||||
color: var(--muted);
|
||||
}
|
||||
.report-page .small,
|
||||
.report-page .hint {
|
||||
@@ -85,7 +85,7 @@
|
||||
}
|
||||
.report-page .error,
|
||||
.report-page .danger-text {
|
||||
color: #96332d;
|
||||
color: var(--danger);
|
||||
}
|
||||
.report-page .stat > strong,
|
||||
.report-page .daily-transfer-parts strong,
|
||||
@@ -110,19 +110,19 @@
|
||||
}
|
||||
.report-page summary {
|
||||
cursor: pointer;
|
||||
color: #234b35;
|
||||
color: var(--green);
|
||||
}
|
||||
.report-page p {
|
||||
margin: 6px 0 10px;
|
||||
}
|
||||
.report-page .note,
|
||||
.report-page .badge {
|
||||
background: #edf5f0;
|
||||
background: var(--soft);
|
||||
border-radius: 6px;
|
||||
padding: 5px 8px;
|
||||
}
|
||||
.report-page .warn {
|
||||
background: #fbefdd;
|
||||
background: var(--internal-bg);
|
||||
}
|
||||
.report-page .table-wrap {
|
||||
overflow: auto;
|
||||
@@ -135,7 +135,7 @@
|
||||
.report-page th,
|
||||
.report-page td {
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #d9e4df;
|
||||
border-bottom: 1px solid var(--border);
|
||||
padding: 7px;
|
||||
vertical-align: top;
|
||||
}
|
||||
@@ -147,7 +147,7 @@
|
||||
.report-page .link-button {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
color: #235c3e;
|
||||
color: var(--green);
|
||||
text-align: left;
|
||||
}
|
||||
.report-page .link-button > span,
|
||||
@@ -171,7 +171,7 @@
|
||||
.report-page button:focus-visible,
|
||||
.report-page input:focus-visible,
|
||||
.report-page summary:focus-visible {
|
||||
outline: 2px solid #3d7a52;
|
||||
outline: 2px solid var(--green-hover);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.report-page .sr-only {
|
||||
@@ -188,12 +188,12 @@
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
padding: 20px;
|
||||
border: 1px solid #cbdacf;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
color: inherit;
|
||||
}
|
||||
.report-page dialog::backdrop {
|
||||
background: #132a1e66;
|
||||
background: color-mix(in srgb, var(--ink) 40%, transparent);
|
||||
}
|
||||
.report-page .dialog-close {
|
||||
float: right;
|
||||
@@ -205,7 +205,7 @@
|
||||
transform: translateX(-50%);
|
||||
pointer-events: none;
|
||||
z-index: 10;
|
||||
background: #edf5ef;
|
||||
background: var(--soft);
|
||||
border-radius: 8px;
|
||||
padding: 10px 16px;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { type LedgerClient } from '../../lib/api';
|
||||
import { Calc, Fees, type MemberRow } from '../../shared';
|
||||
import { Button, Choice, Dialog, Field } from './controls';
|
||||
import { errorText, memberOptions, readForm, type Notice, type Shop } from './settingsModel';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput } from '../../components/BusinessControls';
|
||||
|
||||
interface Cost {
|
||||
name: string;
|
||||
@@ -108,7 +109,7 @@ export function Costs({
|
||||
</div>
|
||||
<label className="shop-cost-search">
|
||||
搜索成本
|
||||
<input
|
||||
<LedgerInput
|
||||
type="search"
|
||||
id="shop-cost-search"
|
||||
placeholder="输入成本名称"
|
||||
@@ -120,52 +121,50 @@ export function Costs({
|
||||
<div id="shop-cost-list">
|
||||
{visible.length ? (
|
||||
<div className="table-wrap">
|
||||
<table className="shop-cost-table">
|
||||
<thead>
|
||||
<tr>
|
||||
{['成本名称', '金额/单价', '付款人', '计费方式', '状态', '操作'].map(text => (
|
||||
<th key={text}>{text}</th>
|
||||
))}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{visible.map(([kind, row]) => (
|
||||
<tr key={kind} data-cost-row={kind}>
|
||||
<td>
|
||||
<strong>{row.name}</strong>
|
||||
</td>
|
||||
<td>¥{row.amount}</td>
|
||||
<td>
|
||||
{row.payer === 'order'
|
||||
? '订单归属人'
|
||||
: members.find(m => m.member === row.payer)?.label || '待确认'}
|
||||
</td>
|
||||
<td>{row.byQuantity ? '单价 × 数量' : '每单一次'}</td>
|
||||
<td>{row.enabled ? '启用' : '停用'}</td>
|
||||
<td>
|
||||
<div className="actions">
|
||||
<Button
|
||||
action="shop-cost-edit"
|
||||
className="quiet"
|
||||
data-kind={kind}
|
||||
onClick={() => open('edit', kind)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Button
|
||||
action="shop-cost-delete"
|
||||
className="danger"
|
||||
data-kind={kind}
|
||||
onClick={() => open('delete', kind)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<LedgerDataTable
|
||||
className="shop-cost-table"
|
||||
columns={[
|
||||
{ title: '成本名称' },
|
||||
{ title: '金额/单价' },
|
||||
{ title: '付款人' },
|
||||
{ title: '计费方式' },
|
||||
{ title: '状态' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={visible.map(([kind, row]) => ({
|
||||
key: kind,
|
||||
attributes: { 'data-cost-row': kind },
|
||||
cells: [
|
||||
<>
|
||||
<strong>{row.name}</strong>
|
||||
</>,
|
||||
<>¥{row.amount}</>,
|
||||
row.payer === 'order' ? '订单归属人' : members.find(m => m.member === row.payer)?.label || '待确认',
|
||||
row.byQuantity ? '单价 × 数量' : '每单一次',
|
||||
row.enabled ? '启用' : '停用',
|
||||
<>
|
||||
<div className="actions">
|
||||
<Button
|
||||
action="shop-cost-edit"
|
||||
className="quiet"
|
||||
data-kind={kind}
|
||||
onClick={() => open('edit', kind)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Button
|
||||
action="shop-cost-delete"
|
||||
className="danger"
|
||||
data-kind={kind}
|
||||
onClick={() => open('delete', kind)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</div>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<p className="empty">
|
||||
@@ -251,9 +250,13 @@ export function Costs({
|
||||
<Button action="shop-cost-close" className="quiet" onClick={close} disabled={saving}>
|
||||
取消
|
||||
</Button>
|
||||
<button type="submit" className={editor.action === 'delete' ? 'danger' : 'primary'} disabled={saving}>
|
||||
<LedgerButton
|
||||
type="submit"
|
||||
className={editor.action === 'delete' ? 'danger' : 'primary'}
|
||||
disabled={saving}
|
||||
>
|
||||
{editor.action === 'delete' ? '确认删除' : '保存成本'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useSta
|
||||
import type { ApiError, LedgerClient } from '../../lib/api';
|
||||
import { Button, Choice, Dialog, Field } from './controls';
|
||||
import { errorText, readForm, type LeaveChecks, type Notice } from './settingsModel';
|
||||
import { LedgerButton, LedgerDataTable, LedgerInput } from '../../components/BusinessControls';
|
||||
|
||||
interface Employee {
|
||||
member: string;
|
||||
@@ -312,9 +313,9 @@ export const Employees = forwardRef<
|
||||
defaultValue={filter.status}
|
||||
disabled={guarded}
|
||||
/>
|
||||
<button type="submit" disabled={guarded}>
|
||||
<LedgerButton type="submit" disabled={guarded}>
|
||||
搜索
|
||||
</button>
|
||||
</LedgerButton>
|
||||
<Button action="employee-reload" className="quiet" disabled={guarded} onClick={load}>
|
||||
刷新
|
||||
</Button>
|
||||
@@ -333,97 +334,97 @@ export const Employees = forwardRef<
|
||||
<p className="empty">没有符合条件的员工。</p>
|
||||
) : (
|
||||
<div className="table-wrap">
|
||||
<table className="employee-table">
|
||||
<thead>
|
||||
<tr>
|
||||
{['账号名称', '经办人名称(开单人)', '手机号/原登录名', '账号状态', '历史记录', '操作'].map(
|
||||
name => (
|
||||
<th key={name}>{name}</th>
|
||||
),
|
||||
)}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.employees.map(item => (
|
||||
<tr key={item.member} data-employee={item.member}>
|
||||
<td>
|
||||
<strong>{item.label}</strong>
|
||||
<div className="small muted">{item.member === 'owner' ? '店主' : '员工'}</div>
|
||||
</td>
|
||||
<td>{item.operatorName || item.label}</td>
|
||||
<td>
|
||||
{item.loginName}
|
||||
<div className="small muted">{item.passwordSet ? '已设置密码' : '尚未设置密码'}</div>
|
||||
</td>
|
||||
<td>
|
||||
<span className={'badge ' + (item.enabled ? '' : 'warn')}>
|
||||
{item.enabled ? '已启用' : '已停用'}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<p className="small muted employee-delete-reason">{deleteReason(item)}</p>
|
||||
{!!item.businessUsage.length && (
|
||||
<details>
|
||||
<summary className="small">关联记录</summary>
|
||||
<ul className="small">
|
||||
{item.businessUsage.map(i => (
|
||||
<li key={i.source}>
|
||||
{i.label || i.source}:{i.count} 条
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<div className="actions">
|
||||
<LedgerDataTable
|
||||
className="employee-table"
|
||||
columns={[
|
||||
{ title: '账号名称' },
|
||||
{ title: '经办人名称(开单人)' },
|
||||
{ title: '手机号/原登录名' },
|
||||
{ title: '账号状态' },
|
||||
{ title: '历史记录' },
|
||||
{ title: '操作' },
|
||||
]}
|
||||
rows={rows.employees.map(item => ({
|
||||
key: item.member,
|
||||
attributes: { 'data-employee': item.member },
|
||||
cells: [
|
||||
<>
|
||||
<strong>{item.label}</strong>
|
||||
<div className="small muted">{item.member === 'owner' ? '店主' : '员工'}</div>
|
||||
</>,
|
||||
item.operatorName || item.label,
|
||||
<>
|
||||
{item.loginName}
|
||||
<div className="small muted">{item.passwordSet ? '已设置密码' : '尚未设置密码'}</div>
|
||||
</>,
|
||||
<>
|
||||
<span className={'badge ' + (item.enabled ? '' : 'warn')}>
|
||||
{item.enabled ? '已启用' : '已停用'}
|
||||
</span>
|
||||
</>,
|
||||
<>
|
||||
<p className="small muted employee-delete-reason">{deleteReason(item)}</p>
|
||||
{!!item.businessUsage.length && (
|
||||
<details>
|
||||
<summary className="small">关联记录</summary>
|
||||
<ul className="small">
|
||||
{item.businessUsage.map(i => (
|
||||
<li key={i.source}>
|
||||
{i.label || i.source}:{i.count} 条
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</>,
|
||||
<>
|
||||
<div className="actions">
|
||||
<Button
|
||||
action="employee-edit"
|
||||
data-member={item.member}
|
||||
onClick={() => open('update', item)}
|
||||
disabled={guarded}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
{item.canDeactivate ? (
|
||||
<Button
|
||||
action="employee-edit"
|
||||
action="employee-deactivate"
|
||||
className="quiet"
|
||||
data-member={item.member}
|
||||
onClick={() => open('update', item)}
|
||||
disabled={guarded}
|
||||
onClick={() => open('deactivate', item)}
|
||||
>
|
||||
编辑
|
||||
停用
|
||||
</Button>
|
||||
{item.canDeactivate ? (
|
||||
<Button
|
||||
action="employee-deactivate"
|
||||
className="quiet"
|
||||
data-member={item.member}
|
||||
disabled={guarded}
|
||||
onClick={() => open('deactivate', item)}
|
||||
>
|
||||
停用
|
||||
</Button>
|
||||
) : item.member !== 'owner' && !item.enabled ? (
|
||||
<Button
|
||||
action="employee-reactivate"
|
||||
data-member={item.member}
|
||||
disabled={guarded}
|
||||
onClick={() => open('reactivate', item)}
|
||||
>
|
||||
启用
|
||||
</Button>
|
||||
) : null}
|
||||
{item.member !== 'owner' && (
|
||||
<Button
|
||||
action="employee-delete"
|
||||
className="quiet"
|
||||
data-member={item.member}
|
||||
disabled={guarded || !item.canDelete}
|
||||
aria-label={'删除' + item.label}
|
||||
title={deleteReason(item)}
|
||||
onClick={() => open('delete', item)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
) : item.member !== 'owner' && !item.enabled ? (
|
||||
<Button
|
||||
action="employee-reactivate"
|
||||
data-member={item.member}
|
||||
disabled={guarded}
|
||||
onClick={() => open('reactivate', item)}
|
||||
>
|
||||
启用
|
||||
</Button>
|
||||
) : null}
|
||||
{item.member !== 'owner' && (
|
||||
<Button
|
||||
action="employee-delete"
|
||||
className="quiet"
|
||||
data-member={item.member}
|
||||
disabled={guarded || !item.canDelete}
|
||||
aria-label={'删除' + item.label}
|
||||
title={deleteReason(item)}
|
||||
onClick={() => open('delete', item)}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</>,
|
||||
],
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -519,9 +520,9 @@ export const Employees = forwardRef<
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<button type="submit" className="primary" disabled={guarded || stale}>
|
||||
<LedgerButton type="submit" className="primary" disabled={guarded || stale}>
|
||||
{adding ? '添加员工' : '保存修改'}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
@@ -534,7 +535,7 @@ export const Employees = forwardRef<
|
||||
<p className="note">{statusMessage[status]}</p>
|
||||
<form id="employee-status-form" onSubmit={submit} data-stale={stale || undefined}>
|
||||
<label className="check">
|
||||
<input type="checkbox" name="verified" required disabled={guarded || stale} />
|
||||
<LedgerInput type="checkbox" name="verified" required disabled={guarded || stale} />
|
||||
已核对员工,确认{statusName[status]}账号。
|
||||
</label>
|
||||
{actions}
|
||||
@@ -547,13 +548,13 @@ export const Employees = forwardRef<
|
||||
>
|
||||
取消
|
||||
</Button>
|
||||
<button
|
||||
<LedgerButton
|
||||
type="submit"
|
||||
className={status === 'delete' ? 'danger' : 'primary'}
|
||||
disabled={guarded || stale}
|
||||
>
|
||||
确认{statusName[status]}
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useRef, useState, type FormEvent } from 'react';
|
||||
import { type LedgerClient } from '../../lib/api';
|
||||
import { Button, Field } from './controls';
|
||||
import { errorText, readForm, type Printing, type Notice } from './settingsModel';
|
||||
import { LedgerButton, LedgerTable } from '../../components/BusinessControls';
|
||||
|
||||
const metrics = [
|
||||
['rows', '表格最少行数', 3, 12],
|
||||
@@ -100,9 +101,9 @@ export function PrintingPanel({
|
||||
: '当前生效设置;修改后请点击保存。'}
|
||||
</p>
|
||||
</div>
|
||||
<button type="submit" form="print-settings" className="primary" disabled={saving || client.busy}>
|
||||
<LedgerButton type="submit" form="print-settings" className="primary" disabled={saving || client.busy}>
|
||||
保存打印设置
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
<form
|
||||
id="print-settings"
|
||||
@@ -155,7 +156,7 @@ export function PrintingPanel({
|
||||
<p id="print-mini-contact" hidden={!printing.contact}>
|
||||
{printing.contact}
|
||||
</p>
|
||||
<table>
|
||||
<LedgerTable>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>商品名称</td>
|
||||
@@ -173,7 +174,7 @@ export function PrintingPanel({
|
||||
<td></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</LedgerTable>
|
||||
<p>合计金额{'\u3000'}¥1,200.00</p>
|
||||
<p>大写:壹仟贰佰元整</p>
|
||||
<p>注意事项 · 珠宝首饰保养须知</p>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { Employees } from './Employees';
|
||||
import { PrintingPanel } from './Printing';
|
||||
import { ShopForm } from './Shop';
|
||||
import './settings.css';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
export interface SettingsProps {
|
||||
client: LedgerClient;
|
||||
@@ -137,7 +138,7 @@ export function SettingsPage({
|
||||
/>
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button disabled={client.busy}>修改并重新登录</button>
|
||||
<LedgerButton disabled={client.busy}>修改并重新登录</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { LedgerClient } from '../../lib/api';
|
||||
import { Calc, type MemberRow } from '../../shared';
|
||||
import { Choice, Field } from './controls';
|
||||
import { errorText, memberOptions, readForm, type Shop, type Notice } from './settingsModel';
|
||||
import { LedgerButton } from '../../components/BusinessControls';
|
||||
|
||||
function shopValues(shop: Shop, today: string) {
|
||||
const month = today.slice(0, 7);
|
||||
@@ -202,9 +203,9 @@ export function ShopForm({
|
||||
{error}
|
||||
</div>
|
||||
<div className="form-actions">
|
||||
<button className="primary" type="submit" disabled={busy || client.busy || !!client.pending()}>
|
||||
<LedgerButton className="primary" type="submit" disabled={busy || client.busy || !!client.pending()}>
|
||||
保存店铺配置
|
||||
</button>
|
||||
</LedgerButton>
|
||||
</div>
|
||||
</form>
|
||||
</>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useLayoutEffect, useRef } from 'react';
|
||||
import type { ButtonHTMLAttributes, InputHTMLAttributes, ReactNode, SelectHTMLAttributes } from 'react';
|
||||
import { LedgerButton, LedgerDialog, LedgerInput, LedgerSelect } from '../../components/BusinessControls';
|
||||
export function Field({ label, ...props }: InputHTMLAttributes<HTMLInputElement> & { label: string }) {
|
||||
return (
|
||||
<label>
|
||||
{label}
|
||||
<input type="text" {...props} />
|
||||
<LedgerInput type="text" {...props} />
|
||||
</label>
|
||||
);
|
||||
}
|
||||
@@ -16,18 +16,18 @@ export function Choice({
|
||||
return (
|
||||
<label>
|
||||
{label}
|
||||
<select {...props}>
|
||||
<LedgerSelect {...props}>
|
||||
{options.map(([value, name]) => (
|
||||
<option key={value} value={value}>
|
||||
{name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</LedgerSelect>
|
||||
</label>
|
||||
);
|
||||
}
|
||||
export function Button({ action, ...props }: ButtonHTMLAttributes<HTMLButtonElement> & { action: string }) {
|
||||
return <button type="button" data-action={action} {...props} />;
|
||||
return <LedgerButton type="button" data-action={action} {...props} />;
|
||||
}
|
||||
export function Dialog({
|
||||
id,
|
||||
@@ -40,16 +40,9 @@ export function Dialog({
|
||||
close: () => void;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const ref = useRef<HTMLDialogElement>(null);
|
||||
useLayoutEffect(() => {
|
||||
const node = ref.current!;
|
||||
node.showModal();
|
||||
node.querySelector<HTMLInputElement>('input:not([type=checkbox])')?.focus();
|
||||
return () => node.close();
|
||||
}, []);
|
||||
return (
|
||||
<dialog
|
||||
ref={ref}
|
||||
<LedgerDialog
|
||||
initialFocusSelector="input:not([type=checkbox])"
|
||||
id={id}
|
||||
aria-labelledby={labelledBy}
|
||||
onCancel={event => {
|
||||
@@ -58,6 +51,6 @@ export function Dialog({
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</dialog>
|
||||
</LedgerDialog>
|
||||
);
|
||||
}
|
||||
@@ -3,14 +3,14 @@
|
||||
display: grid;
|
||||
gap: 18px;
|
||||
line-height: 1.55;
|
||||
color: #243d34;
|
||||
color: var(--ink);
|
||||
}
|
||||
.settings-page .panel {
|
||||
min-width: 0;
|
||||
padding: clamp(16px, 2vw, 28px);
|
||||
border: 1px solid #d9e4df;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
background: var(--white);
|
||||
}
|
||||
.settings-page .team-settings {
|
||||
order: 0;
|
||||
@@ -34,7 +34,7 @@
|
||||
.settings-page h1,
|
||||
.settings-page h2,
|
||||
.settings-page h3 {
|
||||
color: #193c2e;
|
||||
color: var(--green);
|
||||
margin: 0 0 8px;
|
||||
}
|
||||
.settings-page h1 {
|
||||
@@ -55,7 +55,7 @@
|
||||
}
|
||||
.settings-page .muted,
|
||||
.settings-page .eyebrow {
|
||||
color: #536b61;
|
||||
color: var(--muted);
|
||||
}
|
||||
.settings-page .eyebrow {
|
||||
font-size: 12px;
|
||||
@@ -63,7 +63,7 @@
|
||||
}
|
||||
.settings-page .note,
|
||||
.settings-page .badge {
|
||||
background: #edf5f0;
|
||||
background: var(--soft);
|
||||
border-radius: 6px;
|
||||
padding: 8px;
|
||||
}
|
||||
@@ -72,11 +72,11 @@
|
||||
white-space: nowrap;
|
||||
}
|
||||
.settings-page .warn {
|
||||
background: #fbf0db;
|
||||
background: var(--internal-bg);
|
||||
}
|
||||
.settings-page .danger-text,
|
||||
.settings-page .error {
|
||||
color: #982f28;
|
||||
color: var(--danger);
|
||||
}
|
||||
.settings-page fieldset {
|
||||
border: 0;
|
||||
@@ -98,7 +98,7 @@
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
min-height: 38px;
|
||||
border: 1px solid #bdcec4;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 6px;
|
||||
padding: 6px 9px;
|
||||
background: white;
|
||||
@@ -107,10 +107,10 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.settings-page input:read-only {
|
||||
background: #f6f8f6;
|
||||
background: var(--soft);
|
||||
}
|
||||
.settings-page button {
|
||||
border: 1px solid #b7c9be;
|
||||
border: 1px solid var(--border-strong);
|
||||
color: inherit;
|
||||
background: white;
|
||||
cursor: pointer;
|
||||
@@ -119,20 +119,20 @@
|
||||
font: inherit;
|
||||
}
|
||||
.settings-page button.primary {
|
||||
background: #23583d;
|
||||
background: var(--green);
|
||||
color: white;
|
||||
border-color: transparent;
|
||||
}
|
||||
.settings-page button.danger {
|
||||
color: #982f28;
|
||||
border-color: #d8a8a0;
|
||||
color: var(--danger);
|
||||
border-color: color-mix(in srgb, var(--danger) 38%, var(--white));
|
||||
}
|
||||
.settings-page button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: default;
|
||||
}
|
||||
.settings-page :is(button, input, select, summary):focus-visible {
|
||||
outline: 2px solid #377951;
|
||||
outline: 2px solid var(--green-hover);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.settings-page .grid,
|
||||
@@ -170,19 +170,19 @@
|
||||
.settings-page th {
|
||||
padding: 8px;
|
||||
text-align: left;
|
||||
border-bottom: 1px solid #dbe5df;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.settings-page th {
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
color: #4c6658;
|
||||
color: var(--muted);
|
||||
}
|
||||
.settings-page .empty {
|
||||
padding: 12px;
|
||||
color: #52685d;
|
||||
color: var(--muted);
|
||||
}
|
||||
.settings-page .shop-cost-manager {
|
||||
border-top: 1px solid #e3e9e3;
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 22px;
|
||||
padding-top: 14px;
|
||||
}
|
||||
@@ -190,13 +190,13 @@
|
||||
max-width: 320px;
|
||||
}
|
||||
.settings-page .paper-mini {
|
||||
background: #fcfaf4;
|
||||
border: 1px solid #d8d2c2;
|
||||
background: var(--white);
|
||||
border: 1px solid var(--border-strong);
|
||||
padding: 16px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.settings-page .paper-mini td {
|
||||
border: 1px solid #ccc6b6;
|
||||
border: 1px solid var(--border-strong);
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-page dialog {
|
||||
@@ -205,13 +205,13 @@
|
||||
overflow: auto;
|
||||
box-sizing: border-box;
|
||||
padding: 24px;
|
||||
border: 1px solid #cbdbd0;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
color: inherit;
|
||||
box-shadow: 0 25px 65px #11281940;
|
||||
box-shadow: 0 25px 65px color-mix(in srgb, var(--ink) 25%, transparent);
|
||||
}
|
||||
.settings-page dialog::backdrop {
|
||||
background: #132a1e66;
|
||||
background: color-mix(in srgb, var(--ink) 40%, transparent);
|
||||
}
|
||||
.settings-page .dialog-close {
|
||||
float: right;
|
||||
@@ -224,15 +224,15 @@
|
||||
z-index: 10;
|
||||
max-width: 90vw;
|
||||
pointer-events: none;
|
||||
background: #ecf4ef;
|
||||
color: #234d33;
|
||||
border: 1px solid #bacfc1;
|
||||
background: var(--soft);
|
||||
color: var(--green);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: 8px;
|
||||
padding: 10px 15px;
|
||||
}
|
||||
.settings-page .settings-notice.error {
|
||||
color: #8f302a;
|
||||
background: #fff4f1;
|
||||
color: var(--danger);
|
||||
background: color-mix(in srgb, var(--danger) 6%, var(--white));
|
||||
}
|
||||
@media (max-width: 850px) {
|
||||
.settings-page .three,
|
||||
|
||||
Reference in new issue
Block a user