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