fix: 报价重复推送显示原因并支持版本筛选 #1386
@ -32,7 +32,7 @@ final class CourierQuoteSignatureService
|
||||
|
||||
if ($existing && ! $existing->canSend()) {
|
||||
throw ValidationException::withMessages([
|
||||
'signature' => '该报价已经进入签署流程,签署原文不可重新生成。',
|
||||
'signature' => "报价版本 {$version->version_code} 当前为“{$existing->statusLabel()}”,不能重复推送。",
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -57,6 +57,19 @@
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.agreement-submit-error {
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--vip-danger, #B80000);
|
||||
border-radius: 8px;
|
||||
color: var(--vip-danger, #B80000);
|
||||
background: var(--agreement-surface);
|
||||
}
|
||||
|
||||
.agreement-submit-error ul {
|
||||
margin: 6px 0 0;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.supplier-contract-body { line-height: 1.8; }
|
||||
.supplier-contract-body .supplier-contract-heading { font-size: 14px; margin: 18px 0 8px; }
|
||||
.supplier-contract-paragraph { margin: 0 0 8px; overflow-wrap: anywhere; }
|
||||
@ -1330,6 +1343,13 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="agreement-submit-error" role="alert" tabindex="-1" data-agreement-submit-error>
|
||||
<strong>操作未完成:</strong>
|
||||
<ul>@foreach ($errors->all() as $error)<li>{{ $error }}</li>@endforeach</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="agreement-tabs">
|
||||
<div class="agreement-tab-list" role="tablist" aria-label="协议签署工作区">
|
||||
<button class="agreement-tab" type="button" role="tab" id="agreement-tab-tasks" aria-controls="agreement-panel-tasks" aria-selected="true" data-agreement-tab="tasks">
|
||||
@ -1725,6 +1745,8 @@
|
||||
<p class="agreement-help" data-account-operator-help>仅用于 E 签宝身份核验,不是收款人姓名;收款人姓名请填写在下方账户资料中。</p>
|
||||
</div>
|
||||
<div class="agreement-field" data-quote-confirmation-field hidden>
|
||||
<label for="agreement-quote-version-search">筛选报价版本</label>
|
||||
<input class="agreement-control" id="agreement-quote-version-search" type="search" placeholder="输入版本号、快递、报价类型或日期" autocomplete="off" aria-controls="agreement-quote-version" data-quote-version-search disabled>
|
||||
<label for="agreement-quote-version">报价版本 <span class="agreement-required" aria-hidden="true">*</span></label>
|
||||
<select class="agreement-control" id="agreement-quote-version" name="quote_version_id" data-quote-version disabled required>
|
||||
<option value="">请选择已审核报价版本</option>
|
||||
@ -1734,6 +1756,7 @@
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<p class="agreement-help" role="status" aria-live="polite" data-quote-version-count></p>
|
||||
<p class="agreement-help">确认单绑定已审核报价版本,生成后保存该版本快照;变价请生成新版本并重新签署。</p>
|
||||
</div>
|
||||
<div class="agreement-field" data-secondary-signer-fields hidden>
|
||||
@ -2417,6 +2440,11 @@
|
||||
var sharedCourierAdd = root.querySelector('[data-shared-courier-add]');
|
||||
var quoteVersionField = root.querySelector('[data-quote-confirmation-field]');
|
||||
var quoteVersionSelect = root.querySelector('[data-quote-version]');
|
||||
var quoteVersionSearch = root.querySelector('[data-quote-version-search]');
|
||||
var quoteVersionCount = root.querySelector('[data-quote-version-count]');
|
||||
var quoteVersionOptions = quoteVersionSelect ? Array.prototype.filter.call(quoteVersionSelect.options, function (option) {
|
||||
return option.value !== '';
|
||||
}) : [];
|
||||
var archiveFieldset = root.querySelector('[data-archive-fieldset]');
|
||||
var subjects = @json($agreementSubjectPayload);
|
||||
var fallbackSubjectName = @json(company()?->name ?: '当前公司');
|
||||
@ -3344,6 +3372,7 @@
|
||||
quoteVersionField.hidden = !quoteActive;
|
||||
quoteVersionSelect.disabled = !quoteActive;
|
||||
quoteVersionSelect.required = quoteActive;
|
||||
quoteVersionSearch.disabled = !quoteActive;
|
||||
if (!quoteActive) {
|
||||
quoteVersionSelect.value = '';
|
||||
}
|
||||
@ -3374,6 +3403,26 @@
|
||||
});
|
||||
}
|
||||
|
||||
function filterQuoteVersions() {
|
||||
var selectedValue = quoteVersionSelect.value;
|
||||
var courier = courierSelect.value;
|
||||
var keywords = quoteVersionSearch.value.trim().toLowerCase().split(/\s+/).filter(Boolean);
|
||||
var matches = quoteVersionOptions.filter(function (option) {
|
||||
return (!courier || option.dataset.carrier === courier) && keywords.every(function (keyword) {
|
||||
return option.textContent.toLowerCase().indexOf(keyword) !== -1;
|
||||
});
|
||||
});
|
||||
quoteVersionSelect.replaceChildren(new Option(matches.length ? '请选择已审核报价版本' : '没有匹配的已审核报价版本', ''));
|
||||
matches.forEach(function (option) {
|
||||
quoteVersionSelect.appendChild(option.cloneNode(true));
|
||||
});
|
||||
quoteVersionSelect.value = matches.some(function (option) { return option.value === selectedValue; }) ? selectedValue : '';
|
||||
quoteVersionCount.textContent = (courier ? '当前快递:' + courier + ',' : '') + '匹配 ' + matches.length + ' 个已审核版本';
|
||||
if (selectedValue && !quoteVersionSelect.value) {
|
||||
loadQuotePreview();
|
||||
}
|
||||
}
|
||||
|
||||
function quoteVersionOption() {
|
||||
if (!quoteVersionSelect || !quoteVersionSelect.value) {
|
||||
return null;
|
||||
@ -3467,6 +3516,9 @@
|
||||
function refreshPreview() {
|
||||
var documentOption = selectedDocument();
|
||||
var templateType = documentOption.value;
|
||||
if (templateType === 'quote-confirmation') {
|
||||
filterQuoteVersions();
|
||||
}
|
||||
var supplierContract = currentPartnerType === 'supplier' && templateType === 'cooperation-contract';
|
||||
var supplierUnavailable = currentPartnerType === 'supplier' && !supplierOptions.length;
|
||||
sendButton.disabled = !canOperate || supplierUnavailable || !esignAvailable;
|
||||
@ -3971,6 +4023,15 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (quoteVersionSearch) {
|
||||
quoteVersionSearch.addEventListener('keydown', function (event) {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault();
|
||||
quoteVersionSelect.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (esignAccountInput) {
|
||||
esignAccountInput.addEventListener('input', function () {
|
||||
delete esignAccountInput.dataset.autoFilled;
|
||||
@ -4129,6 +4190,11 @@
|
||||
if (initialUrl.searchParams.has('agreement_step')) {
|
||||
updateUrl(initialView, true);
|
||||
}
|
||||
|
||||
var submitError = root.querySelector('[data-agreement-submit-error]');
|
||||
if (submitError) {
|
||||
submitError.focus();
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</section>
|
||||
|
||||
@ -9,6 +9,7 @@ use App\Models\Business\CourierQuoteSignature;
|
||||
use App\Models\Business\CourierQuoteVersion;
|
||||
use App\Services\Esign\EsignClient;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Mockery;
|
||||
use Modules\EcommerceFinance\Repositories\CourierInformationMirrorRepository;
|
||||
use Modules\EcommerceFinance\Repositories\SupplierManagementMirrorRepository;
|
||||
@ -24,6 +25,47 @@ class AgreementSigningPageTest extends FeatureTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function test_duplicate_quote_push_displays_the_reason_on_the_returned_page(): void
|
||||
{
|
||||
$this->grantWorkspaceAccess();
|
||||
Http::preventStrayRequests();
|
||||
config([
|
||||
'services.esign.app_id' => 'test-app-id',
|
||||
'services.esign.app_secret' => 'test-app-secret',
|
||||
]);
|
||||
$signature = $this->createQuoteSignature('QB-DUPLICATE', CourierQuoteSignature::STATUS_ARCHIVED, '睢宁中通');
|
||||
$this->loginAs();
|
||||
$url = route('business.pages.show', [
|
||||
'section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'create',
|
||||
]);
|
||||
|
||||
$this->withExceptionHandling()->loginAs()->from($url)
|
||||
->post(route('business.courier-agreement-signatures.store'), [
|
||||
'idempotency_key' => 'duplicate-quote-push',
|
||||
'courier_name' => '睢宁中通',
|
||||
'document_type' => 'quote-confirmation',
|
||||
'quote_version_id' => $signature->quote_version_id,
|
||||
'signing_subject' => $this->company->name,
|
||||
'company_full_name' => $this->company->name,
|
||||
'signature_date' => now()->toDateString(),
|
||||
'signing_deadline' => now()->addDays(7)->toDateString(),
|
||||
'esign_account' => '13800138000',
|
||||
'counterparty_signer_type' => 'organization',
|
||||
'counterparty_organization_name' => '睢宁中通快递有限公司',
|
||||
'operator_name' => '张经理',
|
||||
'archive_mode' => 'auto',
|
||||
])
|
||||
->assertRedirect($url)
|
||||
->assertSessionHasErrors('signature');
|
||||
|
||||
$this->get($url)->assertOk()
|
||||
->assertSee('data-agreement-submit-error', false)
|
||||
->assertSeeText('报价版本 QB-DUPLICATE 当前为“已签署并归档”,不能重复推送。');
|
||||
Http::assertNothingSent();
|
||||
$this->assertSame(CourierQuoteSignature::STATUS_ARCHIVED, $signature->fresh()->status);
|
||||
$this->assertDatabaseCount('business_courier_quote_signatures', 1);
|
||||
}
|
||||
|
||||
public function testAgreementSigningPageRendersTheSigningWorkspace(): void
|
||||
{
|
||||
$this->grantWorkspaceAccess();
|
||||
@ -593,6 +635,8 @@ class AgreementSigningPageTest extends FeatureTestCase
|
||||
->assertSee('data-template-preview="cooperation-contract"', false)
|
||||
->assertSee('data-template-preview="quote-confirmation"', false)
|
||||
->assertSee('data-quote-version', false)
|
||||
->assertSee('data-quote-version-search', false)
|
||||
->assertSeeText('筛选报价版本')
|
||||
->assertSeeText('报价确认单')
|
||||
->assertSeeText('绑定已审核报价版本')
|
||||
->assertSeeText('甲方名称')
|
||||
|
||||
@ -585,7 +585,7 @@ class CourierQuoteSignatureWorkflowTest extends FeatureTestCase
|
||||
$this->fail('A sent quote must not regenerate its immutable source PDF.');
|
||||
} catch (\Illuminate\Validation\ValidationException $exception) {
|
||||
$this->assertSame(
|
||||
'该报价已经进入签署流程,签署原文不可重新生成。',
|
||||
"报价版本 {$signature->version->version_code} 当前为“待签署”,不能重复推送。",
|
||||
$exception->errors()['signature'][0],
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user