test: 验证新增省份与现有报价表单兼容
This commit is contained in:
parent
1e5dbafb16
commit
dea89287a7
@ -249,7 +249,11 @@
|
||||
let nextProvinceIndex = Math.max(-1, ...Array.from(provinceRows.children, row => Number(row.dataset.provinceIndex))) + 1;
|
||||
provinceEditor.querySelector('[data-add-province]').addEventListener('click', function () {
|
||||
provinceRows.insertAdjacentHTML('beforeend', provinceTemplate.innerHTML.replaceAll('__INDEX__', String(nextProvinceIndex++)));
|
||||
provinceRows.lastElementChild.querySelector('input').focus();
|
||||
const newRow = provinceRows.lastElementChild;
|
||||
newRow.querySelectorAll('[data-field-name]').forEach(field => {
|
||||
field.name = field.dataset.fieldName;
|
||||
});
|
||||
newRow.querySelector('input').focus();
|
||||
});
|
||||
provinceRows.addEventListener('click', function (event) {
|
||||
const removeButton = event.target.closest('[data-remove-province]');
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
<fieldset data-province-index="{{ $provinceIndex }}" class="quote-change-panel__body">
|
||||
<legend>新增省份 · 原报价无</legend>
|
||||
<label>省份
|
||||
<input class="quote-change-control" name="province_additions[{{ $provinceIndex }}][region]" value="{{ $province['region'] ?? '' }}" maxlength="16" required>
|
||||
<input class="quote-change-control" @if($provinceIndex === '__INDEX__') data-field-name @else name @endif="province_additions[{{ $provinceIndex }}][region]" value="{{ $province['region'] ?? '' }}" maxlength="16" required>
|
||||
</label>
|
||||
@foreach($provinceColumns as $column => $label)
|
||||
<label>{{ $label }}
|
||||
<input class="quote-change-price-input" type="number" min="0" step="0.0001" name="province_additions[{{ $provinceIndex }}][prices][{{ $column }}]" value="{{ $province['prices'][$column] ?? '' }}" required>
|
||||
<input class="quote-change-price-input" type="number" min="0" step="0.0001" @if($provinceIndex === '__INDEX__') data-field-name @else name @endif="province_additions[{{ $provinceIndex }}][prices][{{ $column }}]" value="{{ $province['prices'][$column] ?? '' }}" required>
|
||||
</label>
|
||||
@endforeach
|
||||
@if($provinceRemarks !== null)
|
||||
<label>报价备注
|
||||
<textarea class="quote-change-control" name="province_additions[{{ $provinceIndex }}][note]" maxlength="10000">{{ $province['note'] ?? '' }}</textarea>
|
||||
<textarea class="quote-change-control" @if($provinceIndex === '__INDEX__') data-field-name @else name @endif="province_additions[{{ $provinceIndex }}][note]" maxlength="10000">{{ $province['note'] ?? '' }}</textarea>
|
||||
</label>
|
||||
@endif
|
||||
<button type="button" class="quote-change-button" data-remove-province>移除</button>
|
||||
|
||||
@ -263,8 +263,9 @@ class CourierQuoteChangeWorkflowTest extends FeatureTestCase
|
||||
|
||||
$duplicate = $payload;
|
||||
$duplicate['province_additions'][0]['region'] = '江苏';
|
||||
$this->loginAs()->post(route('business.courier-quote-changes.store'), $duplicate)
|
||||
$this->withExceptionHandling()->loginAs()->post(route('business.courier-quote-changes.store'), $duplicate)
|
||||
->assertSessionHasErrors('province_additions.0.region');
|
||||
$this->withoutExceptionHandling();
|
||||
|
||||
$this->post(route('business.courier-quote-changes.store'), $payload)->assertSessionHasNoErrors();
|
||||
$change = CourierQuoteChange::firstOrFail();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user