修复一些错误

This commit is contained in:
liu
2026-08-14 21:28:55 +08:00
parent 398bb98356
commit 228212f8e3
20 changed files with 489 additions and 100 deletions
+1 -10
View File
@@ -33,16 +33,14 @@ class PurchaseOrderExport implements FromCollection, WithHeadings, WithMapping,
/**
* @param PurchaseOrderModel $purchase 采购单
* @param string $type all 全品类 / category 仅蔬果分类
*/
public function __construct(
private readonly PurchaseOrderModel $purchase,
private readonly string $type = 'all',
) {
}
/**
* 导出行(商品聚合行,按 分类sort → 商品sort 排序;蔬果分类时按顶级分类名过滤
* 导出行(商品聚合行,按 分类sort → 商品sort 排序)
*/
public function collection(): Collection
{
@@ -114,13 +112,6 @@ class PurchaseOrderExport implements FromCollection, WithHeadings, WithMapping,
$items = collect($rows);
$this->loadLookups($items);
if ($this->type === 'category') {
$items = $items->filter(function (array $row): bool {
$rootName = $this->categoryNames[$row['product_id']] ?? '';
return str_contains($rootName, '蔬菜') || str_contains($rootName, '水果');
})->values();
}
$sort = 1;
return $this->items = $items->map(static function (array $row) use (&$sort): array {
$row['sort'] = $sort++;