第6项:统一业务控件、主题与移动布局,保留原生输入和焦点契约
This commit is contained in:
1 parent
ff8b05973a
commit
2a4fb47227
77 files changed
+3609
-2451
No files matched your search
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user