第6项:统一业务控件、主题与移动布局,保留原生输入和焦点契约
This commit is contained in:
1 parent
ff8b05973a
commit
c6ad648d7e
74 files changed
+3564
-2443
No files matched your search
@@ -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