fix: 修复首页分账计算模块显示问题
- 显示被隐藏的分账计算模块(移除 display: 'none') - 调整 platformSharePercent 状态变量定义顺序 - 优化 Slider 组件: - 设置标记文字颜色为深灰色 (#666),避免看不清 - 添加 tooltip 提示框,拖动时显示当前百分比 - 设置 tooltip 背景为深色,文字为白色,确保清晰可见 - 移除重复的 90% 标记,只保留 0%、50%、100% 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid } from 'antd';
|
||||
import { Card, Space, Typography, Row, Col, Button, message, DatePicker, Segmented, List, Tag, Statistic, Grid, Slider, InputNumber } from 'antd';
|
||||
import { ReloadOutlined } from '@ant-design/icons';
|
||||
import { Line, Pie } from '@ant-design/plots';
|
||||
import TenantScopeFilter from '@/components/TenantScopeFilter';
|
||||
@@ -22,7 +22,7 @@ const computeRangeByType = (type: RangeType, anchor?: Moment): [Moment, Moment]
|
||||
const STATUS_OPTIONS: { value: number; label: string; color?: string }[] = [
|
||||
{ value: 0, label: '待支付' },
|
||||
{ value: 1, label: '排队中', color: 'gold' },
|
||||
{ value: 2, label: '已取号', color: 'red' },
|
||||
{ value: 2, label: '已取消', color: 'red' },
|
||||
{ value: 3, label: '设备执行完成', color: 'green' },
|
||||
{ value: 4, label: '正在服务', color: 'blue' },
|
||||
{ value: 5, label: '素材上传', color: 'geekblue' },
|
||||
@@ -36,8 +36,9 @@ const Welcome: React.FC = () => {
|
||||
// 租户与时间
|
||||
const [tenantId, setTenantId] = useState<string>();
|
||||
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
|
||||
const [rangeType, setRangeType] = useState<RangeType>('date');
|
||||
const [range, setRange] = useState<[Moment, Moment]>(makeDefaultToday());
|
||||
// 默认统计时间:年
|
||||
const [rangeType, setRangeType] = useState<RangeType>('year');
|
||||
const [range, setRange] = useState<[Moment, Moment]>(computeRangeByType('year', moment()));
|
||||
|
||||
// 加载与数据
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
@@ -74,7 +75,8 @@ const Welcome: React.FC = () => {
|
||||
|
||||
const handleRangeChange = (vals: any) => {
|
||||
if (!Array.isArray(vals) || vals.length !== 2 || !vals[0] || !vals[1]) {
|
||||
setRange(makeDefaultToday());
|
||||
// 按当前类型回退默认范围
|
||||
setRange(computeRangeByType(rangeType, moment()));
|
||||
return;
|
||||
}
|
||||
let s = vals[0] as Moment;
|
||||
@@ -221,9 +223,15 @@ const Welcome: React.FC = () => {
|
||||
animation: false,
|
||||
};
|
||||
|
||||
// 平台分账比例(默认 90%),用于分账计算展示框
|
||||
const [platformSharePercent, setPlatformSharePercent] = useState<number>(90);
|
||||
|
||||
const totalAmountYuan = Number(((orderStats?.totalAmount ?? 0) as number) / 100);
|
||||
const refundAmountYuan = Number(((orderStats?.refundAmount ?? 0) as number) / 100);
|
||||
const netIncomeYuan = Number((totalAmountYuan - refundAmountYuan).toFixed(2));
|
||||
// 分账金额(基于净收入)
|
||||
const platformAmountYuan = Number(((netIncomeYuan * platformSharePercent) / 100).toFixed(2));
|
||||
const scenicAmountYuan = Number((netIncomeYuan - platformAmountYuan).toFixed(2));
|
||||
|
||||
// 首次加载/筛选变化
|
||||
useEffect(() => {
|
||||
@@ -247,11 +255,12 @@ const Welcome: React.FC = () => {
|
||||
<Segmented
|
||||
block={isMobile}
|
||||
size={isMobile ? 'small' : 'middle'}
|
||||
// 统计维度顺序:年 月 周 日(覆盖上方默认)
|
||||
options={[
|
||||
{ label: '日', value: 'date' },
|
||||
{ label: '周', value: 'week' },
|
||||
{ label: '年', value: 'year' },
|
||||
{ label: '月', value: 'month' },
|
||||
{ label: '年', value: 'year' }
|
||||
{ label: '周', value: 'week' },
|
||||
{ label: '日', value: 'date' },
|
||||
]}
|
||||
value={rangeType}
|
||||
onChange={handleRangeTypeChange}
|
||||
@@ -282,7 +291,7 @@ const Welcome: React.FC = () => {
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={12}>
|
||||
<Text strong>总订单概览</Text>
|
||||
<Row gutter={8} align="middle" style={{ width: '100%' }}>
|
||||
<Col xs={12} sm={10} md={10}><Text type="secondary">总订单数</Text></Col>
|
||||
<Col xs={12} sm={10} md={10}><Text type="secondary">支付总订单数</Text></Col>
|
||||
<Col xs={12} sm={14} md={14} style={{ textAlign: 'right' }}>
|
||||
<Statistic value={orderStats?.totalOrders || 0} valueStyle={{ fontWeight: 600, whiteSpace: 'nowrap' }} />
|
||||
</Col>
|
||||
@@ -294,7 +303,7 @@ const Welcome: React.FC = () => {
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={8} align="middle" style={{ width: '100%' }}>
|
||||
<Col xs={12} sm={10} md={10}><Text type="secondary">净订单数</Text></Col>
|
||||
<Col xs={12} sm={10} md={10}><Text type="secondary">支付净订单数</Text></Col>
|
||||
<Col xs={12} sm={14} md={14} style={{ textAlign: 'right' }}>
|
||||
<Statistic value={(orderStats?.totalOrders || 0) - (orderStats?.refundedOrders || 0)} valueStyle={{ fontWeight: 600, whiteSpace: 'nowrap' }} />
|
||||
</Col>
|
||||
@@ -324,6 +333,71 @@ const Welcome: React.FC = () => {
|
||||
<Statistic value={netIncomeYuan} precision={2} valueStyle={{ fontWeight: 600, whiteSpace: 'nowrap' }} />
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 分账计算(基于净收入) */}
|
||||
<Row gutter={[16, 16]} style={{ marginTop: 16 }}>
|
||||
<Col xs={24}>
|
||||
<Card className="modern-card">
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={12}>
|
||||
<Row align="middle" justify="space-between" gutter={[8, 8]}>
|
||||
<Col flex="none"><Text strong>分账计算</Text></Col>
|
||||
<Col flex="auto" style={{ textAlign: 'right' }}>
|
||||
<Space>
|
||||
<span>平台分账比例</span>
|
||||
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 8, minWidth: 220 }}>
|
||||
<Slider
|
||||
style={{ width: 160 }}
|
||||
min={0}
|
||||
max={100}
|
||||
step={1}
|
||||
value={platformSharePercent}
|
||||
onChange={(v: any) => setPlatformSharePercent(Number(v))}
|
||||
marks={{
|
||||
0: { style: { color: '#666' }, label: '0%' },
|
||||
50: { style: { color: '#666' }, label: '50%' },
|
||||
100: { style: { color: '#666' }, label: '100%' }
|
||||
}}
|
||||
tooltip={{
|
||||
formatter: (value) => `${value}%`,
|
||||
overlayStyle: {
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
||||
color: '#fff'
|
||||
},
|
||||
overlayInnerStyle: {
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.75)',
|
||||
color: '#fff'
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<InputNumber min={0} max={100} value={platformSharePercent} onChange={(v) => setPlatformSharePercent(Number(v || 0))} formatter={(v) => `${v}%`} parser={(v: any) => Number(String(v || '').replace('%', ''))} />
|
||||
</div>
|
||||
</Space>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={[8, 8]}>
|
||||
<Col xs={24} sm={12}>
|
||||
<Card>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={8}>
|
||||
<Text type="secondary">平台分账金额(元)</Text>
|
||||
<Statistic value={platformAmountYuan} precision={2} valueStyle={{ fontWeight: 600 }} />
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={24} sm={12}>
|
||||
<Card>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={8}>
|
||||
<Text type="secondary">景区分账金额(元)</Text>
|
||||
<Statistic value={scenicAmountYuan} precision={2} valueStyle={{ fontWeight: 600 }} />
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
<Text type="secondary">基于净收入计算(净收入 = 订单总金额 - 退款总金额)</Text>
|
||||
</Space>
|
||||
</Card>
|
||||
</Col>
|
||||
|
||||
Reference in New Issue
Block a user