将账本业务页面、表单与审批迁移到 React,并加入旧版对照验收
This commit is contained in:
1 parent
f1a4e69f0d
commit
00dd683116
107 files changed
+31755
-191
No files matched your search
@@ -7,10 +7,11 @@ import { modeLabel } from '../lib/format';
|
||||
import { useClientSnapshot } from '../lib/useClient';
|
||||
import type { LedgerState, SessionInfo } from '../shared';
|
||||
import { BrandMark } from './BrandMark';
|
||||
import { navigate, pathFor, sectionFor, type Route, type Section } from '../lib/router';
|
||||
|
||||
// 与旧界面左侧导航相同的分区与编号。旧界面没有可直接定位到某个分区的地址,其余分区统一打开旧版首页(/)。
|
||||
// 分区编号和角色入口与旧版一致。
|
||||
interface NavItem {
|
||||
key: string;
|
||||
key: Section;
|
||||
no?: string;
|
||||
label: string;
|
||||
}
|
||||
@@ -26,42 +27,40 @@ function navItems(role: string): NavItem[] {
|
||||
{ key: 'report', no: '07', label: '每日对账' },
|
||||
...(owner
|
||||
? [
|
||||
{ key: 'team-funds', no: '08', label: '团队账目' },
|
||||
{ key: 'private-operations', no: '09', label: '私域运营概况' },
|
||||
{ key: 'team-funds' as const, no: '08', label: '团队账目' },
|
||||
{ key: 'private-operations' as const, no: '09', label: '私域运营概况' },
|
||||
]
|
||||
: [{ key: 'people-entry', label: '登记人数' }]),
|
||||
: [{ key: 'people-entry' as const, label: '登记人数' }]),
|
||||
{ key: 'settings', no: '10', label: owner ? '店铺与打印设置' : '修改密码' },
|
||||
];
|
||||
}
|
||||
|
||||
function SideNav({ role, onNavigate }: { role: string; onNavigate?: () => void }) {
|
||||
function SideNav({ role, route, onNavigate }: { role: string; route: Route; onNavigate?: () => void }) {
|
||||
return (
|
||||
<nav className="side-nav" aria-label="主要功能">
|
||||
<ul>
|
||||
{navItems(role).map(item =>
|
||||
item.key === 'create' ? (
|
||||
{navItems(role).map(item => {
|
||||
const active = item.key === sectionFor(route);
|
||||
return (
|
||||
<li key={item.key}>
|
||||
<a className="nav-link active" href="/next/" aria-current="page" onClick={onNavigate}>
|
||||
<span className="nav-no">{item.no}</span>
|
||||
<span className="nav-label">{item.label}</span>
|
||||
</a>
|
||||
</li>
|
||||
) : (
|
||||
<li key={item.key}>
|
||||
<a className="nav-link" href="/" title={'在旧版界面打开「' + item.label + '」'}>
|
||||
<a
|
||||
className={'nav-link' + (active ? ' active' : '')}
|
||||
href={pathFor(item.key)}
|
||||
data-tab={item.key}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
onClick={event => {
|
||||
if (event.button || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
||||
event.preventDefault();
|
||||
if (navigate(item.key)) onNavigate?.();
|
||||
}}
|
||||
>
|
||||
<span className="nav-no">{item.no || '··'}</span>
|
||||
<span className="nav-label">{item.label}</span>
|
||||
<span className="nav-old">旧版</span>
|
||||
</a>
|
||||
</li>
|
||||
),
|
||||
)}
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<p className="nav-foot">
|
||||
新版界面目前只有开单;
|
||||
<br />
|
||||
其他分区在旧版界面中打开。
|
||||
</p>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -71,13 +70,17 @@ export function AppShell({
|
||||
state,
|
||||
session,
|
||||
onLoggedOut,
|
||||
canLeave,
|
||||
route,
|
||||
children,
|
||||
}: {
|
||||
client: LedgerClient;
|
||||
state: LedgerState;
|
||||
session: SessionInfo;
|
||||
onLoggedOut: () => void;
|
||||
canLeave: () => boolean;
|
||||
children: ReactNode;
|
||||
route: Route;
|
||||
}) {
|
||||
const { message } = AntApp.useApp();
|
||||
const [leaving, setLeaving] = useState(false);
|
||||
@@ -86,6 +89,7 @@ export function AppShell({
|
||||
const name = shopName(state, session);
|
||||
const who = state.user.label || state.user.name;
|
||||
async function leave() {
|
||||
if (!canLeave()) return;
|
||||
setLeaving(true);
|
||||
try {
|
||||
await logout(client);
|
||||
@@ -140,7 +144,7 @@ export function AppShell({
|
||||
</header>
|
||||
<div className="app-body">
|
||||
<aside className="app-sider">
|
||||
<SideNav role={state.user.role} />
|
||||
<SideNav role={state.user.role} route={route} />
|
||||
</aside>
|
||||
<Drawer
|
||||
className="nav-drawer"
|
||||
@@ -175,7 +179,7 @@ export function AppShell({
|
||||
退出
|
||||
</Button>
|
||||
</div>
|
||||
<SideNav role={state.user.role} onNavigate={() => setMenuOpen(false)} />
|
||||
<SideNav role={state.user.role} route={route} onNavigate={() => setMenuOpen(false)} />
|
||||
<div className="drawer-meta">
|
||||
<Tag bordered={false}>{modeLabel(state.mode)}</Tag>
|
||||
<a href="/">返回旧版界面</a>
|
||||
|
||||
Reference in new issue
Block a user