@page "/report/shiftSettlementDailyReport"
@attribute [ReuseTabsPage(Title = "班结日报表")]


<style>
    .daily-report-container {
        padding: 16px;
        background-color: #f5f7fa;
        min-height: 100vh;
        box-sizing: border-box;
        overflow: hidden;
    }

    .filter-section {
        margin-bottom: 16px;
        padding: 16px !important;
        background: white;
        border: 1px solid #ebeef5;
        border-radius: 4px;
    }

    .filter-content .filter-row {
        display: flex;
        align-items: center;
        gap: 16px;
        flex-wrap: wrap;
    }

        .filter-content .filter-row .filter-item {
            display: flex;
            align-items: center;
        }

            .filter-content .filter-row .filter-item .filter-label {
                margin-right: 8px;
                font-size: 14px;
                color: #606266;
                min-width: 32px;
            }

        .filter-content .filter-row .filter-actions {
            display: flex;
            gap: 8px;
            margin-left: auto;
        }

    .report-section {
        margin-bottom: 16px;
        padding: 16px;
        background: white;
        border: 1px solid #ebeef5;
        border-radius: 4px;
    }

    .section-header {
        margin-bottom: 16px;
        padding: 0 16px;
    }

        .section-header h3 {
            color: #303133;
            font-size: 16px;
            border-left: 4px solid #1890ff;
            padding-left: 10px;
            margin: 0;
        }

    .summary-section {
        padding: 16px;
    }

        .summary-section h3 {
            color: #303133;
            font-size: 16px;
            margin-bottom: 16px;
            border-left: 4px solid #1890ff;
            padding-left: 10px;
        }

    .summary-content {
        display: flex;
        justify-content: space-around;
    }

    .summary-item {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .summary-value {
        font-size: 24px;
        font-weight: 600;
        color: #1890ff;
        margin-bottom: 8px;
    }

    .summary-label {
        font-size: 14px;
        color: #909399;
    }

    .table-container {
        padding: 0 16px 16px;
    }

    /* Div表格样式 */
    .div-table {
        display: flex;
        flex-direction: column;
        border: 1px solid #ebeef5;
        border-radius: 4px;
        overflow: hidden;
        font-size: 14px;
    }

    .div-table-header {
        display: flex;
        background-color: #f5f7fa;
        font-weight: 600;
        color: #606266;
        border-bottom: 1px solid #ebeef5;
    }

    .div-table-row {
        display: flex;
        border-bottom: 1px solid #ebeef5;
    }

        .div-table-row:last-child {
            border-bottom: none;
        }

        .div-table-row.total-row {
            font-weight: 600;
            background-color: #f0f9ff;
        }

        .div-table-row:nth-child(even) {
            background-color: #fafafa;
        }

    .div-table-cell {
        padding: 12px 8px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .highlight-cell {
        color: #1890ff !important;
        font-weight: 500;
    }

    /* 响应式设计 */
    @@media (max-width: 768px) {
        .daily-report-container {
            padding: 12px;
        }

        .filter-section {
            padding: 12px !important;
        }

        .filter-content .filter-row {
            flex-direction: column;
            align-items: flex-start;
        }

            .filter-content .filter-row .filter-actions {
                margin-left: 0;
                width: 100%;
                display: flex;
                justify-content: center;
                margin-top: 8px;
            }

        .summary-content {
            flex-wrap: wrap;
        }

        .summary-item {
            width: 50%;
            margin-bottom: 16px;
        }

        .div-table {
            overflow-x: auto;
        }

        .div-table-header,
        .div-table-row {
            min-width: 800px;
        }

        .div-table-cell {
            padding: 8px 4px;
            font-size: 12px;
        }
    }
</style>

<div class="daily-report-container">
    <!-- 筛选条件 -->
    <div class="filter-section">
        <div class="filter-content">
            <div class="filter-row">
                <div class="filter-item">
                    <span class="filter-label">日期</span>
                    <DatePicker @bind-Value="Filter.Date"
                                Format="yyyy-MM-dd"
                                Style="width: 150px" />
                </div>
                <div class="filter-item">
                    <span class="filter-label">设备编号</span>
                    <Input @bind-Value="Filter.PlateNumber"
                           Placeholder="请输入设备编号"
                           Style="width: 150px" />
                </div>
                <!-- 班次 -->
                <div class="form-item">
                    <span class="form-label">班次</span>
                    <Select TItemValue="string" TItem="string"
                            DataSource="@ShiftName"
                            @bind-Value="@Filter.Shift"
                            Style="width: 120px"
                            Placeholder="请选择"
                            AllowClear />
                </div>
                <div class="filter-actions">
                    <Button Icon="search" OnClick="HandleQuery">查询</Button>
                    <Button Icon="reload" OnClick="HandleReset">重置</Button>
                </div>
            </div>
        </div>
    </div>

    <!-- 统计摘要 -->
    <div class="report-section">
        <div class="summary-section">
            <h3>统计摘要</h3>
            <div class="summary-content">
                <div class="summary-item">
                    <div class="summary-value">@Summary.TotalOrders</div>
                    <div class="summary-label">总订单量</div>
                </div>
                <div class="summary-item">
                    <div class="summary-value">@FormatCurrency(Summary.TotalSales)</div>
                    <div class="summary-label">总销售金额</div>
                </div>
                <div class="summary-item">
                    <div class="summary-value">@FormatCurrency(Summary.TotalActual)</div>
                    <div class="summary-label">总实收金额</div>
                </div>
            </div>
        </div>
    </div>

    <!-- 收入概览 -->
    <div class="report-section">
        <div class="section-header">
            <h3>收入概览</h3>
        </div>
        <div class="table-container">
            <div class="div-table">
                <!-- 表头 -->
                <div class="div-table-header">
                    <div class="div-table-cell" style="width: 25%">销售项目</div>
                    <div class="div-table-cell" style="width:  25%;">订单量</div>
                    <div class="div-table-cell" style="width:  25%;">销售数量</div>
                    <div class="div-table-cell highlight-cell" style="width:  25%;">销售金额</div>
                </div>

                <!-- 表格内容 -->
                @foreach (var item in RevenueData)
                {
                    <div class="div-table-row @(item.Name == "合计" ? "total-row" : "")">
                        <div class="div-table-cell" style="width:  25%;">@item.Name</div>
                        <div class="div-table-cell" style="width:  25%;">@item.OrderCount</div>
                        <div class="div-table-cell" style="width:  25%;">@FormatNumber(item.SalesQuantity)</div>
                        <div class="div-table-cell highlight-cell" style="width:  25%;">@FormatCurrency(item.SalesAmount)</div>
                    </div>
                }
            </div>
        </div>
    </div>

    <!-- 支付方式汇总 -->
    <div class="report-section">
        <div class="section-header">
            <h3>支付方式汇总</h3>
        </div>
        <div class="table-container">
            <div class="div-table">
                <!-- 表头 -->
                <div class="div-table-header">
                    <div class="div-table-cell" style="width: 33%;">支付方式</div>
                    <div class="div-table-cell" style="width: 33%;">支付次数</div>
                    <div class="div-table-cell highlight-cell" style="width: 33%;">支付金额</div>
                </div>

                <!-- 表格内容 -->
                @foreach (var item in PaymentData)
                {
                    <div class="div-table-row">
                        <div class="div-table-cell" style="width: 33%;">@item.Name</div>
                        <div class="div-table-cell" style="width: 33%;">@item.PaymentCount</div>
                        <div class="div-table-cell highlight-cell" style="width: 33%;">@FormatCurrency(item.PaymentAmount)</div>
                    </div>
                }
            </div>
        </div>
    </div>

    <!-- 车队统计表 -->
    <div class="report-section">
        <div class="section-header">
            <h3>车队统计表</h3>
        </div>
        <div class="table-container">
            <div class="div-table">
                <!-- 表头 -->
                <div class="div-table-header">
                    <div class="div-table-cell" style="width: 20%;">设备编号</div>
                    <div class="div-table-cell" style="width: 20%;">车牌号</div>
                    <div class="div-table-cell" style="width: 20%;">加油次数</div>
                    <div class="div-table-cell" style="width: 20%;">加油升数</div>
                    <div class="div-table-cell" style="width: 20%;">支付金额</div>
                </div>

                <!-- 表格内容 -->
                @foreach (var item in FleetStats)
                {
                    <div class="div-table-row">
                        <div class="div-table-cell" style="width: 20%;">@item.DeviceId</div>
                        <div class="div-table-cell" style="width: 20%;">@item.LicencePlate</div>
                        <div class="div-table-cell" style="width: 20%;">@item.PaymentCount</div>
                        <div class="div-table-cell" style="width: 20%;">@FormatCurrency(item.SalesQuantity)</div>
                        <div class="div-table-cell" style="width: 20%;">@FormatCurrency(item.ActualAmount)</div>
                    </div>
                }
            </div>
        </div>
    </div>

    <!-- 油品销售 -->
    <div class="report-section">
        <div class="section-header">
            <h3>油品销售</h3>
        </div>
        <div class="table-container">
            <div class="div-table">
                <!-- 表头 -->
                <div class="div-table-header">
                    <div class="div-table-cell" style="width: 11%;">油品</div>
                    <div class="div-table-cell" style="width: 11%;">订单量</div>
                    <div class="div-table-cell" style="width: 11%;">销售数量</div>
                    <div class="div-table-cell" style="width: 11%;">销售金额</div>
                    <div class="div-table-cell highlight-cell" style="width: 11%;">实收金额</div>
                    <div class="div-table-cell" style="width: 11%;">单价</div>
                    <div class="div-table-cell" style="width: 11%;">起泵数</div>
                    <div class="div-table-cell" style="width: 11%;">止泵数</div>
                    <div class="div-table-cell" style="width: 11%;">泵数</div>
                </div>

                <!-- 表格内容 -->
                @foreach (var item in OilSalesData)
                {
                    <div class="div-table-row @(item.Name == "合计" ? "total-row" : "")">
                        <div class="div-table-cell" style="width: 11%;">@item.Name</div>
                        <div class="div-table-cell" style="width: 11%;">@item.OrderCount</div>
                        <div class="div-table-cell" style="width: 11%;">@FormatNumber(item.SalesQuantity)</div>
                        <div class="div-table-cell" style="width: 11%;">@FormatCurrency(item.SalesAmount)</div>
                        <div class="div-table-cell highlight-cell" style="width: 11%;">@FormatCurrency(item.ActualAmount)</div>
                        <div class="div-table-cell" style="width: 11%;">@FormatCurrency(item.Price)</div>
                        <div class="div-table-cell" style="width: 11%;">@item.StartPumpCount</div>
                        <div class="div-table-cell" style="width: 11%;">@item.EndPumpCount</div>
                        <div class="div-table-cell" style="width: 11%;">@item.PumpCount</div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>