chore(admin-platform-order): disable on submit for add receipt forms

This commit is contained in:
萝卜
2026-03-16 14:33:15 +08:00
parent 2507ab235b
commit 10108ddecd
2 changed files with 75 additions and 2 deletions

View File

@@ -622,7 +622,7 @@
<details class="mt-12" id="add-payment-receipt">
<summary class="muted">追加一条支付回执(不自动改状态)</summary>
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-payment-receipt" class="mt-10">
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-payment-receipt" class="mt-10" data-action="disable-on-submit">
@csrf
<div class="grid-3">
<input type="text" name="type" placeholder="类型bank_transfer/现金/支付宝等" value="bank_transfer">
@@ -693,7 +693,7 @@
<details class="mt-12">
<summary class="muted">追加一条退款记录(会自动推进支付状态)</summary>
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-refund-receipt" class="mt-10" onsubmit="return confirm('确认追加退款记录?该操作会写入退款轨迹,并可能推进支付状态为部分退款/已退款');">
<form method="post" action="/admin/platform-orders/{{ $order->id }}/add-refund-receipt" class="mt-10" data-action="disable-on-submit" onsubmit="return confirm('确认追加退款记录?该操作会写入退款轨迹,并可能推进支付状态为部分退款/已退款');">
@csrf
<div class="grid-3">
<input type="text" name="type" placeholder="类型refund/chargeback/手工退款等" value="refund">

View File

@@ -0,0 +1,73 @@
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderShowAddReceiptsFormsShouldDisableOnSubmitTest extends TestCase
{
use RefreshDatabase;
protected function loginAsPlatformAdmin(): void
{
$this->seed();
$this->post('/admin/login', [
'email' => 'platform.admin@demo.local',
'password' => 'Platform@123456',
])->assertRedirect('/admin');
}
public function test_show_add_receipts_forms_should_disable_on_submit(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'add_receipt_disable_submit_01',
'name' => '回执表单禁用提交测试',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_ADD_RECEIPT_DISABLE_SUBMIT_0001',
'order_type' => 'new_purchase',
'status' => 'pending',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'meta' => [],
]);
$html = $this->get('/admin/platform-orders/' . $order->id)
->assertOk()
->getContent();
$this->assertIsString($html);
// 追加支付回执
$this->assertStringContainsString('/admin/platform-orders/' . $order->id . '/add-payment-receipt', $html);
$this->assertStringContainsString('data-action="disable-on-submit"', $html);
// 追加退款记录
$this->assertStringContainsString('/admin/platform-orders/' . $order->id . '/add-refund-receipt', $html);
$this->assertStringContainsString('data-action="disable-on-submit"', $html);
}
}