diff --git a/app/Support/QuoteManagementSnapshot.php b/app/Support/QuoteManagementSnapshot.php index 4c1486bc..121a8bbc 100644 --- a/app/Support/QuoteManagementSnapshot.php +++ b/app/Support/QuoteManagementSnapshot.php @@ -66,6 +66,7 @@ final class QuoteManagementSnapshot 'id' => sprintf('QB-%03d', $position + 1), 'sheet_index' => (int) ($sheet['index'] ?? $position), 'sheet_name' => $name, + 'company_name' => $this->inferCompanyName($name), 'carrier' => $this->inferCarrier($name), 'quote_type' => $this->inferQuoteType($name), 'effective_date' => $this->extractEffectiveDate($values), @@ -80,6 +81,13 @@ final class QuoteManagementSnapshot ]; } + private function inferCompanyName(string $name): string + { + $companyName = trim((string) preg_replace('/(?:报价表|报价)$/u', '', $name)); + + return $companyName !== '' ? $companyName : $name; + } + private function normalizeMatrix(mixed $matrix): array { if (! is_array($matrix)) { diff --git a/resources/views/business/pages/courier-payables/quote-management.blade.php b/resources/views/business/pages/courier-payables/quote-management.blade.php index 582e9cd3..33921dad 100644 --- a/resources/views/business/pages/courier-payables/quote-management.blade.php +++ b/resources/views/business/pages/courier-payables/quote-management.blade.php @@ -2,12 +2,11 @@ $quoteSnapshot = app(\App\Support\QuoteManagementSnapshot::class)->load(); $quotes = $quoteSnapshot['quotes']; $quoteCompanies = collect($quotes) - ->mapWithKeys(function (array $quote): array { - $label = preg_replace('/(?:报价表|报价)$/u', '', (string) $quote['sheet_name']); - - return [$quote['sheet_name'] => $label ?: $quote['sheet_name']]; - }) + ->pluck('company_name') + ->filter() + ->unique() ->sort() + ->values() ->all(); $quoteTypes = collect($quotes)->pluck('quote_type')->unique()->sort()->values(); @endphp @@ -758,14 +757,14 @@
@@ -1055,9 +1054,8 @@ function renderRow(quote) { var row = create('tr'); var nameCell = appendCell(row, ''); - nameCell.appendChild(create('span', 'quote-table__name', quote.sheet_name)); - nameCell.appendChild(create('span', 'quote-table__secondary', quote.id)); - appendCell(row, quote.carrier); + nameCell.appendChild(create('span', 'quote-table__name', quote.id)); + appendCell(row, quote.company_name); appendCell(row, quote.quote_type); appendCell(row, text(quote.source_range, '-')); appendCell(row, quote.row_count + ' 行 × ' + quote.column_count + ' 列'); @@ -1112,12 +1110,12 @@ var keyword = fields.keyword.value.trim().toLocaleLowerCase('zh-CN'); filteredQuotes = quotes.filter(function (quote) { - var matchesKeyword = !keyword || (quote.sheet_name + ' ' + quote.id + ' ' + quote.carrier) + var matchesKeyword = !keyword || (quote.company_name + ' ' + quote.sheet_name + ' ' + quote.id + ' ' + quote.carrier) .toLocaleLowerCase('zh-CN') .includes(keyword); return matchesKeyword - && (!fields.carrier.value || quote.sheet_name === fields.carrier.value) + && (!fields.carrier.value || quote.company_name === fields.carrier.value) && (!fields.type.value || quote.quote_type === fields.type.value) && (!fields.status.value || quote.status === fields.status.value); }); @@ -1150,7 +1148,7 @@ lastFocusedElement = trigger; setDetail('title', quote.sheet_name); setDetail('id', quote.id); - setDetail('carrier', quote.carrier); + setDetail('carrier', quote.company_name); setDetail('type', quote.quote_type); setDetail('range', text(quote.source_range, '-')); setDetail('date', text(quote.effective_date, 'Excel 未标注')); diff --git a/tests/Feature/Business/QuoteManagementPageTest.php b/tests/Feature/Business/QuoteManagementPageTest.php index 891f6c8a..28869a93 100644 --- a/tests/Feature/Business/QuoteManagementPageTest.php +++ b/tests/Feature/Business/QuoteManagementPageTest.php @@ -52,6 +52,16 @@ class QuoteManagementPageTest extends FeatureTestCase ], 'formulas' => [[], []], ], + [ + 'index' => 3, + 'name' => '新北中通其他报价', + 'address' => 'A1:D2', + 'values' => [ + ['省份', '面单', '费率', '备注'], + ['江苏省', 4.1, 0.6, null], + ], + 'formulas' => [[], []], + ], ], ], JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR)); @@ -91,14 +101,26 @@ class QuoteManagementPageTest extends FeatureTestCase ->assertSeeText('变更类型') ->assertSeeText('变更说明') ->assertSeeText('生成变更草稿') - ->assertSee('', false) - ->assertSee('', false) + ->assertSee('', false) + ->assertSee('', false) + ->assertSee('', false) + ->assertSee('"id":"QB-001"', false) + ->assertSee('"company_name":"新北中通"', false) + ->assertSee('"company_name":"新北中通其他"', false) ->assertSee('新北中通报价', false) ->assertSee('常州圆通-上楼', false) ->assertSee('2025-12-01', false) ->assertSee('=B3/2', false) ->assertSeeText('原始报价规则保留,当前页面不重新计算金额') ->assertDontSee('报价列表正在配置中'); + + $quotes = app(QuoteManagementSnapshot::class)->load()['quotes']; + + $this->assertSame(['QB-001', 'QB-002', 'QB-003', 'QB-004'], array_column($quotes, 'id')); + $this->assertSame( + ['新北中通', '常州圆通-上楼', '新德邦快递超长', '新北中通其他'], + array_column($quotes, 'company_name') + ); } public function testQuoteManagementPageKeepsTheShellWhenThePrivateSnapshotIsMissing(): void