CaiWuXiTong/resources/assets/js/components/business/PeriodBalanceReconciliation.vue
qiuxiang 6518018b9f fix: 优化期末余额双源核对页面加载卡顿 (#1323)
分页明细、默认收起核查原因并增加冷查询单飞缓存。
2026-11-20 16:27:14 +08:00

1555 lines
60 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="period-reconciliation" :aria-busy="loading ? 'true' : 'false'">
<header class="reconciliation-head">
<div>
<p class="eyebrow">资金核对</p>
<p>财务系统期末余额与聚水潭店铺余额逐店铺核对,定位差异并记录待核查事项。</p>
</div>
<div class="date-filter">
<label>
<span>开始日期</span>
<flat-picker
ref="startDate"
:value="dateRange.start"
:config="startDateConfig"
aria-label="开始日期"
placeholder="开始日期"
@on-change="(_, value) => changeDate('start', value)"
/>
</label>
<label>
<span>结束日期</span>
<flat-picker
ref="endDate"
:value="dateRange.end"
:config="endDateConfig"
aria-label="结束日期"
placeholder="结束日期"
@on-change="(_, value) => changeDate('end', value)"
/>
</label>
<button type="button" class="primary-button" :disabled="!canQuery || loading" @click="applyTimeRange">
{{ loading ? '查询中…' : '查询' }}
</button>
</div>
</header>
<div class="filter-status">
<div class="filter-state">
<span v-if="dateError" class="filter-error" role="alert">{{ dateError }}</span>
<span v-else-if="filtersDirty" class="filter-dirty" role="status">条件已修改,点击查询后生效</span>
<span class="range-label">当前数据:{{ dataPeriodLabel }}</span>
</div>
</div>
<div class="source-banner">
<strong>聚水潭数据源</strong>
<span>淘系支付宝账户取“店铺余额表”;拼多多账户取“平台资金账户余额”;抖音账户取“头条放心购平台资金账户余额”。其他平台暂未接入,不参与差异判断。</span>
</div>
<div v-if="error" class="state-panel is-error" role="alert">
<span>{{ error }}</span>
<button type="button" @click="fetchReconciliation">重新加载</button>
</div>
<template v-else>
<section class="metric-grid" aria-label="财务系统汇总">
<article v-for="card in metricCards" :key="card.key" class="metric-card" :class="card.className">
<div class="metric-heading">
<span>{{ card.label }}</span>
<i aria-hidden="true"></i>
</div>
<strong>{{ card.value }}</strong>
<p :class="{ 'is-danger': card.danger }">{{ card.note }}</p>
</article>
</section>
<section class="panel chart-panel">
<header class="panel-head">
<div>
<h3>{{ trendTitle }}</h3>
<p>{{ trendSubtitle }}</p>
</div>
<div class="chart-legend">
<span><i class="finance-line"></i>财务系统</span>
<span><i class="jst-line"></i>聚水潭</span>
<span><i class="diff-bar"></i>差异</span>
<button type="button" :disabled="loading || trendLoading" @click="loadTrend">
{{ trendLoading ? '趋势加载中…' : (trendLoaded ? '刷新趋势' : '加载趋势') }}
</button>
<button v-if="selectedKey" type="button" @click="selectedKey = ''">恢复全部趋势</button>
</div>
</header>
<div ref="trendWrap" class="trend-wrap" @mouseleave="hideTooltip">
<div v-if="!trendPoints.length || !trendAvailable" class="chart-empty">
{{ trendEmptyMessage }}
</div>
<svg v-show="trendPoints.length && trendAvailable" ref="trendSvg" class="trend-svg" role="img" :aria-label="trendAriaLabel"></svg>
<div ref="tooltip" class="chart-tooltip" role="tooltip"></div>
</div>
</section>
<section class="verify-grid">
<article class="panel verify-card" :class="equationClass">
<span>① 勾稽校验</span>
<strong>{{ equationComplete ? (equationOk ? '通过' : '不平') : '待取数' }}</strong>
<p>{{ equationText }}</p>
</article>
<article class="panel verify-card" :class="dualSourceClass">
<span>② 双源核对 · 已接入范围</span>
<strong>{{ dualSourceStatus }}</strong>
<p>
财务 {{ moneyWan(dualSource.financial_total) }} · 聚水潭 {{ moneyWan(dualSource.jushuitan_total) }}
· 差异 {{ signedNumberWan(dualSource.difference) }}
</p>
</article>
<article class="panel verify-card" :class="anomalyClass">
<span>③ 待核查店铺</span>
<strong>{{ summary.pending_review_count || 0 }} / {{ summary.store_count || 0 }}</strong>
<ul class="review-status-list" aria-label="待核查状态统计">
<li v-for="item in reviewStatuses" :key="item.label" :class="{ 'is-total': item.total }">
<span>{{ item.label }}</span>
<b>{{ item.count || 0 }} 家</b>
</li>
</ul>
<p>
{{ summary.connected_store_count || 0 }} 家已接入;
{{ summary.unconnected_platform_count || 0 }} 个平台聚水潭暂未接入
</p>
<ul v-if="summary.top_anomalies && summary.top_anomalies.length">
<li v-for="row in summary.top_anomalies.slice(0, 3)" :key="row.key">
{{ row.store_name }} · {{ signedNumberWan(row.difference) }}
</li>
</ul>
<p v-else>当前范围没有待核查店铺。</p>
</article>
</section>
<section class="panel source-panel" aria-label="聚水潭快照状态">
<div v-for="source in report.sources" :key="source.slug" class="source-chip" :class="`is-${source.status}`">
<strong>{{ source.name }}</strong>
<span>{{ source.source_label }}</span>
<small v-if="source.snapshot_date">快照 {{ source.snapshot_date }}</small>
<small v-else>暂无快照</small>
</div>
</section>
<section class="panel reconciliation-panel">
<header class="table-head">
<div>
<h3>明细核对</h3>
<p>点击平台或店铺行切换趋势;再次点击恢复全部。</p>
</div>
<div class="table-actions">
<div class="view-tabs" role="tablist" aria-label="核对维度">
<button type="button" role="tab" :aria-selected="view === 'shop' ? 'true' : 'false'" :class="{ 'is-active': view === 'shop' }" @click="view = 'shop'">按店铺</button>
<button type="button" role="tab" :aria-selected="view === 'platform' ? 'true' : 'false'" :class="{ 'is-active': view === 'platform' }" @click="view = 'platform'">按平台</button>
</div>
<select v-if="view === 'shop'" v-model="platformFilter" aria-label="筛选平台">
<option value="">全部平台</option>
<option v-for="platform in availablePlatforms" :key="platform.slug" :value="platform.slug">{{ platform.name }}</option>
</select>
<button type="button" class="secondary-button" @click="toggleAllReasons">{{ allReasonsExpanded ? '收起全部原因' : '展开全部原因' }}</button>
</div>
</header>
<div class="table-scroll">
<table class="reconciliation-table">
<thead>
<tr>
<th scope="col">平台</th>
<th scope="col">{{ view === 'shop' ? '店铺名称' : '平台汇总' }}</th>
<th scope="col" class="is-number">财务系统期末(万元)</th>
<th scope="col" class="is-number">聚水潭期末(万元)</th>
<th scope="col" class="is-number">差异(万元)</th>
<th scope="col">状态</th>
</tr>
</thead>
<tbody>
<template v-for="row in pagedTableRows">
<tr
:key="rowKey(row)"
:class="rowClass(row)"
@click="selectTrend(row)"
>
<td>{{ row.platform || row.name }}</td>
<td>
<button type="button" class="row-name" @click.stop="selectTrend(row)">
{{ view === 'shop' ? row.store_name : `${row.store_count || countPlatformStores(row.slug)} 家店铺` }}
</button>
<button
v-if="rowHasReasons(row)"
type="button"
class="reason-toggle"
:aria-expanded="isExpanded(row) ? 'true' : 'false'"
@click.stop="toggleReason(row)"
>{{ isExpanded(row) ? '收起原因' : '展开原因' }}</button>
</td>
<td class="is-number">{{ amountWanValue(row.financial_balance) }}</td>
<td class="is-number">{{ amountWanValue(row.jushuitan_balance) }}</td>
<td class="is-number" :class="differenceClass(row.difference)">{{ signedAmountWanValue(row.difference) }}</td>
<td><span class="badge" :class="statusMeta(row.status).className">{{ statusMeta(row.status).label }}</span></td>
</tr>
<tr v-if="rowHasReasons(row) && isExpanded(row)" :key="`${rowKey(row)}-reason`" class="reason-row">
<td colspan="6">
<div class="reason-list">
<article v-for="(reason, index) in rowReasons(row)" :key="`${rowKey(row)}-${index}`">
<div><strong>{{ reason.title }}</strong><em>待核查</em></div>
<p><b>可能原因:</b>{{ reason.reason }}</p>
<p><b>建议核查:</b>{{ reason.action }}</p>
</article>
</div>
</td>
</tr>
</template>
<tr v-if="!tableRows.length">
<td colspan="6" class="empty-cell">当前筛选范围没有店铺余额记录。</td>
</tr>
<tr v-if="tableRows.length" class="total-row">
<td>合计</td>
<td>{{ view === 'shop' ? `${tableRows.length} 家店铺` : '全部平台' }}</td>
<td class="is-number">{{ amountWanValue(filteredTotal.financial) }}</td>
<td class="is-number">{{ amountWanValue(filteredTotal.jst) }}</td>
<td class="is-number" :class="differenceClass(filteredTotal.difference)">{{ signedAmountWanValue(filteredTotal.difference) }}</td>
<td><span class="badge" :class="filteredTotal.className">{{ filteredTotal.label }}</span></td>
</tr>
</tbody>
</table>
</div>
<div v-if="tableRows.length > tablePageSize" class="table-pagination" aria-label="明细分页">
<span>第 {{ tablePageStart }}–{{ tablePageEnd }} 条,共 {{ tableRows.length }} 条</span>
<div>
<button type="button" :disabled="currentPage <= 1" @click="goToTablePage(currentPage - 1)">上一页</button>
<b>{{ currentPage }} / {{ tableRowPages }}</b>
<button type="button" :disabled="currentPage >= tableRowPages" @click="goToTablePage(currentPage + 1)">下一页</button>
</div>
</div>
</section>
<footer class="reconciliation-foot">
<span>容差:±{{ numberWan(report.tolerance_yuan) }}。聚水潭快照落后于所选截止日时标记“取数时间待核查”。</span>
<span>其他平台暂未接入聚水潭,不生成差异结论。</span>
</footer>
</template>
</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 currentMonthRange = () => {
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth() + 1;
const lastDay = new Date(year, month, 0).getDate();
return {
start: `${year}-${pad(month)}-01`,
end: `${year}-${pad(month)}-${pad(lastDay)}`,
};
};
const dateConfig = {
dateFormat: 'Y-m-d',
locale: Mandarin,
disableMobile: true,
allowInput: false,
onReady: (_, value, picker) => picker.calendarContainer.classList.add('reconciliation-calendar'),
};
const emptyReport = () => ({
period: { start: '', end: '' },
tolerance_yuan: 200,
financial: {
summary: {
opening_balance: null,
income: null,
expense: null,
balance: null,
platform_count: 8,
available_platform_count: 0,
complete: false,
},
platforms: [],
},
dual_source: {
status: 'incomplete',
financial_total: null,
jushuitan_total: null,
difference: null,
connected_store_count: 0,
matched_store_count: 0,
missing_store_count: 0,
anomaly_store_count: 0,
stale_store_count: 0,
},
platforms: [],
stores: [],
sources: [],
summary: {
store_count: 0,
connected_store_count: 0,
anomaly_count: 0,
stale_count: 0,
missing_jushuitan_count: 0,
unconnected_platform_count: 5,
top_anomalies: [],
},
trend: { points: [], by_platform: {}, by_store: {}, dates_note: '' },
available_dates: { start: null, end: null },
});
export default {
name: 'PeriodBalanceReconciliation',
components: { flatPicker },
props: {
apiBase: { type: String, required: true },
},
data() {
const range = currentMonthRange();
return {
dateRange: { ...range },
queryRange: { ...range },
report: emptyReport(),
loading: true,
error: '',
trendLoading: false,
trendError: '',
trendLoaded: false,
requestSerial: 0,
view: 'shop',
platformFilter: '',
selectedKey: '',
expanded: {},
currentPage: 1,
tablePageSize: 50,
resizeTimer: null,
};
},
computed: {
dateError() {
if (!this.dateRange.start || !this.dateRange.end) return '请选择完整的开始和结束日期。';
if (this.dateRange.start > this.dateRange.end) return '结束日期不能早于开始日期。';
return '';
},
canQuery() {
return Boolean(this.dateRange.start && this.dateRange.end && !this.dateError);
},
filtersDirty() {
return this.dateRange.start !== this.queryRange.start
|| this.dateRange.end !== this.queryRange.end;
},
dataPeriodLabel() {
const start = this.report.period && this.report.period.start;
const end = this.report.period && this.report.period.end;
if (!start || !end) return this.loading ? '读取中…' : '—';
const startMonth = start.slice(0, 7);
const endMonth = end.slice(0, 7);
const monthLabel = startMonth === endMonth ? startMonth : `${startMonth} 至 ${endMonth}`;
return `${start} 至 ${end}(${monthLabel})`;
},
startDateConfig() {
return { ...dateConfig, maxDate: this.dateRange.end || null };
},
endDateConfig() {
return { ...dateConfig, minDate: this.dateRange.start || null };
},
financialSummary() {
return this.report.financial.summary || emptyReport().financial.summary;
},
metricCards() {
const dual = this.report.dual_source || emptyReport().dual_source;
const danger = Math.abs(Number(dual.difference || 0)) > Number(this.report.tolerance_yuan || 200);
return [
{
key: 'opening',
label: '期初余额合计',
value: this.moneyWan(this.financialSummary.opening_balance),
note: '财务系统口径',
className: '',
},
{
key: 'income',
label: '收入合计',
value: this.moneyWan(this.financialSummary.income),
note: '财务系统口径',
className: 'is-income',
},
{
key: 'expense',
label: '支出合计',
value: this.moneyWan(this.financialSummary.expense),
note: '财务系统口径',
className: 'is-expense',
},
{
key: 'balance',
label: '期末余额合计',
value: this.moneyWan(this.financialSummary.balance),
note: `聚水潭已接入 ${this.numberWan(dual.jushuitan_total)} · 双源差异 ${this.signedNumberWan(dual.difference)}`,
className: 'is-closing',
danger,
},
];
},
equationComplete() {
return [
this.financialSummary.opening_balance,
this.financialSummary.income,
this.financialSummary.expense,
this.financialSummary.balance,
].every((value) => value !== null && value !== undefined && Number.isFinite(Number(value)));
},
equationOk() {
if (!this.equationComplete) return false;
return Math.abs(
Number(this.financialSummary.opening_balance)
+ Number(this.financialSummary.income)
- Number(this.financialSummary.expense)
- Number(this.financialSummary.balance),
) <= 0.005;
},
equationText() {
if (!this.equationComplete) return '财务余额数据不完整,暂不能完成勾稽。';
return `${this.numberWan(this.financialSummary.opening_balance)} + ${this.numberWan(this.financialSummary.income)} − ${this.numberWan(this.financialSummary.expense)} = ${this.numberWan(this.financialSummary.balance)}`;
},
equationClass() {
if (!this.equationComplete) return 'is-warning';
return this.equationOk ? 'is-ok' : 'is-bad';
},
dualSource() {
return this.report.dual_source || emptyReport().dual_source;
},
dualSourceStatus() {
return {
normal: '余额一致',
pending: '存在待核查',
incomplete: '数据未齐全',
}[this.dualSource.status] || '待核查';
},
dualSourceClass() {
return this.dualSource.status === 'normal' ? 'is-ok' : this.dualSource.status === 'incomplete' ? 'is-warning' : 'is-bad';
},
anomalyClass() {
return Number(this.report.summary.review_total_count || 0) > 0 ? 'is-warning' : 'is-ok';
},
summary() {
return this.report.summary || emptyReport().summary;
},
reviewStatuses() {
return [
{ label: '金额异常', count: this.summary.anomaly_count || 0 },
{ label: '取数日期待核查', count: this.summary.stale_count || 0 },
{ label: '聚水潭未匹配', count: this.summary.missing_jushuitan_count || 0 },
{ label: '财务无余额', count: this.summary.financial_missing_count || 0 },
{ label: '待核查合计', count: this.summary.pending_review_count || 0, total: true },
];
},
availablePlatforms() {
const map = new Map();
this.report.stores.forEach((row) => {
if (!map.has(row.platform_slug)) map.set(row.platform_slug, { slug: row.platform_slug, name: row.platform });
});
return Array.from(map.values());
},
tableRows() {
return this.view === 'platform'
? this.report.platforms
: this.report.stores.filter((row) => !this.platformFilter || row.platform_slug === this.platformFilter);
},
tableRowPages() {
return Math.max(1, Math.ceil(this.tableRows.length / this.tablePageSize));
},
pagedTableRows() {
const start = (this.currentPage - 1) * this.tablePageSize;
return this.tableRows.slice(start, start + this.tablePageSize);
},
tablePageStart() {
return this.tableRows.length ? (this.currentPage - 1) * this.tablePageSize + 1 : 0;
},
tablePageEnd() {
return Math.min(this.currentPage * this.tablePageSize, this.tableRows.length);
},
filteredTotal() {
const rows = this.tableRows;
const financial = this.sumFinite(rows, 'financial_balance');
const jst = this.sumFinite(rows, 'jushuitan_balance');
const difference = financial !== null && jst !== null ? this.round2(financial - jst) : null;
const pending = rows.some((row) => ['abnormal', 'stale', 'jst_missing', 'financial_missing', 'pending'].includes(row.status));
const connected = rows.some((row) => row.connected);
return {
financial,
jst,
difference,
label: !connected ? '未接入' : pending ? '存在待核查' : '正常',
className: !connected ? 'is-unavailable' : pending ? 'is-pending' : 'is-normal',
};
},
trendPoints() {
if (!this.selectedKey) return this.report.trend.points || [];
if (this.selectedKey.startsWith('platform:')) {
return this.report.trend.by_platform[this.selectedKey.slice('platform:'.length)] || [];
}
if (this.selectedKey.startsWith('shop:')) {
return this.report.trend.by_store[this.selectedKey.slice('shop:'.length)] || [];
}
return [];
},
trendAvailable() {
return this.trendPoints.some((point) => Number.isFinite(Number(point.financial_balance)));
},
trendTitle() {
if (!this.selectedKey) return '全部合计(已接入范围)';
const row = this.findSelectedRow();
if (!row) return '双源余额趋势';
return this.view === 'platform' ? `${row.name} · 平台趋势` : `${row.store_name} · 店铺趋势`;
},
trendSubtitle() {
if (!this.selectedKey) {
return `${this.summary.connected_store_count || 0} 家已接入店铺 · ${this.report.trend.dates_note || '图表金额单位:万元'}`;
}
const row = this.findSelectedRow();
if (!row) return '图表金额单位:万元';
if (!row.connected) return '该平台聚水潭暂未接入,仅展示财务系统数据';
return `${row.source?.source_label || '聚水潭余额'} · 金额单位:万元`;
},
trendUnavailableMessage() {
return this.selectedKey && !this.findSelectedRow()?.connected
? '聚水潭暂未接入,当前维度无法生成双源趋势。'
: '当前时间范围没有可用的双源趋势快照。';
},
trendEmptyMessage() {
if (this.trendLoading) return '趋势加载中…';
if (this.trendError) return this.trendError;
if (!this.trendLoaded) return '趋势按需加载,不影响上方核对结果。';
return this.trendUnavailableMessage;
},
trendAriaLabel() {
return `${this.trendTitle},财务系统与聚水潭余额趋势及差异`;
},
allReasonsExpanded() {
const rows = this.tableRows.filter((row) => this.rowHasReasons(row));
return rows.length > 0 && rows.every((row) => this.isExpanded(row));
},
},
watch: {
selectedKey() {
this.$nextTick(this.drawTrend);
},
view() {
this.selectedKey = '';
this.platformFilter = '';
this.currentPage = 1;
this.$nextTick(this.drawTrend);
},
platformFilter() {
this.selectedKey = '';
this.currentPage = 1;
this.$nextTick(this.drawTrend);
},
},
mounted() {
this.fetchReconciliation();
window.addEventListener('resize', this.queueChartDraw);
},
beforeDestroy() {
window.removeEventListener('resize', this.queueChartDraw);
clearTimeout(this.resizeTimer);
},
methods: {
openDatePicker(ref) {
if (this.$refs[ref] && this.$refs[ref].fp) this.$refs[ref].fp.open();
},
changeDate(boundary, value) {
this.dateRange[boundary] = value || '';
},
parseDate(value) {
const [year, month, day] = String(value || '').split('-').map(Number);
return new Date(year, Math.max(month - 1, 0), day || 1);
},
formatDate(date) {
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
},
round2(value) {
return Math.round((Number(value) + Number.EPSILON) * 100) / 100;
},
number(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
return Number(value).toLocaleString('zh-CN', {
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
},
numberWan(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
return `${this.number(Number(value) / 10000)} 万`;
},
moneyWan(value) {
return this.numberWan(value);
},
amountWanValue(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
return this.number(Number(value) / 10000);
},
signedAmountWanValue(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
const amount = Number(value);
if (Math.abs(amount) < 0.005) return '0.00';
return `${amount > 0 ? '+' : '−'}${this.number(Math.abs(amount) / 10000)}`;
},
signedNumberWan(value) {
if (value === null || value === undefined || !Number.isFinite(Number(value))) return '—';
const amount = Number(value);
if (Math.abs(amount) < 0.005) return '0.00 万';
return `${amount > 0 ? '+' : '−'}${this.number(Math.abs(amount) / 10000)} 万`;
},
differenceClass(value) {
if (value === null || value === undefined || Math.abs(Number(value)) < 0.005) return 'is-flat';
return Number(value) > 0 ? 'is-up' : 'is-down';
},
statusMeta(status) {
return {
normal: { label: '正常', className: 'is-normal' },
abnormal: { label: '异常', className: 'is-error' },
stale: { label: '取数时间待核查', className: 'is-pending' },
jst_missing: { label: '聚水潭未匹配', className: 'is-pending' },
financial_missing: { label: '财务无余额', className: 'is-pending' },
unavailable: { label: '未接入', className: 'is-unavailable' },
pending: { label: '待核查', className: 'is-pending' },
}[status] || { label: '待核查', className: 'is-pending' };
},
applyTimeRange() {
if (!this.canQuery) return;
this.queryRange = { ...this.dateRange };
this.selectedKey = '';
this.fetchReconciliation();
},
async fetchReconciliation() {
const requestId = ++this.requestSerial;
this.loading = true;
this.error = '';
this.trendLoading = false;
this.trendError = '';
this.trendLoaded = false;
this.report.trend = emptyReport().trend;
try {
const response = await window.axios.get(`${this.apiBase}/reconciliation`, {
params: {
start: this.queryRange.start,
end: this.queryRange.end,
},
});
if (requestId !== this.requestSerial) return;
this.report = {
...emptyReport(),
...(response.data || {}),
financial: {
...emptyReport().financial,
...((response.data && response.data.financial) || {}),
},
dual_source: {
...emptyReport().dual_source,
...((response.data && response.data.dual_source) || {}),
},
summary: {
...emptyReport().summary,
...((response.data && response.data.summary) || {}),
},
trend: {
...emptyReport().trend,
...((response.data && response.data.trend) || {}),
},
};
this.expanded = {};
this.currentPage = 1;
this.$nextTick(this.drawTrend);
} catch (error) {
if (requestId !== this.requestSerial) return;
this.report = emptyReport();
this.error = (error.response && error.response.data && error.response.data.message)
|| '期末余额双源核对数据暂时无法读取,请稍后重试。';
} finally {
if (requestId === this.requestSerial) this.loading = false;
}
},
loadTrend() {
if (this.trendLoading) return;
this.fetchTrend(this.requestSerial);
},
async fetchTrend(requestId) {
if (requestId !== this.requestSerial) return;
this.trendLoading = true;
this.trendError = '';
try {
const response = await window.axios.get(`${this.apiBase}/reconciliation/trend`, {
params: {
start: this.queryRange.start,
end: this.queryRange.end,
},
});
if (requestId !== this.requestSerial) return;
this.report.trend = {
...emptyReport().trend,
...(response.data || {}),
};
this.trendLoaded = true;
this.$nextTick(this.drawTrend);
} catch (error) {
if (requestId !== this.requestSerial) return;
this.trendError = (error.response && error.response.data && error.response.data.message)
|| '趋势暂时无法读取,请稍后重试。';
} finally {
if (requestId === this.requestSerial) this.trendLoading = false;
}
},
rowKey(row) {
return this.view === 'platform'
? `platform:${row.slug}`
: `shop:${row.key}`;
},
rowClass(row) {
return {
'is-selected': this.selectedKey === this.rowKey(row),
'is-anomaly': row.status === 'abnormal',
'is-pending': ['stale', 'jst_missing', 'financial_missing', 'pending'].includes(row.status),
'is-unavailable': row.status === 'unavailable' || row.connected === false,
};
},
findSelectedRow() {
if (this.selectedKey.startsWith('platform:')) {
return this.report.platforms.find((row) => this.rowKey(row) === this.selectedKey);
}
if (this.selectedKey.startsWith('shop:')) {
return this.report.stores.find((row) => this.rowKey(row) === this.selectedKey);
}
return null;
},
selectTrend(row) {
const key = this.rowKey(row);
this.selectedKey = this.selectedKey === key ? '' : key;
},
rowReasons(row) {
if (Array.isArray(row.reasons) && row.reasons.length) return row.reasons;
if (this.view !== 'platform') return [];
const reasons = this.report.stores
.filter((store) => store.platform_slug === row.slug)
.flatMap((store) => Array.isArray(store.reasons) ? store.reasons : []);
const unique = new Map(reasons.map((reason) => [`${reason.kind}|${reason.title}`, reason]));
return Array.from(unique.values());
},
rowHasReasons(row) {
return this.rowReasons(row).length > 0;
},
isExpanded(row) {
return Boolean(this.expanded[this.rowKey(row)]);
},
toggleReason(row) {
const key = this.rowKey(row);
if (this.expanded[key]) this.$delete(this.expanded, key);
else this.$set(this.expanded, key, true);
},
toggleAllReasons() {
const rows = this.tableRows.filter((row) => this.rowHasReasons(row));
if (this.allReasonsExpanded) {
rows.forEach((row) => this.$delete(this.expanded, this.rowKey(row)));
} else {
rows.forEach((row) => this.$set(this.expanded, this.rowKey(row), true));
}
},
goToTablePage(page) {
this.currentPage = Math.max(1, Math.min(Number(page) || 1, this.tableRowPages));
},
countPlatformStores(slug) {
return this.report.stores.filter((row) => row.platform_slug === slug).length;
},
sumFinite(rows, field) {
const values = rows
.map((row) => row[field])
.filter((value) => value !== null && value !== undefined && Number.isFinite(Number(value)));
if (!values.length) return null;
return this.round2(values.reduce((total, value) => total + Number(value), 0));
},
queueChartDraw() {
clearTimeout(this.resizeTimer);
this.resizeTimer = setTimeout(this.drawTrend, 100);
},
smoothPath(points) {
if (!points.length) return '';
if (points.length === 1) return `M ${points[0].x} ${points[0].y}`;
let path = `M ${points[0].x.toFixed(2)} ${points[0].y.toFixed(2)}`;
for (let index = 0; index < points.length - 1; index += 1) {
const p0 = points[index - 1] || points[index];
const p1 = points[index];
const p2 = points[index + 1];
const p3 = points[index + 2] || p2;
path += ` C ${(p1.x + (p2.x - p0.x) / 6).toFixed(2)} ${(p1.y + (p2.y - p0.y) / 6).toFixed(2)}, `
+ `${(p2.x - (p3.x - p1.x) / 6).toFixed(2)} ${(p2.y - (p3.y - p1.y) / 6).toFixed(2)}, `
+ `${p2.x.toFixed(2)} ${p2.y.toFixed(2)}`;
}
return path;
},
drawTrend() {
const wrap = this.$refs.trendWrap;
const svg = this.$refs.trendSvg;
const tooltip = this.$refs.tooltip;
if (!wrap || !svg || !tooltip || !this.trendPoints.length || !this.trendAvailable) return;
const width = Math.max(wrap.clientWidth, 320);
const height = width < 620 ? 300 : 350;
const margin = { left: 62, right: 20, top: 24, bottom: 28 };
const plotHeight = width < 620 ? 180 : 220;
const plotWidth = width - margin.left - margin.right;
const diffTop = margin.top + plotHeight + 38;
const diffHeight = 54;
const values = this.trendPoints
.flatMap((point) => [point.financial_balance, point.jushuitan_balance])
.filter((value) => value !== null && value !== undefined)
.map((value) => Number(value) / 10000);
const min = Math.min(...values);
const max = Math.max(...values);
const padding = Math.max((max - min) * 0.18, max * 0.012, 0.01);
const yMin = Math.max(0, min - padding);
const yMax = max + padding;
const y = (value) => margin.top + plotHeight - ((Number(value) / 10000 - yMin) / (yMax - yMin || 1)) * plotHeight;
const timeAt = (date) => Date.parse(`${date}T00:00:00Z`);
const firstTime = timeAt(this.trendPoints[0].date);
const lastTime = timeAt(this.trendPoints[this.trendPoints.length - 1].date);
const xForDate = (date) => margin.left
+ (lastTime === firstTime
? plotWidth / 2
: (timeAt(date) - firstTime) / (lastTime - firstTime) * plotWidth);
const x = (index) => xForDate(this.trendPoints[index].date);
const financePoints = this.trendPoints
.map((point, index) => point.financial_balance === null || point.financial_balance === undefined
? null
: { x: x(index), y: y(point.financial_balance), index })
.filter(Boolean);
const jstPoints = this.trendPoints
.map((point, index) => point.jushuitan_balance === null || point.jushuitan_balance === undefined
? null
: { x: x(index), y: y(point.jushuitan_balance) })
.filter(Boolean);
const financePath = this.smoothPath(financePoints);
const jstPath = this.smoothPath(jstPoints);
const areaPath = financePath
? `${financePath} L ${financePoints[financePoints.length - 1].x} ${margin.top + plotHeight} L ${financePoints[0].x} ${margin.top + plotHeight} Z`
: '';
const maxDiff = Math.max(...this.trendPoints.map((point) => Math.abs(Number(point.difference || 0))), 1);
const yTicks = Array.from({ length: 5 }, (_, index) => {
const value = yMin + (yMax - yMin) * (4 - index) / 4;
const lineY = margin.top + plotHeight * index / 4;
return `<line x1="${margin.left}" x2="${margin.left + plotWidth}" y1="${lineY}" y2="${lineY}" stroke="#e8e2d7" />
<text x="${margin.left - 9}" y="${lineY + 4}" text-anchor="end" fill="#595959" font-size="11">${this.number(value)}</text>`;
}).join('');
const xStride = Math.max(1, Math.ceil(this.trendPoints.length / (width < 620 ? 3 : 6)));
const xLabels = this.trendPoints.map((point, index) => (index % xStride === 0 || index === this.trendPoints.length - 1)
? `<text x="${x(index)}" y="${height - 7}" text-anchor="middle" fill="#595959" font-size="11">${point.date.slice(5)}</text>`
: '').join('');
const bars = this.trendPoints.map((point, index) => {
if (point.difference === null || point.difference === undefined) return '';
const barHeight = Math.abs(Number(point.difference) / 10000) / maxDiff * (diffHeight - 12);
const overTolerance = Math.abs(Number(point.difference)) > Number(this.report.tolerance_yuan || 200);
return `<rect class="difference-bar${overTolerance ? ' is-over-tolerance' : ''}" data-over-tolerance="${overTolerance ? 'true' : 'false'}" x="${x(index) - 5}" y="${diffTop + diffHeight - 6 - barHeight}" width="10" height="${Math.max(2, barHeight)}" rx="2" fill="${overTolerance ? '#B80000' : '#D8D2C7'}" />`;
}).join('');
const financeDots = financePoints.map((point) => `<circle cx="${point.x}" cy="${point.y}" r="3" fill="#fff" stroke="#856632" stroke-width="2" />`).join('');
const jstDots = jstPoints.map((point) => `<circle cx="${point.x}" cy="${point.y}" r="2.7" fill="#fff" stroke="#B9954F" stroke-width="1.8" />`).join('');
svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
svg.setAttribute('height', String(height));
svg.innerHTML = `
<title>${this.escapeHtml(this.trendTitle)}</title>
<desc>财务系统与聚水潭余额趋势及差异</desc>
<defs>
<linearGradient id="periodFinanceArea" x1="0" x2="0" y1="0" y2="1">
<stop offset="0%" stop-color="#856632" stop-opacity=".14" />
<stop offset="100%" stop-color="#856632" stop-opacity="0" />
</linearGradient>
</defs>
${yTicks}
${areaPath ? `<path d="${areaPath}" fill="url(#periodFinanceArea)" />` : ''}
${financePath ? `<path d="${financePath}" fill="none" stroke="#856632" stroke-width="2.2" stroke-linecap="round" />` : ''}
${jstPath ? `<path d="${jstPath}" fill="none" stroke="#B9954F" stroke-width="2" stroke-dasharray="7 5" stroke-linecap="round" />` : ''}
${financeDots}${jstDots}${xLabels}
<text x="${margin.left}" y="${diffTop - 10}" fill="#595959" font-size="11">双源差异</text>
<line x1="${margin.left}" x2="${margin.left + plotWidth}" y1="${diffTop + diffHeight - 6}" y2="${diffTop + diffHeight - 6}" stroke="#e8e2d7" />
${bars}
<line class="hover-guide" x1="0" x2="0" y1="${margin.top}" y2="${diffTop + diffHeight}" stroke="#9a9181" stroke-dasharray="3 3" opacity="0" />
<circle class="hover-finance" r="4" fill="#fff" stroke="#856632" stroke-width="2" opacity="0" />
<circle class="hover-jst" r="4" fill="#fff" stroke="#B9954F" stroke-width="2" opacity="0" />
<rect class="hover-overlay" x="${margin.left}" y="${margin.top}" width="${plotWidth}" height="${diffTop + diffHeight - margin.top}" fill="transparent" />
`;
const overlay = svg.querySelector('.hover-overlay');
const guide = svg.querySelector('.hover-guide');
const hoverFinance = svg.querySelector('.hover-finance');
const hoverJst = svg.querySelector('.hover-jst');
overlay.addEventListener('pointermove', (event) => {
const cursor = svg.createSVGPoint();
cursor.x = event.clientX;
cursor.y = event.clientY;
const matrix = svg.getScreenCTM();
if (!matrix) return;
const local = cursor.matrixTransform(matrix.inverse());
const ratio = Math.max(0, Math.min(1, (local.x - margin.left) / plotWidth));
const targetTime = firstTime + ratio * (lastTime - firstTime);
let index = 0;
let bestDistance = Number.POSITIVE_INFINITY;
this.trendPoints.forEach((point, pointIndex) => {
const distance = Math.abs(timeAt(point.date) - targetTime);
if (distance < bestDistance) {
bestDistance = distance;
index = pointIndex;
}
});
const point = this.trendPoints[index];
const fin = financePoints.find((item) => item.index === index) || null;
const pointX = x(index);
const jst = point.jushuitan_balance === null || point.jushuitan_balance === undefined
? null
: jstPoints.find((item) => Math.abs(item.x - pointX) < 0.1);
guide.setAttribute('x1', pointX);
guide.setAttribute('x2', pointX);
guide.setAttribute('opacity', '1');
if (fin) {
hoverFinance.setAttribute('cx', fin.x);
hoverFinance.setAttribute('cy', fin.y);
hoverFinance.setAttribute('opacity', '1');
} else {
hoverFinance.setAttribute('opacity', '0');
}
if (jst) {
hoverJst.setAttribute('cx', jst.x);
hoverJst.setAttribute('cy', jst.y);
hoverJst.setAttribute('opacity', '1');
} else {
hoverJst.setAttribute('opacity', '0');
}
const status = this.statusMeta(point.status).label;
tooltip.innerHTML = `
<strong>${point.date}</strong>
<span><i>财务系统</i><b>${this.numberWan(point.financial_balance)}</b></span>
<span><i>聚水潭</i><b>${this.numberWan(point.jushuitan_balance)}</b></span>
<span><i>双源差异</i><b>${this.signedNumberWan(point.difference)}</b></span>
<span><i>状态</i><b>${status}</b></span>
`;
const box = svg.getBoundingClientRect();
const left = pointX * box.width / width + 12;
tooltip.style.left = `${left + 220 > box.width ? Math.max(4, left - 244) : left}px`;
tooltip.style.top = `${Math.max(4, (fin ? fin.y : margin.top) * box.height / height - 72)}px`;
tooltip.style.display = 'block';
});
},
hideTooltip() {
if (this.$refs.tooltip) this.$refs.tooltip.style.display = 'none';
},
escapeHtml(value) {
return String(value || '').replace(/[&<>"']/g, (char) => ({
'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#039;',
}[char]));
},
},
};
</script>
<style scoped>
.period-reconciliation {
--ink: #171717;
--muted: #595959;
--line: #D8D2C7;
--gold: #856632;
--gold-light: #B9954F;
--gold-soft: #F7F0DE;
--red: #B80000;
--red-soft: #FFF1F0;
--green: #53793E;
--green-soft: #F0F7ED;
--amber: #935F07;
--amber-soft: #FBF5E9;
color: var(--ink);
font-family: "JetBrains Mono", "CaiWu CJK", monospace;
}
.reconciliation-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
margin-bottom: 12px;
}
.eyebrow {
margin: 0 0 4px;
color: var(--gold);
font-size: 11px;
font-weight: 700;
letter-spacing: .08em;
}
.reconciliation-head p:not(.eyebrow) {
margin: 6px 0 0;
color: var(--muted);
font-size: 13px;
}
.date-filter {
display: flex;
align-items: flex-end;
flex-wrap: wrap;
gap: 8px;
}
.date-filter label {
display: flex;
flex-direction: column;
gap: 4px;
color: var(--muted);
font-size: 11px;
}
.date-filter input {
height: 34px;
padding: 0 9px;
border: 1px solid var(--line);
border-radius: 7px;
background: #fff;
color: var(--ink);
}
.primary-button,
.secondary-button {
min-height: 34px;
padding: 0 13px;
border-radius: 7px;
font: 600 12px/1 inherit;
}
.primary-button {
border: 1px solid var(--gold);
background: var(--gold);
color: #fff;
}
.primary-button:disabled {
opacity: .55;
}
.secondary-button {
border: 1px solid var(--line);
background: #fff;
color: var(--ink);
}
.filter-status {
display: flex;
justify-content: flex-end;
margin-bottom: 12px;
}
.filter-state {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-end;
gap: 4px 10px;
margin-left: auto;
}
.range-label,
.filter-error,
.filter-dirty {
font-size: 11px;
}
.range-label { color: var(--muted); }
.filter-error { color: var(--red); }
.filter-dirty { color: var(--amber); font-weight: 600; }
.source-banner {
display: flex;
align-items: flex-start;
gap: 9px;
margin-bottom: 12px;
padding: 10px 12px;
border: 1px solid var(--line);
border-radius: 8px;
background: #FAF7EF;
color: var(--muted);
font-size: 11px;
}
.source-banner strong {
flex: 0 0 auto;
color: var(--gold);
}
.state-panel {
display: flex;
align-items: center;
justify-content: space-between;
min-height: 110px;
padding: 16px;
border: 1px solid var(--line);
border-radius: 10px;
background: #fff;
color: var(--muted);
}
.state-panel.is-error {
border-color: #f0c4c7;
background: var(--red-soft);
color: #a82d32;
}
.state-panel button {
padding: 5px 9px;
border: 1px solid currentColor;
border-radius: 6px;
background: transparent;
color: inherit;
}
.metric-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
margin-bottom: 12px;
}
.metric-card {
min-height: 122px;
padding: 14px 15px;
border: 1px solid var(--line);
border-radius: 11px;
background: #fff;
}
.metric-card.is-closing {
border-color: var(--gold-light);
background: linear-gradient(145deg, #fff, var(--gold-soft));
}
.metric-heading {
display: flex;
justify-content: space-between;
color: var(--muted);
font-size: 12px;
font-weight: 700;
}
.metric-heading i {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--gold);
}
.metric-card.is-income .metric-heading i { background: var(--green); }
.metric-card.is-expense .metric-heading i { background: var(--red); }
.metric-card strong {
display: block;
margin-top: 10px;
font-size: 24px;
line-height: 1.15;
font-variant-numeric: tabular-nums;
}
.metric-card p {
margin: 9px 0 0;
color: var(--muted);
font-size: 11px;
}
.metric-card p.is-danger { color: var(--red); font-weight: 700; }
.panel {
border: 1px solid var(--line);
border-radius: 11px;
background: #fff;
}
.chart-panel {
padding: 14px 15px 10px;
margin-bottom: 12px;
}
.panel-head,
.table-head {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 14px;
}
.panel-head h3,
.table-head h3 {
margin: 0;
font-size: 15px;
}
.panel-head p,
.table-head p {
margin: 4px 0 0;
color: var(--muted);
font-size: 11px;
}
.chart-legend {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: flex-end;
gap: 12px;
color: var(--muted);
font-size: 11px;
}
.chart-legend span {
display: inline-flex;
align-items: center;
gap: 5px;
}
.chart-legend i {
display: inline-block;
}
.finance-line { width: 21px; border-top: 2px solid var(--gold); }
.jst-line { width: 21px; border-top: 2px dashed var(--gold-light); }
.diff-bar { width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.chart-legend button {
padding: 0;
border: 0;
background: transparent;
color: var(--gold);
font: 600 11px/1.4 inherit;
}
.chart-legend button:disabled {
opacity: .55;
}
.trend-wrap {
position: relative;
min-height: 280px;
margin-top: 8px;
}
.trend-svg {
display: block;
width: 100%;
min-height: 280px;
}
.chart-empty {
display: flex;
min-height: 260px;
align-items: center;
justify-content: center;
color: var(--muted);
font-size: 12px;
}
.chart-tooltip {
position: absolute;
z-index: 4;
display: none;
min-width: 190px;
padding: 9px 11px;
border: 1px solid #dfe3ea;
border-radius: 8px;
background: #fff;
box-shadow: 0 7px 22px rgba(25, 33, 49, .14);
pointer-events: none;
font-size: 11px;
}
.chart-tooltip strong {
display: block;
margin-bottom: 5px;
}
.chart-tooltip span {
display: flex;
justify-content: space-between;
gap: 14px;
margin-top: 2px;
}
.chart-tooltip i { color: var(--muted); font-style: normal; }
.chart-tooltip b { font-variant-numeric: tabular-nums; }
.verify-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 10px;
margin-bottom: 12px;
}
.verify-card {
min-height: 116px;
padding: 13px 14px;
}
.verify-card > span {
display: block;
color: var(--muted);
font-size: 11px;
font-weight: 700;
}
.verify-card > strong {
display: block;
margin-top: 8px;
font-size: 16px;
}
.verify-card > p,
.verify-card li {
color: var(--muted);
font-size: 11px;
line-height: 1.6;
}
.verify-card > p { margin: 6px 0 0; }
.verify-card ul { margin: 5px 0 0; padding-left: 16px; }
.review-status-list {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 4px 12px;
margin: 8px 0 0 !important;
padding: 0 !important;
list-style: none;
}
.review-status-list li {
display: flex;
justify-content: space-between;
gap: 8px;
}
.review-status-list li b {
color: var(--ink);
font-weight: 600;
white-space: nowrap;
}
.review-status-list li.is-total {
grid-column: 1 / -1;
padding-top: 4px;
border-top: 1px solid var(--line);
color: var(--amber);
}
.verify-card.is-ok > strong { color: var(--green); }
.verify-card.is-bad > strong { color: var(--red); }
.verify-card.is-warning > strong { color: var(--amber); }
.source-panel {
display: flex;
gap: 8px;
margin-bottom: 12px;
padding: 10px;
overflow-x: auto;
}
.source-chip {
display: flex;
min-width: 190px;
flex: 1 0 190px;
flex-direction: column;
gap: 2px;
padding: 8px 10px;
border: 1px solid #e1e5ec;
border-radius: 7px;
background: #fbfcfd;
}
.source-chip strong { font-size: 12px; }
.source-chip span,
.source-chip small { color: var(--muted); font-size: 10px; }
.source-chip.is-ready { border-color: #cbdec2; background: var(--green-soft); }
.source-chip.is-stale,
.source-chip.is-missing { border-color: #ecd9b7; background: var(--amber-soft); }
.source-chip.is-financial_error { border-color: #efc9cc; background: var(--red-soft); }
.reconciliation-panel { overflow: hidden; }
.table-head {
padding: 13px 14px;
border-bottom: 1px solid var(--line);
}
.table-actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
.view-tabs {
display: inline-flex;
padding: 2px;
border-radius: 7px;
background: #F2EEE5;
}
.view-tabs button {
min-height: 28px;
padding: 0 10px;
border: 0;
border-radius: 6px;
background: transparent;
color: var(--muted);
font: 600 11px/1 inherit;
}
.view-tabs button.is-active {
background: #fff;
color: var(--gold);
box-shadow: 0 1px 3px rgba(30, 40, 60, .1);
}
.table-actions select {
height: 32px;
padding: 0 26px 0 9px;
border: 1px solid #d6dbe3;
border-radius: 7px;
background: #fff;
color: var(--ink);
font-size: 11px;
}
.table-scroll {
max-height: 42rem;
overflow: auto;
}
.table-pagination {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
padding: 10px 14px;
border-top: 1px solid var(--line);
color: var(--muted);
font-size: 11px;
}
.table-pagination div {
display: flex;
align-items: center;
gap: 8px;
}
.table-pagination button {
min-height: 30px;
padding: 0 10px;
border: 1px solid var(--line);
border-radius: 6px;
background: #fff;
color: var(--ink);
font: 600 11px/1 inherit;
}
.table-pagination button:disabled {
opacity: .45;
}
.table-pagination b {
min-width: 42px;
color: var(--ink);
text-align: center;
}
.reconciliation-table {
width: 100%;
min-width: 54rem;
border-collapse: separate;
border-spacing: 0;
font-size: 12px;
font-variant-numeric: tabular-nums;
}
.reconciliation-table th,
.reconciliation-table td {
padding: 9px 11px;
border-bottom: 1px solid #edf0f4;
text-align: left;
white-space: nowrap;
}
.reconciliation-table thead th {
position: sticky;
z-index: 2;
top: 0;
background: #f7f8fa;
color: #616a78;
font-size: 11px;
}
.reconciliation-table .is-number { text-align: right; }
.reconciliation-table tbody tr { cursor: pointer; }
.reconciliation-table tbody tr:hover td { background: #FAF7EF; }
.reconciliation-table tbody tr.is-selected td { background: var(--gold-soft); }
.reconciliation-table tbody tr.is-anomaly td { background: var(--red-soft); }
.reconciliation-table tbody tr.is-pending td { background: #fffbf3; }
.reconciliation-table tbody tr.is-unavailable td { color: #7d8491; }
.reconciliation-table tbody tr.total-row td {
background: #f7f8fa;
border-top: 1px solid #dce1e8;
font-weight: 700;
}
.row-name,
.reason-toggle {
padding: 0;
border: 0;
background: transparent;
color: inherit;
text-align: left;
}
.row-name { font-weight: 700; }
.row-name:hover { color: var(--gold); }
.reason-toggle {
margin-left: 7px;
color: var(--gold);
font-size: 10px;
font-weight: 600;
}
.badge {
display: inline-flex;
padding: 2px 7px;
border-radius: 999px;
font-size: 10px;
font-weight: 700;
}
.badge.is-normal { background: var(--green-soft); color: #0b7e3d; }
.badge.is-error { background: var(--red-soft); color: #bd3036; }
.badge.is-pending { background: var(--amber-soft); color: var(--amber); }
.badge.is-unavailable { background: #f2f4f7; color: #707887; }
.is-up,
.is-down { color: var(--red); font-weight: 700; }
.is-flat { color: #8b929e; }
.reason-row td {
padding: 0 !important;
background: #fffafa !important;
white-space: normal !important;
}
.reason-list {
padding: 0 11px 10px 26px;
}
.reason-list article {
margin-top: 7px;
padding: 9px 11px;
border-left: 3px solid var(--red);
border-radius: 0 7px 7px 0;
background: #fff;
}
.reason-list article > div {
display: flex;
align-items: center;
gap: 7px;
}
.reason-list strong { font-size: 12px; }
.reason-list em {
padding: 1px 6px;
border-radius: 999px;
background: var(--red-soft);
color: var(--red);
font-size: 9px;
font-style: normal;
font-weight: 700;
}
.reason-list p {
margin: 4px 0 0;
color: #5c6472;
font-size: 11px;
}
.reason-list b { color: #303846; }
.empty-cell {
padding: 3.5rem 1rem !important;
color: var(--muted);
text-align: center !important;
}
.reconciliation-foot {
display: flex;
justify-content: space-between;
gap: 10px;
margin-top: 9px;
color: var(--muted);
font-size: 10px;
}
@media (max-width: 960px) {
.reconciliation-head,
.panel-head,
.table-head {
flex-direction: column;
}
.date-filter { width: 100%; }
.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.verify-grid { grid-template-columns: 1fr; }
.chart-legend { justify-content: flex-start; }
}
@media (max-width: 560px) {
.metric-grid { grid-template-columns: 1fr; }
.date-filter label { flex: 1 1 130px; }
.primary-button { flex: 1 1 100%; }
.filter-state { width: 100%; margin-left: 0; justify-content: flex-start; }
.reconciliation-foot { flex-direction: column; }
}
</style>