[ * 'projects' => ['RD01', 'RD02'], * 'data' => [ [...] ] * ], * '2024年5月' => [ * 'projects' => ['RD03'], * 'data' => [ [...] ] * ] * ] */ public function __construct(array $monthsData,$company) { $this->monthsData = $monthsData; $this->company = $company; } public function sheets(): array { $sheets = []; foreach ($this->monthsData as $month => $item) { // 每次实例化 Sheet 时,传入该月特有的 projects 列表 $sheets[] = new ItemSalaryFTSheetExport( $month, $item['data'], $item['projects'], $this->company ); } return $sheets; } }