修复BUG

This commit is contained in:
liu
2026-08-27 14:20:09 +08:00
parent 513cc568a9
commit 52dc6efadf
203 changed files with 576 additions and 1130 deletions
+18 -7
View File
@@ -6,11 +6,13 @@ use App\Exceptions\RepositoryException;
use App\Models\PurchaseOrderModel;
use App\Models\StoreOrderItemModel;
use App\Models\SupplierModel;
use App\Services\PurchaseItemService;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
/**
* 供应商采购明细导出:多供应商合并为一个 XLSX(每供应商一个工作表,工作表名=供应商名称);
* 构造传入 supplierId 时仅导出该供应商(单工作表)
* 供应商采购明细导出:多供应商合并为一个 XLSX,按「供应商 × 市场」拆分工作表
* (工作表名=供应商·市场,市场取商品档案,未设置市场归入「未设置」);
* 构造传入 supplierId 时仅导出该供应商
*/
class PurchaseSupplierExport implements WithMultipleSheets
{
@@ -51,14 +53,23 @@ class PurchaseSupplierExport implements WithMultipleSheets
->orderBy('id')
->get(['id', 'name']);
$service = app(PurchaseItemService::class);
$usedNames = [];
$sheets = [];
foreach ($suppliers as $supplier) {
$sheets[] = new PurchaseSupplierSheet(
$this->purchase,
$supplier,
SheetName::make((string) $supplier->name, (int) $supplier->id, $usedNames),
);
// 按市场拆分工作表
$matrix = $service->supplierMarketMatrix($this->purchase->id, (int) $supplier->id);
foreach ($matrix['markets'] as $market => $rows) {
$marketLabel = $market === '' ? '未设置' : $market;
$sheets[] = new PurchaseSupplierSheet(
$this->purchase,
$supplier,
$marketLabel,
$rows,
$matrix['stores'],
SheetName::make($supplier->name . '·' . $marketLabel, (int) $supplier->id, $usedNames),
);
}
}
return $sheets;