修正庫存報表分頁參數衝突導致明細顯示為空的問題

This commit is contained in:
2026-02-10 16:07:31 +08:00
parent 8b950f6529
commit 593ce94734
15 changed files with 1210 additions and 30 deletions

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Modules\Inventory\Exports;
use App\Modules\Inventory\Services\InventoryReportService;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithStyles;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class InventoryReportExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithStyles
{
protected $service;
protected $filters;
public function __construct(InventoryReportService $service, array $filters)
{
$this->service = $service;
$this->filters = $filters;
}
public function collection()
{
return $this->service->getReportData($this->filters, null); // perPage = null to get all
}
public function headings(): array
{
return [
'商品代碼',
'商品名稱',
'分類',
'進貨量',
'出貨量',
'調整量',
'淨變動',
];
}
public function map($row): array
{
return [
$row->product_code,
$row->product_name,
$row->category_name ?? '-',
$row->inbound_qty,
$row->outbound_qty,
$row->adjust_qty,
$row->net_change,
];
}
public function styles(Worksheet $sheet)
{
return [
1 => ['font' => ['bold' => true]],
];
}
}