多时期补录保留选定快递网点编号 (#384)

This commit is contained in:
limeng 2026-10-17 21:09:11 +08:00
parent 10d9c22e3e
commit 23887059f1
2 changed files with 16 additions and 0 deletions

View File

@ -33,6 +33,7 @@
@endif
<form method="POST" enctype="multipart/form-data" action="{{ $entry ? route('business.courier-stock-quotes.update', $entry) : route('business.courier-stock-quotes.store') }}" data-stock-quote-form>
@csrf
<input type="hidden" name="courier_expcode" value="{{ old('courier_expcode', $entry?->courier_expcode ?? request('courier_expcode')) }}" data-stock-courier-code>
@if($entry) @method('PATCH') @endif
<section class="stock-quote__panel">
<h2 class="stock-quote__header"><span class="material-icons-outlined" aria-hidden="true">local_shipping</span>第一步:确认快递名称</h2>
@ -88,6 +89,10 @@
<script>
(() => {
const form = document.querySelector('[data-stock-quote-form]');
const name = form?.querySelector('[data-courier-name-input]');
const code = form?.querySelector('[data-stock-courier-code]');
const initialName = name?.value.trim(), initialCode = code?.value;
name?.addEventListener('input', () => { code.value = name.value.trim() === initialName ? initialCode : ''; });
form?.addEventListener('submit', () => {
const button = form.querySelector('button[type="submit"]');
button.disabled = true;

View File

@ -350,6 +350,17 @@ class CourierStockQuoteEntryTest extends FeatureTestCase
$this->withExceptionHandling()->loginAs($this->reviewer(), $this->company)->post(route('business.courier-stock-quotes.period-end', $entry), ['end_date' => '2026-09-30', 'reason' => '公司隔离检查'])->assertNotFound();
}
public function test_period_prefill_preserves_selected_code_for_same_named_couriers(): void
{
$response = $this->loginAs()->get(route('business.courier-stock-quotes.single', ['courier_name' => '同名快递网点', 'courier_expcode' => 'EXP-002', 'quote_type' => '标准快递报价']))->assertOk();
$document = new \DOMDocument;
@$document->loadHTML($response->getContent(), LIBXML_NONET);
$code = (new \DOMXPath($document))->query('//input[@name="courier_expcode"]')->item(0)->getAttribute('value');
$this->assertSame('EXP-002', $code);
$this->post(route('business.courier-stock-quotes.store'), [...$this->payload(), 'courier_name' => '同名快递网点', 'courier_expcode' => $code])->assertRedirect();
$this->assertSame('EXP-002', CourierStockQuoteEntry::firstOrFail()->courier_expcode);
}
private function payload(): array
{
return ['courier_expcode' => 'EXP-001', 'quote_type' => '标准快递报价', 'source_quote' => $this->workbook(),