CaiWuXiTong/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue

1992 lines
68 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<main class="balance-trend" :aria-busy="busy ? 'true' : 'false'">
<header class="trend-head">
<div class="trend-title-block">
<p class="trend-eyebrow">资金核对</p>
<h2>账户余额总览</h2>
<p class="trend-subtitle">8 个平台账户 · {{ queryPeriodLabel }} · 单位:万元</p>
<p class="trend-platform-note">
聚合 8 个收款平台(淘系支付宝账户、淘系微信账户、拼多多账户、京东网银钱包账户、抖音账户、唯品会MP账户、唯品会JX账户、小红书账户)在选定发生时间范围内的期初、收入与支出(单位:万元)
</p>
</div>
<div class="trend-controls">
<form class="trend-date-filter" aria-label="按发生时间筛选" @submit.prevent="applyTimeRange">
<span class="trend-date-label">发生时间</span>
<div class="trend-date-row">
<span class="trend-date-control" @click="openDatePicker('startDate')">
<flat-picker
ref="startDate"
:value="dateRange.start"
:config="startDateConfig"
aria-label="开始日期"
placeholder="开始日期"
@on-change="(_, value) => changeDate('start', value)"
/>
<button
v-if="dateRange.start"
type="button"
class="trend-date-clear"
title="清除开始日期"
aria-label="清除开始日期"
@click.stop="changeDate('start', '')"
>×</button>
<button
type="button"
class="trend-date-picker"
title="选择开始日期"
aria-label="选择开始日期"
@click.stop="openDatePicker('startDate')"
>
<svg class="trend-date-icon" viewBox="0 0 24 24" aria-hidden="true">
<rect x="3" y="5" width="18" height="16" rx="2"></rect>
<path d="M16 3v4M8 3v4M3 10h18"></path>
</svg>
</button>
</span>
<b>至</b>
<span class="trend-date-control" @click="openDatePicker('endDate')">
<flat-picker
ref="endDate"
:value="dateRange.end"
:config="endDateConfig"
aria-label="结束日期"
placeholder="结束日期"
@on-change="(_, value) => changeDate('end', value)"
/>
<button
v-if="dateRange.end"
type="button"
class="trend-date-clear"
title="清除结束日期"
aria-label="清除结束日期"
@click.stop="changeDate('end', '')"
>×</button>
<button
type="button"
class="trend-date-picker"
title="选择结束日期"
aria-label="选择结束日期"
@click.stop="openDatePicker('endDate')"
>
<svg class="trend-date-icon" viewBox="0 0 24 24" aria-hidden="true">
<rect x="3" y="5" width="18" height="16" rx="2"></rect>
<path d="M16 3v4M8 3v4M3 10h18"></path>
</svg>
</button>
</span>
</div>
<button
type="submit"
class="trend-query-button"
:disabled="invalidDateRange || !dateRange.start || !dateRange.end || busy"
>{{ loading ? '查询中…' : '查询' }}</button>
</form>
<div class="trend-horizon" role="group" aria-label="切换趋势时间范围">
<button
v-for="option in horizonOptions"
:key="option.value"
type="button"
:aria-pressed="horizon === option.value ? 'true' : 'false'"
:class="{ 'is-active': horizon === option.value }"
@click="selectHorizon(option.value)"
>{{ option.label }}</button>
</div>
</div>
</header>
<p v-if="invalidDateRange" class="trend-filter-message is-error" role="alert">结束日期不能早于开始日期</p>
<p v-else-if="!dateRange.start || !dateRange.end" class="trend-filter-message is-error" role="alert">请选择完整的开始和结束日期</p>
<p v-else-if="filtersDirty && !busy" class="trend-filter-message" role="status">时间条件已修改,点击查询后生效。</p>
<section class="trend-cards" aria-label="账户余额汇总">
<article v-for="card in cards" :key="card.key" class="trend-card" :class="card.className">
<div class="trend-card-heading">
<span class="trend-card-dot" aria-hidden="true"></span>
<span>{{ card.label }}</span>
</div>
<strong
v-if="!loading && summary.complete"
class="trend-card-value"
:data-summary-key="card.key"
:title="card.title"
>{{ card.value }}</strong>
<strong v-else class="trend-card-value is-muted">{{ loading ? '--' : '—' }}</strong>
<p>{{ card.note }}</p>
</article>
</section>
<section class="trend-status" :class="statusClass" aria-live="polite">
<span v-if="loading">正在汇总各平台账单…</span>
<template v-else-if="error">
<span>{{ error }}</span>
<button type="button" @click="fetchOverview">重新加载</button>
</template>
<template v-else-if="summary.complete">
<span class="trend-status-dot" aria-hidden="true"></span>
<span>{{ summary.available_platform_count }} / {{ summary.platform_count }} 个平台数据齐全,金额已按当前发生时间范围汇总。</span>
</template>
<template v-else>
<span class="trend-status-dot" aria-hidden="true"></span>
<span>
{{ summary.available_platform_count }} / {{ summary.platform_count }} 个平台数据可读取,
为避免金额失真,暂不展示不完整合计。
<template v-if="unavailableNames.length">待补:{{ unavailableNames.join('、') }}</template>
</span>
<button type="button" @click="fetchOverview">重新加载</button>
</template>
</section>
<section class="trend-panel trend-chart-panel" aria-labelledby="trend-chart-title">
<header class="trend-panel-head">
<h3 id="trend-chart-title">期末余额趋势 <span>· {{ horizonLabel }}</span></h3>
<p>鼠标悬停数据点查看当日明细</p>
</header>
<div ref="chartWrap" class="trend-chart-wrap">
<svg
v-if="visibleRows.length"
class="trend-chart"
:viewBox="`0 0 ${chart.width} ${chart.height}`"
role="img"
aria-labelledby="trend-chart-svg-title trend-chart-svg-desc"
>
<title id="trend-chart-svg-title">店铺期末余额趋势</title>
<desc id="trend-chart-svg-desc">
{{ queryPeriodLabel }},当前展示{{ visibleRows.length }}个日期的期末余额,单位为万元。
</desc>
<defs>
<linearGradient id="balance-area-gradient" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stop-color="#3b82f6" stop-opacity="0.26"></stop>
<stop offset="100%" stop-color="#3b82f6" stop-opacity="0.02"></stop>
</linearGradient>
</defs>
<g class="trend-grid" aria-hidden="true">
<line
v-for="tick in chart.yTicks"
:key="`grid-${tick.value}`"
:x1="chart.plotLeft"
:x2="chart.plotRight"
:y1="tick.y"
:y2="tick.y"
></line>
</g>
<g class="trend-axis trend-axis-y" aria-hidden="true">
<text
v-for="tick in chart.yTicks"
:key="`label-${tick.value}`"
:x="chart.plotLeft - 14"
:y="tick.y + 4"
text-anchor="end"
>{{ tick.label }}</text>
</g>
<g class="trend-axis trend-axis-x" aria-hidden="true">
<text
v-for="tick in chart.xTicks"
:key="`x-${tick.index}`"
:x="tick.x"
:y="chart.plotBottom + 30"
text-anchor="middle"
>{{ tick.label }}</text>
</g>
<path class="trend-area" :d="chart.areaPath"></path>
<path class="trend-line" :d="chart.linePath"></path>
<g class="trend-points">
<circle
v-for="point in chart.points"
:key="`mark-${point.row.date}`"
class="trend-point"
:class="{ 'is-active': tooltipIndex === point.index }"
:cx="point.x"
:cy="point.y"
r="3.4"
></circle>
<circle
v-for="point in chart.points"
:key="`hit-${point.row.date}`"
class="trend-point-hit"
:cx="point.x"
:cy="point.y"
r="12"
@mouseenter="showTooltip($event, point.index)"
@mousemove="showTooltip($event, point.index)"
@mouseleave="hideTooltip"
></circle>
</g>
</svg>
<div v-else class="trend-chart-empty" role="status">
{{ dailyLoading ? '正在读取每日余额…' : (dailyError || '暂无可展示的完整余额趋势数据') }}
</div>
<div
v-if="tooltipRow && visibleRows.length"
class="trend-tooltip"
:style="tooltipStyle"
role="tooltip"
>
<strong>{{ tooltipRow.date }}</strong>
<span>期初 <b>{{ plainMoney(tooltipRow.opening) }}</b></span>
<span>收入 <b class="is-income">+{{ plainMoney(tooltipRow.income) }}</b></span>
<span>支出 <b class="is-expense">−{{ plainMoney(tooltipRow.expense) }}</b></span>
<span>期末 <b class="is-balance">{{ plainMoney(tooltipRow.closing) }}</b></span>
</div>
</div>
</section>
<section class="trend-panel trend-table-panel" aria-labelledby="trend-table-title">
<header class="trend-panel-head">
<div>
<h3 id="trend-table-title">每日余额明细</h3>
<p class="trend-table-caption">{{ queryPeriodLabel }} · 单位:万元</p>
</div>
<div class="trend-detail-tabs" role="tablist" aria-label="每日余额明细维度">
<button
v-for="tab in detailTabs"
:key="tab.key"
type="button"
role="tab"
:aria-selected="detailView === tab.key ? 'true' : 'false'"
:class="{ 'is-active': detailView === tab.key }"
@click="selectDetailView(tab.key)"
>{{ tab.label }}</button>
</div>
</header>
<div v-if="dailyError" class="trend-daily-error" role="alert">
<span>{{ dailyError }}</span>
<button type="button" @click="fetchOverview">重新加载</button>
</div>
<template v-else-if="detailView === 'summary'">
<div class="trend-table-scroll">
<table class="trend-table">
<thead>
<tr>
<th scope="col">日期</th>
<th scope="col">期初余额</th>
<th scope="col">收入</th>
<th scope="col">支出</th>
<th scope="col">期末余额</th>
</tr>
</thead>
<tbody>
<tr v-for="row in visibleRows" :key="row.date">
<td>{{ shortDate(row.date) }}</td>
<td class="is-number">{{ plainMoney(row.opening) }}</td>
<td class="is-number is-income">+{{ plainMoney(row.income) }}</td>
<td class="is-number is-expense">−{{ plainMoney(row.expense) }}</td>
<td class="is-number is-closing">{{ plainMoney(row.closing) }}</td>
</tr>
<tr v-if="!visibleRows.length">
<td colspan="5" class="trend-table-empty">
{{ dailyLoading ? '正在读取每日余额…' : '暂无可展示的完整每日余额数据' }}
</td>
</tr>
</tbody>
</table>
</div>
</template>
<template v-else-if="detailView === 'platform'">
<div class="trend-matrix-scroll">
<table class="trend-matrix-table">
<thead>
<tr>
<th scope="col" class="trend-sticky-platform">平台</th>
<th v-for="date in visibleDates" :key="date" scope="col">{{ shortDate(date) }}</th>
</tr>
</thead>
<tbody>
<tr v-for="platform in platformRows" :key="platform.slug">
<th scope="row" class="trend-sticky-platform">{{ platform.name }}</th>
<td v-for="date in visibleDates" :key="`${platform.slug}-${date}`">
<button
type="button"
class="trend-matrix-cell"
:aria-label="`${platform.name} ${date} 期末余额`"
:disabled="!dailyValue(platform, date)"
@click="openDailyDetail('platform', platform, date)"
>{{ dailyCell(platform, date) }}</button>
</td>
</tr>
<tr class="trend-matrix-total">
<th scope="row" class="trend-sticky-platform">合计</th>
<td v-for="date in visibleDates" :key="`total-${date}`">
<button
type="button"
class="trend-matrix-cell is-closing"
:aria-label="`全部平台 ${date} 期末余额`"
:disabled="!dailySummaryValue(date)"
@click="openDailyDetail('summary', { name: '全部平台' }, date)"
>{{ dailySummaryCell(date) }}</button>
</td>
</tr>
<tr v-if="!platforms.length">
<td :colspan="visibleDates.length + 1" class="trend-table-empty">
{{ dailyLoading ? '正在读取平台每日余额…' : '暂无可展示的平台每日余额数据' }}
</td>
</tr>
</tbody>
</table>
</div>
</template>
<template v-else>
<form class="trend-store-filters" @submit.prevent="applyStoreFilters">
<label>
<span>平台</span>
<select v-model="storePlatformFilter" @change="applyStoreFilters">
<option value="">全部平台</option>
<option v-for="platform in platforms" :key="platform.slug" :value="platform.slug">
{{ platform.name }}
</option>
</select>
</label>
<label class="trend-store-search">
<span>店铺</span>
<input v-model.trim="storeKeywordDraft" type="search" placeholder="搜索店铺名称">
</label>
<button type="submit" class="trend-store-query" :disabled="storeLoading">
{{ storeLoading ? '查询中…' : '查询' }}
</button>
<span class="trend-store-count">
共 {{ storePagination.total }} 家店铺
</span>
</form>
<div v-if="storeError" class="trend-daily-error" role="alert">
<span>{{ storeError }}</span>
<button type="button" @click="fetchStoreBalances">重新加载</button>
</div>
<div class="trend-matrix-scroll trend-store-table-scroll">
<table class="trend-matrix-table trend-store-table">
<thead>
<tr>
<th scope="col" class="trend-sticky-platform">平台</th>
<th scope="col" class="trend-sticky-store">店铺</th>
<th v-for="date in visibleDates" :key="`store-${date}`" scope="col">{{ shortDate(date) }}</th>
</tr>
</thead>
<tbody>
<template v-for="group in storeGroups">
<tr :key="`group-${group.slug}`" class="trend-store-group">
<th scope="rowgroup" class="trend-sticky-platform">{{ group.platform }}</th>
<td class="trend-sticky-store">
<button
type="button"
class="trend-group-toggle"
:aria-expanded="isStoreGroupExpanded(group.slug) ? 'true' : 'false'"
@click="toggleStoreGroup(group.slug)"
>
<span>{{ isStoreGroupExpanded(group.slug) ? '▾' : '▸' }}</span>
{{ group.stores.length }} 家店铺
</button>
</td>
<td v-for="date in visibleDates" :key="`group-${group.slug}-${date}`">
<button
type="button"
class="trend-matrix-cell"
:aria-label="`${group.platform} ${date} 店铺合计`"
:disabled="!group.totals[date]"
@click="openDailyDetail('group', group, date)"
>{{ groupCell(group, date) }}</button>
</td>
</tr>
<template v-if="isStoreGroupExpanded(group.slug)">
<tr v-for="store in group.stores" :key="`${store.platform_slug}-${store.store_name}`">
<td class="trend-sticky-platform">{{ store.platform }}</td>
<th scope="row" class="trend-sticky-store trend-store-name">{{ store.store_name }}</th>
<td v-for="date in visibleDates" :key="`${store.platform_slug}-${store.store_name}-${date}`">
<button
type="button"
class="trend-matrix-cell"
:aria-label="`${store.store_name} ${date} 期末余额`"
:disabled="!storeDailyValue(store, date)"
@click="openDailyDetail('store', store, date)"
>{{ storeDailyCell(store, date) }}</button>
</td>
</tr>
</template>
</template>
<tr v-if="!storeGroups.length">
<td :colspan="visibleDates.length + 2" class="trend-table-empty">
{{ storeLoading ? '正在读取店铺每日余额…' : '当前筛选条件下暂无店铺余额数据' }}
</td>
</tr>
</tbody>
</table>
</div>
<div v-if="storePageCount > 1" class="trend-store-pagination" aria-label="店铺分页">
<button type="button" :disabled="storePage <= 1 || storeLoading" @click="changeStorePage(storePage - 1)">上一页</button>
<span>第 {{ storePage }} / {{ storePageCount }} 页</span>
<button type="button" :disabled="storePage >= storePageCount || storeLoading" @click="changeStorePage(storePage + 1)">下一页</button>
</div>
</template>
<div v-if="selectedDailyDetail" class="trend-day-detail" role="status">
<div>
<strong>{{ selectedDailyDetail.title }}</strong>
<span>{{ selectedDailyDetail.date }}</span>
</div>
<dl>
<div><dt>期初</dt><dd>{{ dailyDetailMoney('opening') }}</dd></div>
<div><dt>收入</dt><dd class="is-income">{{ dailyDetailSigned('income') }}</dd></div>
<div><dt>支出</dt><dd class="is-expense">{{ dailyDetailSigned('expense') }}</dd></div>
<div><dt>期末</dt><dd class="is-closing">{{ dailyDetailMoney('closing') }}</dd></div>
</dl>
<button type="button" class="trend-day-detail-close" aria-label="关闭当日明细" @click="closeDailyDetail">×</button>
</div>
</section>
<p class="trend-footnote">{{ dailyNote }}</p>
</main>
</template>
<script>
import flatPicker from 'vue-flatpickr-component';
import { Mandarin } from 'flatpickr/dist/l10n/zh';
import 'flatpickr/dist/flatpickr.css';
const pad = value => String(value).padStart(2, '0');
const roundMoney = value => Math.round((Number(value) || 0) * 100) / 100;
const lastCompleteMonthRange = () => {
const now = new Date();
const year = now.getMonth() === 0 ? now.getFullYear() - 1 : now.getFullYear();
const month = now.getMonth() === 0 ? 12 : now.getMonth();
const lastDay = new Date(year, month, 0).getDate();
return {
start: `${year}-${pad(month)}-01`,
end: `${year}-${pad(month)}-${pad(lastDay)}`,
};
};
const emptySummary = () => ({
opening_balance: null,
income: null,
expense: null,
balance: null,
platform_count: 8,
available_platform_count: 0,
complete: false,
});
const dateConfig = {
dateFormat: 'Y-m-d',
locale: Mandarin,
disableMobile: true,
allowInput: false,
onReady: (_, value, picker) => picker.calendarContainer.classList.add('trend-calendar'),
};
export default {
name: 'StoreReceivingBalanceOverview',
components: { flatPicker },
props: {
apiBase: { type: String, required: true },
},
data() {
const range = lastCompleteMonthRange();
return {
dateRange: { ...range },
queryRange: { ...range },
loading: true,
error: '',
summary: emptySummary(),
platforms: [],
dailyLoading: true,
dailyError: '',
dailyDates: [],
dailySummary: {},
dailyPlatforms: [],
stores: [],
storeLoading: false,
storeError: '',
storeRequestSerial: 0,
dailyNote: '每日余额按账单实际发生日期滚动计算,单位为万元。',
detailView: 'summary',
detailTabs: [
{ key: 'summary', label: '汇总' },
{ key: 'platform', label: '平台' },
{ key: 'store', label: '店铺' },
],
storePlatformFilter: '',
storeKeyword: '',
storeKeywordDraft: '',
storePage: 1,
storePageSize: 30,
storePagination: { page: 1, limit: 30, total: 0, last_page: 1 },
expandedStorePlatforms: {},
selectedDailyDetail: null,
requestSerial: 0,
horizon: 30,
horizonOptions: [
{ value: 7, label: '近 7 天' },
{ value: 30, label: '近 30 天' },
],
tooltipIndex: -1,
tooltipStyle: { left: '0px', top: '0px' },
};
},
computed: {
busy() {
return this.loading || this.dailyLoading;
},
invalidDateRange() {
return Boolean(
this.dateRange.start
&& this.dateRange.end
&& this.dateRange.start > this.dateRange.end,
);
},
filtersDirty() {
return this.dateRange.start !== this.queryRange.start
|| this.dateRange.end !== this.queryRange.end;
},
startDateConfig() {
return { ...dateConfig, maxDate: this.dateRange.end || null };
},
endDateConfig() {
return { ...dateConfig, minDate: this.dateRange.start || null };
},
queryPeriodLabel() {
return `${this.queryRange.start} ~ ${this.queryRange.end}`;
},
horizonLabel() {
return `近 ${this.horizon} 天`;
},
visibleDates() {
if (this.horizon === 7) return this.dailyDates.slice(-7);
return this.dailyDates.length > 31 ? this.dailyDates.slice(-31) : this.dailyDates;
},
storePageCount() {
return Math.max(1, Number(this.storePagination.last_page || 1));
},
storeGroups() {
const groups = new Map();
this.stores.forEach((store) => {
if (!groups.has(store.platform_slug)) {
groups.set(store.platform_slug, {
slug: store.platform_slug,
platform: store.platform,
stores: [],
totals: {},
});
}
const group = groups.get(store.platform_slug);
group.stores.push(store);
});
return Array.from(groups.values()).map((group) => {
const totals = {};
this.visibleDates.forEach((date) => {
const daily = group.stores.map(store => store.daily?.[date] || null);
const available = daily.length > 0
&& daily.every(day => day && day.available && Number.isFinite(Number(day.closing)));
totals[date] = available
? {
date,
opening: roundMoney(daily.reduce((sum, day) => sum + Number(day.opening || 0), 0)),
income: roundMoney(daily.reduce((sum, day) => sum + Number(day.income || 0), 0)),
expense: roundMoney(daily.reduce((sum, day) => sum + Number(day.expense || 0), 0)),
closing: roundMoney(daily.reduce((sum, day) => sum + Number(day.closing || 0), 0)),
available: true,
}
: null;
});
return { ...group, totals };
});
},
statusClass() {
return {
'is-loading': this.loading,
'is-error': Boolean(this.error),
'is-complete': !this.loading && !this.error && this.summary.complete,
'is-incomplete': !this.loading && !this.error && !this.summary.complete,
};
},
unavailableNames() {
return this.platforms
.filter(platform => !platform.available)
.map(platform => platform.name);
},
platformRows() {
const dailyBySlug = new Map(this.dailyPlatforms.map(platform => [platform.slug, platform]));
const basePlatforms = this.platforms.length ? this.platforms : this.dailyPlatforms;
return basePlatforms.map(platform => ({
...platform,
...(dailyBySlug.get(platform.slug) || {}),
}));
},
cards() {
return [
{
key: 'opening_balance',
label: '期初余额合计',
value: this.moneyWan(this.summary.opening_balance),
title: this.yuanTitle(this.summary.opening_balance),
note: '8 个平台期初余额',
className: 'is-opening',
},
{
key: 'income',
label: '收入合计',
value: this.moneyWan(this.summary.income),
title: this.yuanTitle(this.summary.income),
note: '各平台收入总和',
className: 'is-income',
},
{
key: 'expense',
label: '支出合计',
value: this.moneyWan(this.summary.expense),
title: this.yuanTitle(this.summary.expense),
note: '各平台总支出',
className: 'is-expense',
},
{
key: 'balance',
label: '期末余额合计',
value: this.moneyWan(this.summary.balance),
title: this.yuanTitle(this.summary.balance),
note: '期初 + 收入 − 支出',
className: 'is-balance',
},
];
},
fullTrendRows() {
return this.visibleDates.map((date) => {
const row = this.dailySummary[date] || {};
return {
date,
opening: this.valueToCents(row.opening),
income: this.valueToCents(row.income),
expense: this.valueToCents(row.expense),
closing: this.valueToCents(row.closing),
available: Boolean(row.available),
};
});
},
visibleRows() {
return this.fullTrendRows;
},
chart() {
const width = 1400;
const height = 360;
const plotLeft = 72;
const plotRight = 1378;
const plotTop = 26;
const plotBottom = 292;
const rows = this.visibleRows;
if (!rows.length) {
return {
width,
height,
plotLeft,
plotRight,
plotBottom,
points: [],
xTicks: [],
yTicks: [],
linePath: '',
areaPath: '',
};
}
const values = rows
.filter(row => row.available && Number.isFinite(row.closing))
.map(row => row.closing / 1000000);
if (!values.length) {
return {
width,
height,
plotLeft,
plotRight,
plotBottom,
points: [],
xTicks: [],
yTicks: [],
linePath: '',
areaPath: '',
};
}
const rawMin = Math.min(...values);
const rawMax = Math.max(...values);
const spread = Math.max(rawMax - rawMin, Math.abs(rawMax) * 0.08, 1);
const domainMin = Math.max(0, rawMin - spread * 0.18);
const domainMax = rawMax + spread * 0.18;
const plotWidth = plotRight - plotLeft;
const plotHeight = plotBottom - plotTop;
const xForIndex = index => (
rows.length === 1
? plotLeft + plotWidth / 2
: plotLeft + (index * plotWidth) / (rows.length - 1)
);
const yForValue = value => (
plotTop + ((domainMax - value) / (domainMax - domainMin || 1)) * plotHeight
);
const points = rows
.map((row, index) => {
if (!row.available || !Number.isFinite(row.closing)) return null;
return {
row,
index,
x: xForIndex(index),
y: yForValue(row.closing / 1000000),
};
})
.filter(Boolean);
const linePath = points
.map((point, index) => `${index === 0 ? 'M' : 'L'} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`)
.join(' ');
const areaPath = [
`M ${points[0].x.toFixed(2)} ${plotBottom}`,
...points.map(point => `L ${point.x.toFixed(2)} ${point.y.toFixed(2)}`),
`L ${points[points.length - 1].x.toFixed(2)} ${plotBottom}`,
'Z',
].join(' ');
const yTicks = Array.from({ length: 6 }, (_, index) => {
const value = domainMin + ((domainMax - domainMin) * index) / 5;
return {
value: Number(value.toFixed(4)),
y: yForValue(value),
label: value.toLocaleString('zh-CN', {
minimumFractionDigits: 0,
maximumFractionDigits: 0,
}),
};
});
const tickIndexes = rows.length <= 7
? rows.map((_, index) => index)
: rows.reduce((indexes, _, index) => {
if (index % 5 === 0 || index === rows.length - 1) indexes.push(index);
return indexes;
}, []);
const xTicks = tickIndexes.map((index) => ({
index,
x: xForIndex(index),
label: this.shortDate(rows[index].date),
}));
return {
width,
height,
plotLeft,
plotRight,
plotBottom,
points,
xTicks,
yTicks,
linePath,
areaPath,
};
},
tooltipRow() {
return this.visibleRows[this.tooltipIndex] || null;
},
},
watch: {
horizon() {
this.hideTooltip();
this.closeDailyDetail();
},
queryRange: {
deep: true,
handler() {
this.hideTooltip();
this.closeDailyDetail();
},
},
storePageCount(value) {
if (this.storePage > value) this.storePage = value;
},
},
mounted() {
this.fetchOverview();
},
methods: {
async fetchOverview() {
const requestId = ++this.requestSerial;
++this.storeRequestSerial;
this.loading = true;
this.dailyLoading = true;
this.storeLoading = false;
this.error = '';
this.dailyError = '';
this.hideTooltip();
this.closeDailyDetail();
try {
const response = await window.axios.get(`${this.apiBase}/daily-balance`, {
params: {
start: this.queryRange.start,
end: this.queryRange.end,
},
});
if (requestId !== this.requestSerial) return;
const body = response.data || {};
this.summary = { ...emptySummary(), ...(body.summary || {}) };
this.platforms = Array.isArray(body.platforms) ? body.platforms : [];
this.dailyDates = Array.isArray(body.dates) ? body.dates : [];
this.dailySummary = body.daily_summary || {};
this.dailyPlatforms = this.platforms;
this.stores = [];
this.storePage = 1;
const platformSlugs = new Set(this.platforms.map(platform => platform.slug));
if (!this.storePlatformFilter || !platformSlugs.has(this.storePlatformFilter)) {
this.storePlatformFilter = this.platforms[0]?.slug || '';
}
this.dailyNote = body.daily_note
|| '每日余额按账单实际发生日期滚动计算,单位为万元。';
if (this.detailView === 'store') await this.fetchStoreBalances();
} catch (error) {
if (requestId !== this.requestSerial) return;
this.summary = emptySummary();
this.platforms = [];
this.dailyDates = [];
this.dailySummary = {};
this.dailyPlatforms = [];
this.stores = [];
this.storePagination = { page: 1, limit: this.storePageSize, total: 0, last_page: 1 };
this.error = (error.response && error.response.data && error.response.data.message)
|| '账户余额总览暂时无法读取,请稍后重试。';
this.dailyError = this.error;
} finally {
if (requestId === this.requestSerial) {
this.loading = false;
this.dailyLoading = false;
}
}
},
async fetchStoreBalances() {
if (this.detailView !== 'store') return;
const requestId = ++this.storeRequestSerial;
this.storeLoading = true;
this.storeError = '';
this.closeDailyDetail();
try {
const response = await window.axios.get(`${this.apiBase}/daily-balance-stores`, {
params: {
start: this.queryRange.start,
end: this.queryRange.end,
platform: this.storePlatformFilter,
keyword: this.storeKeyword,
page: this.storePage,
limit: this.storePageSize,
},
});
if (requestId !== this.storeRequestSerial) return;
const body = response.data || {};
this.stores = Array.isArray(body.rows) ? body.rows : [];
this.storePagination = {
page: Number(body.pagination?.page || 1),
limit: Number(body.pagination?.limit || this.storePageSize),
total: Number(body.pagination?.total || 0),
last_page: Number(body.pagination?.last_page || 1),
};
this.storePage = this.storePagination.page;
} catch (error) {
if (requestId !== this.storeRequestSerial) return;
this.stores = [];
this.storePagination = { page: 1, limit: this.storePageSize, total: 0, last_page: 1 };
this.storeError = (error.response && error.response.data && error.response.data.message)
|| '店铺每日余额暂时无法读取,请稍后重试。';
} finally {
if (requestId === this.storeRequestSerial) this.storeLoading = false;
}
},
applyTimeRange() {
if (this.invalidDateRange || !this.dateRange.start || !this.dateRange.end) return;
this.queryRange = { ...this.dateRange };
this.fetchOverview();
},
changeDate(field, value) {
const date = value || '';
if (this.dateRange[field] === date) return;
this.dateRange[field] = date;
},
openDatePicker(refName) {
const picker = this.$refs[refName];
if (picker && picker.fp) picker.fp.open();
},
selectHorizon(value) {
if (this.horizon === value) return;
this.horizon = value;
},
selectDetailView(view) {
if (this.detailView === view) return;
this.detailView = view;
this.storePage = 1;
this.closeDailyDetail();
if (view === 'store') this.fetchStoreBalances();
},
applyStoreFilters() {
this.storeKeyword = this.storeKeywordDraft;
this.storePage = 1;
this.fetchStoreBalances();
},
changeStorePage(page) {
const nextPage = Math.min(Math.max(Number(page) || 1, 1), this.storePageCount);
if (nextPage === this.storePage || this.storeLoading) return;
this.storePage = nextPage;
this.fetchStoreBalances();
},
isStoreGroupExpanded(slug) {
return this.expandedStorePlatforms[slug] !== false;
},
toggleStoreGroup(slug) {
this.expandedStorePlatforms = {
...this.expandedStorePlatforms,
[slug]: !this.isStoreGroupExpanded(slug),
};
},
valueToCents(value) {
if (value === null || value === undefined || value === '') return null;
const number = Number(value);
return Number.isFinite(number) ? Math.round(number * 100) : null;
},
dailyValue(item, date) {
const row = item && item.daily ? item.daily[date] : null;
return row && row.available && Number.isFinite(Number(row.closing)) ? row : null;
},
dailyCell(item, date) {
const row = this.dailyValue(item, date);
return row ? this.plainMoney(this.valueToCents(row.closing)) : '—';
},
dailySummaryValue(date) {
const row = this.dailySummary[date];
return row && row.available && Number.isFinite(Number(row.closing)) ? row : null;
},
dailySummaryCell(date) {
const row = this.dailySummaryValue(date);
return row ? this.plainMoney(this.valueToCents(row.closing)) : '—';
},
storeDailyValue(store, date) {
return this.dailyValue(store, date);
},
storeDailyCell(store, date) {
return this.dailyCell(store, date);
},
groupCell(group, date) {
const row = group.totals[date];
return row ? this.plainMoney(this.valueToCents(row.closing)) : '—';
},
openDailyDetail(kind, item, date) {
const values = kind === 'summary'
? this.dailySummaryValue(date)
: kind === 'group'
? item.totals[date]
: this.dailyValue(item, date);
if (!values) return;
this.selectedDailyDetail = {
date,
title: kind === 'store'
? `${item.platform} · ${item.store_name}`
: kind === 'platform' || kind === 'group'
? item.name || item.platform
: '全部平台',
values,
};
},
closeDailyDetail() {
this.selectedDailyDetail = null;
},
dailyDetailMoney(key) {
const value = this.selectedDailyDetail?.values?.[key];
return value !== null
&& value !== undefined
&& value !== ''
&& Number.isFinite(Number(value))
? this.plainMoney(this.valueToCents(value))
: '—';
},
dailyDetailSigned(key) {
const value = this.selectedDailyDetail?.values?.[key];
if (value === null || value === undefined || value === '' || !Number.isFinite(Number(value))) return '—';
const sign = key === 'expense' ? '−' : '+';
return `${sign}${this.plainMoney(this.valueToCents(value))}`;
},
showTooltip(event, index) {
const host = this.$refs.chartWrap;
if (!host) return;
const rect = host.getBoundingClientRect();
const tooltipWidth = 214;
const tooltipHeight = 154;
let left = event.clientX - rect.left + 14;
let top = event.clientY - rect.top - 26;
if (left + tooltipWidth > rect.width - 8) left = event.clientX - rect.left - tooltipWidth - 14;
if (top + tooltipHeight > rect.height - 8) top = rect.height - tooltipHeight - 8;
this.tooltipIndex = index;
this.tooltipStyle = {
left: `${Math.max(8, left)}px`,
top: `${Math.max(8, top)}px`,
};
},
hideTooltip() {
this.tooltipIndex = -1;
},
shortDate(value) {
return String(value || '').slice(5).replace('-', '/');
},
plainMoney(cents) {
const value = Number(cents);
if (!Number.isFinite(value)) return '—';
return (value / 1000000).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
},
money(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
return `¥${Number(value).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}`;
},
moneyWan(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
return `¥${(Number(value) / 10000).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
})}万`;
},
yuanTitle(value) {
const amount = this.money(value);
return amount === '—' ? '' : `原值:${amount}`;
},
},
};
</script>
<style scoped>
.balance-trend {
--trend-ink: #1f2937;
--trend-muted: #6b7280;
--trend-line: #e2e8f0;
--trend-surface: #ffffff;
--trend-blue: #2563eb;
--trend-blue-soft: #eff6ff;
--trend-green: #16a34a;
--trend-red: #dc2626;
width: min(100%, 1920px);
margin: 0 auto;
padding: 1.25rem 1.15rem 2rem;
color: var(--trend-ink);
font-family: "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace;
}
.trend-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1.5rem;
}
.trend-title-block {
min-width: 0;
}
.trend-eyebrow {
margin: 0 0 .3rem;
color: #856632;
font-size: .6875rem;
font-weight: 700;
letter-spacing: .12em;
}
.trend-title-block h2 {
margin: 0;
font-size: 1.5rem;
font-weight: 700;
letter-spacing: -.035em;
line-height: 1.25;
}
.trend-subtitle {
margin: .35rem 0 0;
color: var(--trend-muted);
font-size: .8125rem;
line-height: 1.55;
}
.trend-platform-note {
max-width: 44rem;
margin: .35rem 0 0;
color: #7b8492;
font-size: .6875rem;
line-height: 1.65;
}
.trend-controls {
display: flex;
flex: 0 0 auto;
flex-direction: column;
align-items: flex-end;
gap: .65rem;
}
.trend-horizon {
display: inline-flex;
gap: .25rem;
padding: .25rem;
border-radius: .65rem;
background: #f1f5f9;
}
.trend-horizon button {
min-width: 4.6rem;
height: 2rem;
padding: 0 .8rem;
border: 0;
border-radius: .5rem;
background: transparent;
color: #6b7280;
font: 600 .75rem/1 inherit;
cursor: pointer;
transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.trend-horizon button:hover {
color: #334155;
}
.trend-horizon button.is-active {
background: #fff;
color: var(--trend-blue);
box-shadow: 0 1px 5px rgba(15, 23, 42, .12);
}
.trend-horizon button:focus-visible,
.trend-query-button:focus-visible,
.trend-date-control:focus-within {
outline: 2px solid rgba(37, 99, 235, .38);
outline-offset: 2px;
}
.trend-date-filter {
display: flex;
align-items: center;
gap: .55rem;
padding: .4rem .45rem .4rem .75rem;
border: 1px solid var(--trend-line);
border-radius: .65rem;
background: rgba(255, 255, 255, .92);
}
.trend-date-label {
color: var(--trend-muted);
font-size: .6875rem;
font-weight: 600;
white-space: nowrap;
}
.trend-date-row {
display: flex;
align-items: center;
gap: .4rem;
}
.trend-date-row b {
color: var(--trend-muted);
font-size: .6875rem;
font-weight: 400;
}
.trend-date-control {
position: relative;
display: flex;
width: 9rem;
height: 2rem;
align-items: center;
overflow: hidden;
border: 1px solid var(--trend-line);
border-radius: .5rem;
background: #fff;
cursor: pointer;
}
.trend-date-control input {
width: 100%;
height: 100%;
min-width: 0;
padding: 0 3.75rem 0 .7rem;
border: 0;
border-radius: inherit;
background: transparent;
color: var(--trend-ink);
font: 400 .75rem/1 "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace;
font-variant-numeric: tabular-nums;
cursor: pointer;
}
.trend-date-control input:focus {
outline: none;
}
.trend-date-picker,
.trend-date-clear {
position: absolute;
top: 0;
display: inline-flex;
height: 100%;
align-items: center;
justify-content: center;
padding: 0;
border: 0;
background: transparent;
color: #64748b;
cursor: pointer;
}
.trend-date-picker {
right: .5rem;
width: 1.5rem;
}
.trend-date-clear {
right: 1.9rem;
width: 1.25rem;
color: #94a3b8;
font-size: .95rem;
}
.trend-date-icon {
width: 1rem;
height: 1rem;
fill: none;
stroke: currentColor;
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 1.8;
}
.trend-query-button {
height: 2rem;
padding: 0 .85rem;
border: 1px solid #1d4ed8;
border-radius: .5rem;
background: var(--trend-blue);
color: #fff;
font: 600 .75rem/1 inherit;
cursor: pointer;
}
.trend-query-button:hover {
background: #1d4ed8;
}
.trend-query-button:disabled {
cursor: not-allowed;
opacity: .58;
}
.trend-filter-message {
margin: .65rem 0 -.3rem;
color: var(--trend-muted);
font-size: .6875rem;
text-align: right;
}
.trend-filter-message.is-error {
color: var(--trend-red);
}
.trend-cards {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: .9rem;
margin-top: 1rem;
}
.trend-card {
min-width: 0;
min-height: 7.3rem;
padding: 1rem 1.15rem .9rem;
border: 1px solid var(--trend-line);
border-radius: .6875rem;
background: var(--trend-surface);
}
.trend-card-heading {
display: flex;
align-items: center;
gap: .45rem;
color: #4b5563;
font-size: .75rem;
font-weight: 600;
}
.trend-card-dot {
width: .4375rem;
height: .4375rem;
flex: 0 0 auto;
border-radius: 50%;
background: #64748b;
}
.trend-card-value {
display: block;
margin-top: .8rem;
font-size: 1.45rem;
font-weight: 700;
line-height: 1.2;
white-space: nowrap;
}
.trend-card-value.is-muted {
color: #94a3b8;
}
.trend-card p {
margin: .55rem 0 0;
color: var(--trend-muted);
font-size: .6875rem;
line-height: 1.45;
}
.trend-card.is-income .trend-card-dot {
background: var(--trend-green);
}
.trend-card.is-income .trend-card-value {
color: var(--trend-green);
}
.trend-card.is-expense .trend-card-dot {
background: var(--trend-red);
}
.trend-card.is-expense .trend-card-value {
color: var(--trend-red);
}
.trend-card.is-balance {
border-color: #93c5fd;
background: linear-gradient(135deg, #f8fbff, var(--trend-blue-soft));
}
.trend-card.is-balance .trend-card-dot {
background: var(--trend-blue);
}
.trend-card.is-balance .trend-card-value {
color: var(--trend-blue);
}
.trend-status {
display: flex;
min-height: 2.25rem;
align-items: center;
flex-wrap: wrap;
gap: .5rem;
margin-top: .7rem;
padding: .45rem .65rem;
border-radius: .5rem;
background: #f8fafc;
color: var(--trend-muted);
font-size: .6875rem;
}
.trend-status.is-complete {
background: #f0fdf4;
color: #3f6f50;
}
.trend-status.is-incomplete,
.trend-status.is-error {
background: #fff7ed;
color: #8a4b16;
}
.trend-status button {
margin-left: auto;
padding: .2rem .5rem;
border: 1px solid currentColor;
border-radius: .35rem;
background: transparent;
color: inherit;
font: inherit;
cursor: pointer;
}
.trend-status-dot {
width: .4rem;
height: .4rem;
flex: 0 0 auto;
border-radius: 50%;
background: currentColor;
}
.trend-panel {
margin-top: .9rem;
border: 1px solid var(--trend-line);
border-radius: .6875rem;
background: var(--trend-surface);
}
.trend-panel-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
padding: 1rem 1.2rem .5rem;
}
.trend-panel-head h3 {
margin: 0;
font-size: .95rem;
font-weight: 700;
}
.trend-panel-head h3 span {
color: #9ca3af;
font-size: .75rem;
font-weight: 400;
}
.trend-panel-head p {
margin: 0;
color: #9ca3af;
font-size: .6875rem;
}
.trend-chart-wrap {
position: relative;
min-height: 20rem;
padding: 0 1rem .5rem;
}
.trend-chart {
display: block;
width: 100%;
height: auto;
min-height: 18.5rem;
overflow: visible;
}
.trend-grid line {
stroke: #edf1f5;
stroke-width: 1;
}
.trend-axis {
fill: #9ca3af;
font-family: "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace;
font-size: 10px;
font-variant-numeric: tabular-nums;
}
.trend-area {
fill: url(#balance-area-gradient);
}
.trend-line {
fill: none;
stroke: var(--trend-blue);
stroke-linecap: round;
stroke-linejoin: round;
stroke-width: 2.5;
}
.trend-point {
fill: #fff;
stroke: var(--trend-blue);
stroke-width: 2;
pointer-events: none;
}
.trend-point-hit {
fill: transparent;
cursor: crosshair;
}
.trend-point.is-active {
r: 4.5;
}
.trend-chart-empty {
display: flex;
min-height: 18.5rem;
align-items: center;
justify-content: center;
color: var(--trend-muted);
font-size: .75rem;
}
.trend-tooltip {
position: absolute;
z-index: 3;
display: grid;
width: 13.25rem;
gap: .28rem;
padding: .65rem .75rem;
border-radius: .45rem;
background: #111827;
color: #f8fafc;
box-shadow: 0 4px 8px rgba(15, 23, 42, .16);
font-size: .6875rem;
font-variant-numeric: tabular-nums;
pointer-events: none;
}
.trend-tooltip strong {
margin-bottom: .12rem;
color: #fff;
font-size: .72rem;
}
.trend-tooltip span {
display: flex;
justify-content: space-between;
gap: 1rem;
color: #cbd5e1;
}
.trend-tooltip b {
color: #f8fafc;
font-weight: 600;
}
.trend-tooltip b.is-income {
color: #4ade80;
}
.trend-tooltip b.is-expense {
color: #f87171;
}
.trend-tooltip b.is-balance {
color: #60a5fa;
}
.trend-table-panel {
overflow: hidden;
}
.trend-table-panel .trend-panel-head {
padding-bottom: .85rem;
border-bottom: 1px solid var(--trend-line);
}
.trend-table-scroll {
max-height: 18.75rem;
overflow: auto;
}
.trend-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
color: #334155;
font-size: .75rem;
}
.trend-table th {
position: sticky;
z-index: 1;
top: 0;
padding: .72rem 1.2rem;
border-bottom: 1px solid var(--trend-line);
background: #fff;
color: var(--trend-muted);
font-size: .6875rem;
font-weight: 600;
text-align: left;
white-space: nowrap;
}
.trend-table th:not(:first-child),
.trend-table td:not(:first-child) {
text-align: right;
}
.trend-table td {
padding: .68rem 1.2rem;
border-bottom: 1px solid #f1f5f9;
white-space: nowrap;
}
.trend-table tbody tr:last-child td {
border-bottom: 0;
}
.trend-table tbody tr:hover td {
background: #f8fafc;
}
.trend-table .is-number {
font-variant-numeric: tabular-nums;
}
.trend-table .is-income {
color: var(--trend-green);
}
.trend-table .is-expense {
color: var(--trend-red);
}
.trend-table .is-closing {
color: #0f172a;
font-weight: 700;
}
.trend-table-empty {
height: 12rem;
color: var(--trend-muted);
text-align: center !important;
}
.trend-table-caption {
margin-top: .25rem !important;
}
.trend-detail-tabs {
display: inline-flex;
flex: 0 0 auto;
gap: .2rem;
padding: .2rem;
border-radius: .5rem;
background: #f1f5f9;
}
.trend-detail-tabs button {
min-width: 3.75rem;
height: 1.9rem;
padding: 0 .65rem;
border: 0;
border-radius: .38rem;
background: transparent;
color: var(--trend-muted);
font: 600 .6875rem/1 inherit;
cursor: pointer;
}
.trend-detail-tabs button.is-active {
background: #fff;
color: #765722;
box-shadow: 0 1px 4px rgba(23, 23, 23, .12);
}
.trend-detail-tabs button:focus-visible,
.trend-matrix-cell:focus-visible,
.trend-group-toggle:focus-visible,
.trend-store-filters select:focus-visible,
.trend-store-filters input:focus-visible,
.trend-store-pagination button:focus-visible,
.trend-day-detail-close:focus-visible {
outline: 2px solid rgba(185, 149, 79, .42);
outline-offset: 2px;
}
.trend-matrix-scroll {
max-height: 26rem;
overflow: auto;
border-top: 1px solid var(--trend-line);
}
.trend-matrix-table {
width: max-content;
min-width: 100%;
border-collapse: separate;
border-spacing: 0;
color: #334155;
font-size: .6875rem;
}
.trend-matrix-table th,
.trend-matrix-table td {
min-width: 4.65rem;
height: 2.55rem;
padding: .45rem .7rem;
border-right: 1px solid #f1f5f9;
border-bottom: 1px solid #f1f5f9;
background: #fff;
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.trend-matrix-table thead th {
position: sticky;
z-index: 2;
top: 0;
background: #faf8f3;
color: #6f6556;
font-weight: 600;
}
.trend-matrix-table tbody tr:hover > * {
background: #fcfaf5;
}
.trend-matrix-table .trend-sticky-platform,
.trend-matrix-table .trend-sticky-store {
position: sticky;
left: 0;
z-index: 3;
text-align: left;
background: #fff;
}
.trend-matrix-table .trend-sticky-platform {
width: 8rem;
min-width: 8rem;
}
.trend-matrix-table .trend-sticky-store {
left: 8rem;
width: 14rem;
min-width: 14rem;
}
.trend-matrix-table thead .trend-sticky-platform,
.trend-matrix-table thead .trend-sticky-store {
z-index: 4;
background: #faf8f3;
}
.trend-matrix-table .trend-matrix-total > * {
background: #fbfaf7;
font-weight: 700;
}
.trend-matrix-table .trend-store-group > * {
background: #f8f5ee;
font-weight: 700;
}
.trend-matrix-cell {
width: 100%;
min-height: 1.5rem;
padding: .2rem 0;
border: 0;
background: transparent;
color: inherit;
font: inherit;
font-variant-numeric: tabular-nums;
text-align: right;
cursor: pointer;
}
.trend-matrix-cell:hover {
color: #765722;
}
.trend-matrix-cell:disabled {
color: #a8a29a;
cursor: default;
}
.trend-matrix-cell.is-closing {
color: #171717;
font-weight: 700;
}
.trend-store-filters {
display: flex;
align-items: flex-end;
flex-wrap: wrap;
gap: .65rem;
padding: .75rem 1.2rem;
border-top: 1px solid #eee9df;
background: #fcfbf8;
}
.trend-store-filters label {
display: flex;
min-width: 10rem;
flex-direction: column;
gap: .25rem;
color: var(--trend-muted);
font-size: .6875rem;
}
.trend-store-filters .trend-store-search {
min-width: 14rem;
flex: 1;
}
.trend-store-filters select,
.trend-store-filters input {
width: 100%;
height: 2rem;
padding: 0 .65rem;
border: 1px solid #d8d2c7;
border-radius: .42rem;
background: #fff;
color: var(--trend-ink);
font: 400 .75rem/1 "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace;
}
.trend-store-query {
height: 2rem;
padding: 0 .8rem;
border: 1px solid #8a682f;
border-radius: .42rem;
background: #8a682f;
color: #fff;
font: 600 .75rem/1 inherit;
cursor: pointer;
}
.trend-store-query:disabled {
cursor: wait;
opacity: .58;
}
.trend-store-count {
margin-left: auto;
padding-bottom: .55rem;
color: #8a8173;
font-size: .6875rem;
white-space: nowrap;
}
.trend-group-toggle {
display: inline-flex;
align-items: center;
gap: .35rem;
padding: 0;
border: 0;
background: transparent;
color: #61513a;
font: 700 .6875rem/1 inherit;
cursor: pointer;
}
.trend-store-name {
padding-left: 1.35rem !important;
font-weight: 500;
}
.trend-store-pagination {
display: flex;
align-items: center;
justify-content: flex-end;
gap: .7rem;
padding: .65rem 1.2rem;
border-top: 1px solid #eee9df;
color: var(--trend-muted);
font-size: .6875rem;
}
.trend-store-pagination button,
.trend-daily-error button {
height: 1.9rem;
padding: 0 .7rem;
border: 1px solid #d8d2c7;
border-radius: .38rem;
background: #fff;
color: #55462e;
font: 600 .6875rem/1 inherit;
cursor: pointer;
}
.trend-store-pagination button:disabled {
color: #aaa297;
cursor: default;
}
.trend-daily-error {
display: flex;
align-items: center;
gap: .7rem;
padding: .8rem 1.2rem;
border-top: 1px solid #f0d8c7;
background: #fff8f2;
color: #8a4b16;
font-size: .75rem;
}
.trend-daily-error button {
margin-left: auto;
}
.trend-day-detail {
position: relative;
display: flex;
align-items: center;
gap: 1.2rem;
margin: .75rem 1.2rem 1rem;
padding: .75rem 2rem .75rem .85rem;
border: 1px solid #d9c9a9;
border-radius: .55rem;
background: #fffaf0;
color: #4d4437;
}
.trend-day-detail > div:first-child {
display: flex;
min-width: 12rem;
flex-direction: column;
gap: .2rem;
}
.trend-day-detail strong {
color: #2d2923;
font-size: .75rem;
}
.trend-day-detail span {
color: var(--trend-muted);
font-size: .6875rem;
}
.trend-day-detail dl {
display: grid;
grid-template-columns: repeat(4, minmax(5.5rem, auto));
gap: .9rem;
margin: 0;
}
.trend-day-detail dl div {
display: flex;
flex-direction: column;
gap: .15rem;
}
.trend-day-detail dt {
color: var(--trend-muted);
font-size: .625rem;
}
.trend-day-detail dd {
margin: 0;
color: #241f19;
font-size: .75rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.trend-day-detail dd.is-income {
color: var(--trend-green);
}
.trend-day-detail dd.is-expense {
color: var(--trend-red);
}
.trend-day-detail dd.is-closing {
color: #765722;
}
.trend-day-detail-close {
position: absolute;
top: .45rem;
right: .5rem;
width: 1.5rem;
height: 1.5rem;
padding: 0;
border: 0;
background: transparent;
color: #8b7c63;
font-size: 1rem;
cursor: pointer;
}
.trend-footnote {
margin: 1rem .2rem 0;
color: #9ca3af;
font-size: .6875rem;
line-height: 1.6;
}
@media (max-width: 980px) {
.trend-head {
flex-direction: column;
}
.trend-controls {
width: 100%;
align-items: flex-start;
}
.trend-day-detail {
align-items: flex-start;
flex-direction: column;
gap: .65rem;
}
.trend-day-detail dl {
grid-template-columns: repeat(2, minmax(5.5rem, 1fr));
}
}
@media (max-width: 760px) {
.balance-trend {
padding: .85rem .65rem 1.5rem;
}
.trend-cards {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.trend-date-filter {
width: 100%;
flex-wrap: wrap;
}
.trend-date-row {
flex: 1 1 100%;
order: 3;
}
.trend-date-control {
width: auto;
flex: 1 1 0;
}
.trend-query-button {
margin-left: auto;
}
.trend-panel-head {
align-items: flex-start;
flex-direction: column;
gap: .3rem;
}
.trend-store-count {
width: 100%;
margin-left: 0;
padding-bottom: 0;
}
}
@media (max-width: 520px) {
.trend-cards {
grid-template-columns: 1fr;
}
.trend-horizon {
width: 100%;
}
.trend-horizon button {
flex: 1 1 0;
}
.trend-chart-wrap {
min-height: 16rem;
padding-inline: .35rem;
}
.trend-chart {
min-width: 34rem;
}
.trend-chart-wrap {
overflow-x: auto;
}
.trend-table th,
.trend-table td {
padding-inline: .75rem;
}
}
@media (prefers-reduced-motion: reduce) {
.trend-horizon button {
transition: none;
}
}
</style>
<style>
.trend-calendar {
font-family: "Microsoft YaHei", sans-serif;
border: 1px solid #dbe2ea;
border-radius: 8px;
background: #fff;
}
.trend-calendar .flatpickr-day.selected,
.trend-calendar .flatpickr-day.selected:hover {
border-color: #2563eb;
background: #2563eb;
}
.trend-calendar .flatpickr-day.today {
border-color: #2563eb;
}
.trend-calendar .flatpickr-day:hover,
.trend-calendar .flatpickr-day:focus {
border-color: #dbe2ea;
background: #eff6ff;
}
</style>