首页改为财务驾驶舱骨架,并加入常用网址入口

- 首页不再展示业务目录:改为财务驾驶舱(本月收入/支出/毛利/毛利率/应收/应付 + 趋势 + 风险预警位置),指标待接入
- 侧边栏常用网址:新增聚水潭,搜索框右侧书签入口展示
- 更新首页相关测试
This commit is contained in:
renshen 2026-10-19 14:15:27 +08:00
parent 9b2edfe1de
commit 664fc05faf
4 changed files with 108 additions and 183 deletions

View File

@ -9,4 +9,5 @@
*/
return [
['title' => '聚水潭', 'url' => 'https://w.erp321.com/login.aspx'],
];

View File

@ -1,9 +1,16 @@
@php
$pageTotal = collect($sections)->sum(static fn (array $section): int => count($section['pages']));
$kpis = [
['key' => 'income', 'label' => '本月收入'],
['key' => 'expense', 'label' => '本月支出'],
['key' => 'gross_profit', 'label' => '本月毛利'],
['key' => 'gross_margin', 'label' => '毛利率'],
['key' => 'receivable', 'label' => '应收余额'],
['key' => 'payable', 'label' => '应付余额'],
];
@endphp
<x-layouts.admin>
<x-slot name="title">首页</x-slot>
<x-slot name="title">财务驾驶舱</x-slot>
<x-slot name="content">
<style>
@ -14,40 +21,80 @@
margin-right: 1.5rem;
}
.home-nav {
.cockpit {
display: grid;
gap: 1.25rem;
margin: 1.5rem 0 2rem;
gap: 1rem;
margin: 1rem 0 2rem;
font-size: 0.8125rem;
line-height: 1.5;
color: var(--vip-content-ink, #171717);
}
.home-nav__hello {
.cockpit__head {
display: grid;
gap: 0.25rem;
padding: 0.25rem 0 0.5rem;
}
.home-nav__hello-title {
font-size: 0.875rem;
.cockpit__eyebrow {
color: var(--vip-content-accent-dark, #856632);
font-size: 0.6875rem;
font-weight: 600;
line-height: 1.25;
letter-spacing: 0.32em;
}
.home-nav__hello-hint {
.cockpit__title {
font-size: 1.125rem;
font-weight: 600;
line-height: 1.3;
}
.cockpit__hint {
color: var(--vip-content-muted, #595959);
font-size: 0.75rem;
}
.home-nav__grid {
.cockpit__kpis {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
gap: 0.75rem;
grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}
.home-nav__group {
.cockpit__kpi {
display: grid;
gap: 0.5rem;
gap: 0.375rem;
padding: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 0.75rem;
background: var(--vip-surface, #fff);
}
.cockpit__kpi-label {
color: var(--vip-content-muted, #595959);
font-size: 0.75rem;
}
.cockpit__kpi-value {
font-size: 1.5rem;
font-weight: 600;
line-height: 1.2;
font-variant-numeric: tabular-nums;
}
.cockpit__kpi-note {
color: var(--vip-content-muted, #595959);
font-size: 0.6875rem;
}
.cockpit__grid {
display: grid;
gap: 1rem;
grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
}
.cockpit__panel {
display: grid;
gap: 0.75rem;
align-content: start;
padding: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
@ -55,191 +102,70 @@
background: var(--vip-surface, #fff);
}
.home-nav__group-title {
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--vip-border, #D8D2C7);
color: var(--vip-content-muted, #595959);
font-size: 0.75rem;
font-weight: 600;
line-height: 1.333;
}
.home-nav__links {
display: grid;
gap: 0.125rem;
margin: 0;
padding: 0;
list-style: none;
}
.home-nav__link {
display: flex;
align-items: center;
gap: 0.625rem;
min-height: 2rem;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
color: var(--vip-content-ink, #171717);
text-decoration: none;
}
.home-nav__link .material-icons-outlined {
width: 1.125rem;
flex: 0 0 1.125rem;
color: var(--vip-content-accent-dark, #856632);
font-size: 1.125rem;
text-align: center;
}
.home-nav__link:hover {
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-accent-dark, #856632);
}
.home-nav__link:focus-visible {
outline: 2px solid var(--vip-content-accent-dark, #856632);
outline-offset: 2px;
}
.home-nav__all {
display: grid;
gap: 0.875rem;
padding: 1rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 0.75rem;
background: var(--vip-surface, #fff);
}
.home-nav__all-title {
display: flex;
align-items: baseline;
gap: 0.5rem;
color: var(--vip-content-muted, #595959);
font-size: 0.75rem;
font-weight: 600;
}
.home-nav__all-count {
color: var(--vip-content-muted, #595959);
font-size: 0.6875rem;
font-weight: 400;
}
.home-nav__section {
padding-top: 0.75rem;
border-top: 1px solid var(--vip-border, #D8D2C7);
}
.home-nav__section:first-of-type {
padding-top: 0;
border-top: 0;
}
.home-nav__section-title {
.cockpit__panel-title {
display: flex;
align-items: center;
gap: 0.375rem;
color: var(--vip-content-ink, #171717);
font-size: 0.75rem;
font-weight: 600;
cursor: pointer;
list-style: none;
}
.home-nav__section-title::-webkit-details-marker {
display: none;
}
.home-nav__section-title .material-icons-outlined {
.cockpit__panel-title .material-icons-outlined {
color: var(--vip-content-accent-dark, #856632);
font-size: 1rem;
}
.home-nav__section-title .home-nav__section-toggle {
margin-left: auto;
color: var(--vip-content-muted, #595959);
font-size: 0.6875rem;
font-weight: 400;
}
.home-nav__section[open] .home-nav__section-title {
color: var(--vip-content-accent-dark, #856632);
}
.home-nav__chips {
display: flex;
flex-wrap: wrap;
gap: 0.375rem;
margin-top: 0.5rem;
}
.home-nav__chip {
padding: 0.25rem 0.625rem;
border: 1px solid var(--vip-border, #D8D2C7);
border-radius: 999px;
.cockpit__placeholder {
display: grid;
place-items: center;
min-height: 11rem;
border: 1px dashed var(--vip-border, #D8D2C7);
border-radius: 0.5rem;
color: var(--vip-content-muted, #595959);
font-size: 0.75rem;
text-decoration: none;
text-align: center;
}
.home-nav__chip:hover {
border-color: var(--vip-content-accent, #B9954F);
background: var(--vip-content-accent-soft, #F7F0DE);
color: var(--vip-content-accent-dark, #856632);
}
.home-nav__chip:focus-visible {
outline: 2px solid var(--vip-content-accent-dark, #856632);
outline-offset: 2px;
@media (max-width: 1100px) {
.cockpit__grid {
grid-template-columns: minmax(0, 1fr);
}
}
</style>
<div class="home-nav" data-home-nav>
<div class="home-nav__hello">
<p class="home-nav__hello-title">{{ user()->name }},欢迎回来</p>
<p class="home-nav__hello-hint">从下面的模块进入要处理的页面,也可以直接用左侧菜单搜索。</p>
</div>
<div class="cockpit" data-cockpit>
<header class="cockpit__head">
<p class="cockpit__eyebrow">FINANCE COCKPIT</p>
<h1 class="cockpit__title">财务驾驶舱</h1>
<p class="cockpit__hint">指标口径和数据源待确认,下面先留出位置;确认后接入真实数据。</p>
</header>
<div class="home-nav__grid">
@foreach ($groups as $group)
<section class="home-nav__group" aria-label="{{ $group['title'] }}">
<h2 class="home-nav__group-title">{{ $group['title'] }}</h2>
<ul class="home-nav__links">
@foreach ($group['items'] as $item)
<li>
<a class="home-nav__link" href="{{ route('business.pages.show', ['section' => $item['section'], 'page' => $item['page']]) }}">
<span class="material-icons-outlined" aria-hidden="true">{{ $item['icon'] }}</span>
<span>{{ $item['title'] }}</span>
</a>
</li>
@endforeach
</ul>
<div class="cockpit__kpis">
@foreach ($kpis as $kpi)
<section class="cockpit__kpi" data-cockpit-kpi="{{ $kpi['key'] }}">
<span class="cockpit__kpi-label">{{ $kpi['label'] }}</span>
<span class="cockpit__kpi-value">—</span>
<span class="cockpit__kpi-note">待接入</span>
</section>
@endforeach
</div>
@if ($sections !== [])
<section class="home-nav__all" aria-label="全部业务模块">
<h2 class="home-nav__all-title">
全部业务模块
<span class="home-nav__all-count">{{ count($sections) }} 个模块 · {{ $pageTotal }} 个页面</span>
<div class="cockpit__grid">
<section class="cockpit__panel" aria-label="趋势">
<h2 class="cockpit__panel-title">
<span class="material-icons-outlined" aria-hidden="true">show_chart</span>
近 12 个月收入 / 支出
</h2>
@foreach ($sections as $section)
<details class="home-nav__section">
<summary class="home-nav__section-title">
<span class="material-icons-outlined" aria-hidden="true">{{ $section['icon'] }}</span>
<span>{{ $section['title'] }}</span>
<span class="home-nav__section-toggle">{{ count($section['pages']) }} 个页面</span>
</summary>
<div class="home-nav__chips">
@foreach ($section['pages'] as $sectionPage)
<a class="home-nav__chip" href="{{ route('business.pages.show', ['section' => $section['slug'], 'page' => $sectionPage['slug']]) }}">{{ $sectionPage['title'] }}</a>
@endforeach
</div>
</details>
@endforeach
<div class="cockpit__placeholder">图表位置(接入数据后显示趋势)</div>
</section>
@endif
<section class="cockpit__panel" aria-label="风险预警">
<h2 class="cockpit__panel-title">
<span class="material-icons-outlined" aria-hidden="true">notification_important</span>
风险预警
</h2>
<div class="cockpit__placeholder">预警位置(接入数据后显示待处理事项)</div>
</section>
</div>
</div>
</x-slot>
</x-layouts.admin>

View File

@ -131,7 +131,7 @@ class DingTalkLoginTest extends FeatureTestCase
]);
$this->get(route('dashboard', ['company_id' => $this->company->id]))
->assertOk()
->assertSee('data-home-nav', false);
->assertSee('data-cockpit', false);
}
public function test_limited_login_gets_only_three_courier_pages_and_blocks_direct_urls(): void
@ -569,8 +569,7 @@ class DingTalkLoginTest extends FeatureTestCase
$this->actingAs($created)->withSession(['dingtalk_identity_id' => $created->dingtalkIdentity->id, 'dingtalk_roster_checked_at' => now()->timestamp])
->get(route('dashboard'))
->assertOk()
->assertSee('data-home-nav', false)
->assertSeeText('店铺基础信息');
->assertSee('data-cockpit', false);
$this->withExceptionHandling()->get(route('business.pages.show', [
'company_id' => $this->company->id, 'section' => 'company-management', 'page' => 'basic-information',
]))->assertForbidden();

View File

@ -19,15 +19,14 @@ use Tests\Feature\FeatureTestCase;
class PagesTest extends FeatureTestCase
{
public function testDashboardShowsHomeNavigationInsteadOfOpeningTheFirstBusinessPage(): void
public function testDashboardShowsFinanceCockpitInsteadOfOpeningTheFirstBusinessPage(): void
{
$this->loginAs()
->get(route('dashboard', ['company_id' => company_id()]))
->assertOk()
->assertSee('data-home-nav', false)
->assertSeeText('全部业务模块')
->assertSee(route('business.pages.show', ['section' => 'courier-payables', 'page' => 'quote-management']), false)
->assertSee(route('business.pages.show', ['section' => 'company-management', 'page' => 'subject-operating-report']), false);
->assertSee('data-cockpit', false)
->assertSeeText('财务驾驶舱')
->assertSee('data-cockpit-kpi="income"', false);
}
public function testInventoryReportProvidesAFilteredExportButton(): void