fix: 调整报价版本与快递公司显示
This commit is contained in:
parent
33086a0eda
commit
c3e1df41de
@ -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)) {
|
||||
|
||||
@ -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 @@
|
||||
<div class="quote-toolbar" aria-label="报价筛选">
|
||||
<label class="quote-field">
|
||||
<span class="quote-field__label">报价名称</span>
|
||||
<input class="quote-control" type="search" name="keyword" placeholder="搜索工作表或版本号" autocomplete="off" data-quote-filter="keyword">
|
||||
<input class="quote-control" type="search" name="keyword" placeholder="搜索快递公司或版本号" autocomplete="off" data-quote-filter="keyword">
|
||||
</label>
|
||||
<label class="quote-field">
|
||||
<span class="quote-field__label">快递公司</span>
|
||||
<select class="quote-control" name="carrier" data-quote-filter="carrier">
|
||||
<option value="">全部公司</option>
|
||||
@foreach ($quoteCompanies as $sheetName => $companyName)
|
||||
<option value="{{ $sheetName }}">{{ $companyName }}</option>
|
||||
@foreach ($quoteCompanies as $companyName)
|
||||
<option value="{{ $companyName }}">{{ $companyName }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
@ -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 未标注'));
|
||||
|
||||
@ -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('<option value="新北中通报价">新北中通</option>', false)
|
||||
->assertSee('<option value="新德邦快递超长报价">新德邦快递超长</option>', false)
|
||||
->assertSee('<option value="新北中通">新北中通</option>', false)
|
||||
->assertSee('<option value="新北中通其他">新北中通其他</option>', false)
|
||||
->assertSee('<option value="新德邦快递超长">新德邦快递超长</option>', 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user