第6项:统一业务控件、主题与移动布局,保留原生输入和焦点契约
This commit is contained in:
1 parent
ff8b05973a
commit
f30905b236
74 files changed
+3567
-2443
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 ? (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user