feat(admin): 重复批量投递warning提供复制run_id按钮(复用copyToClipboard)
This commit is contained in:
@@ -1638,7 +1638,9 @@ class PlatformOrderController extends Controller
|
|||||||
if ($existing !== '' && str_starts_with($existing, 'BAS')) {
|
if ($existing !== '' && str_starts_with($existing, 'BAS')) {
|
||||||
$res = $res
|
$res = $res
|
||||||
->with('warning_link_href', '/admin/platform-batches/show?type=bas&run_id=' . urlencode($existing))
|
->with('warning_link_href', '/admin/platform-batches/show?type=bas&run_id=' . urlencode($existing))
|
||||||
->with('warning_link_label', '进入上次批次复盘');
|
->with('warning_link_label', '进入上次批次复盘')
|
||||||
|
->with('warning_copy_text', $existing)
|
||||||
|
->with('warning_copy_label', '复制run_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
@@ -1789,7 +1791,9 @@ class PlatformOrderController extends Controller
|
|||||||
if ($existing !== '' && str_starts_with($existing, 'BMPA')) {
|
if ($existing !== '' && str_starts_with($existing, 'BMPA')) {
|
||||||
$res = $res
|
$res = $res
|
||||||
->with('warning_link_href', '/admin/platform-batches/show?type=bmpa&run_id=' . urlencode($existing))
|
->with('warning_link_href', '/admin/platform-batches/show?type=bmpa&run_id=' . urlencode($existing))
|
||||||
->with('warning_link_label', '进入上次批次复盘');
|
->with('warning_link_label', '进入上次批次复盘')
|
||||||
|
->with('warning_copy_text', $existing)
|
||||||
|
->with('warning_copy_label', '复制run_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
|||||||
@@ -718,6 +718,30 @@
|
|||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// 通用:复制任意文本(用于 flash 提示中的“复制run_id”等)
|
||||||
|
(function(){
|
||||||
|
var btns = document.querySelectorAll('[data-action="copy-text"][data-copy-text]');
|
||||||
|
if(!btns || btns.length === 0){return;}
|
||||||
|
|
||||||
|
btns.forEach(function(btn){
|
||||||
|
btn.addEventListener('click', function(){
|
||||||
|
var text = btn.getAttribute('data-copy-text') || '';
|
||||||
|
var label = btn.getAttribute('data-copy-label') || '文本';
|
||||||
|
|
||||||
|
copyToClipboard(text).then(function(){
|
||||||
|
markCopied(btn, true);
|
||||||
|
toastCopied(label, text);
|
||||||
|
}).catch(function(){
|
||||||
|
markCopied(btn, false);
|
||||||
|
if (toastCopyFailed(label, '请手动复制:' + text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try { window.alert('复制失败,请手动复制:' + text); } catch (e) {}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
// 续费缺订阅治理:订单详情页“绑定订阅ID”输入框,小交互增强:
|
// 续费缺订阅治理:订单详情页“绑定订阅ID”输入框,小交互增强:
|
||||||
// - 输入后按 Enter 直接提交
|
// - 输入后按 Enter 直接提交
|
||||||
// - 自动聚焦,减少点击
|
// - 自动聚焦,减少点击
|
||||||
|
|||||||
@@ -97,10 +97,15 @@
|
|||||||
@php
|
@php
|
||||||
$flashWarningLinkHref = \App\Support\BackUrl::sanitizeForLinks((string) session('warning_link_href'));
|
$flashWarningLinkHref = \App\Support\BackUrl::sanitizeForLinks((string) session('warning_link_href'));
|
||||||
$flashWarningLinkLabel = (string) (session('warning_link_label') ?: '查看');
|
$flashWarningLinkLabel = (string) (session('warning_link_label') ?: '查看');
|
||||||
|
$flashWarningCopyText = (string) (session('warning_copy_text') ?: '');
|
||||||
|
$flashWarningCopyLabel = (string) (session('warning_copy_label') ?: '复制');
|
||||||
@endphp
|
@endphp
|
||||||
@if($flashWarningLinkHref !== '')
|
@if($flashWarningLinkHref !== '')
|
||||||
<a href="{{ $flashWarningLinkHref }}" class="btn btn-secondary btn-sm" style="margin-left:8px;">{{ $flashWarningLinkLabel }}</a>
|
<a href="{{ $flashWarningLinkHref }}" class="btn btn-secondary btn-sm" style="margin-left:8px;">{{ $flashWarningLinkLabel }}</a>
|
||||||
@endif
|
@endif
|
||||||
|
@if($flashWarningCopyText !== '')
|
||||||
|
<button type="button" class="btn btn-secondary btn-sm" style="margin-left:8px;" data-action="copy-text" data-copy-text="{{ $flashWarningCopyText }}" data-copy-label="{{ $flashWarningCopyLabel }}">{{ $flashWarningCopyLabel }}</button>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminFlashWarningShouldSupportCopyTextButtonTest 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_flash_warning_should_render_copy_text_button_when_session_keys_present(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$res = $this->withSession([
|
||||||
|
'warning' => '重复提交',
|
||||||
|
'warning_link_href' => '/admin/platform-batches/show?type=bas&run_id=BAS202603171234560001',
|
||||||
|
'warning_link_label' => '进入上次批次复盘',
|
||||||
|
'warning_copy_text' => 'BAS202603171234560001',
|
||||||
|
'warning_copy_label' => '复制run_id',
|
||||||
|
])->get('/admin');
|
||||||
|
|
||||||
|
$res->assertOk();
|
||||||
|
$res->assertSee('复制run_id');
|
||||||
|
$res->assertSee('data-action="copy-text"', false);
|
||||||
|
$res->assertSee('data-copy-text="BAS202603171234560001"', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user