hotfix: 修复OA页面刷新路由缺失 #788
@ -23,6 +23,13 @@ class ProcessDetails extends Controller
|
||||
|
||||
public function show(Request $request)
|
||||
{
|
||||
if ($request->boolean('refresh_current')) {
|
||||
return $this->requestRefresh($request);
|
||||
}
|
||||
if ($request->filled('refresh_status')) {
|
||||
return $this->refreshStatus((string) $request->query('refresh_status'));
|
||||
}
|
||||
|
||||
$filters = $this->filters($request);
|
||||
$page = max((int) $request->query('page', 1), 1);
|
||||
$perPage = ProcessDetailsPageData::normalizePerPage($request->query('per_page'));
|
||||
@ -144,6 +151,11 @@ class ProcessDetails extends Controller
|
||||
|
||||
public function requestRefresh(Request $request): JsonResponse
|
||||
{
|
||||
$businessIds = $request->input('business_ids', $request->query('business_ids', []));
|
||||
if (is_string($businessIds)) {
|
||||
$businessIds = array_values(array_filter(array_map('trim', explode(',', $businessIds))));
|
||||
}
|
||||
$request->merge(['business_ids' => $businessIds]);
|
||||
$validated = $request->validate([
|
||||
'business_ids' => ['required', 'array', 'min:1', 'max:50'],
|
||||
'business_ids.*' => ['required', 'string', 'max:32', 'regex:/^[A-Za-z0-9_-]+$/'],
|
||||
|
||||
@ -23,19 +23,6 @@ Route::admin('ecommerce-finance', function (): void {
|
||||
->defaults('page', 'oa-process')
|
||||
->name('business.process-details.export');
|
||||
|
||||
Route::post('workspace/process-data/oa-process/refresh', [ProcessDetails::class, 'requestRefresh'])
|
||||
->middleware(['business.page.viewer', 'throttle:20,1'])
|
||||
->defaults('section', 'process-data')
|
||||
->defaults('page', 'oa-process')
|
||||
->name('business.process-details.refresh');
|
||||
|
||||
Route::get('workspace/process-data/oa-process/refresh/{token}', [ProcessDetails::class, 'refreshStatus'])
|
||||
->where('token', '[0-9a-fA-F-]{36}')
|
||||
->middleware(['business.page.viewer', 'throttle:120,1'])
|
||||
->defaults('section', 'process-data')
|
||||
->defaults('page', 'oa-process')
|
||||
->name('business.process-details.refresh-status');
|
||||
|
||||
Route::get('workspace/financial-operations/process-details', function (\Illuminate\Http\Request $request) {
|
||||
return redirect()->route('business.pages.show', array_merge($request->query(), [
|
||||
'section' => 'process-data',
|
||||
|
||||
@ -64,8 +64,8 @@
|
||||
->take(50)
|
||||
->values()
|
||||
->all();
|
||||
$refreshUrl = route('business.process-details.refresh');
|
||||
$refreshStatusUrl = route('business.process-details.refresh-status', ['token' => '__TOKEN__']);
|
||||
$refreshUrl = $pageUrl . '?refresh_current=1';
|
||||
$refreshStatusUrl = $pageUrl . '?refresh_status=__TOKEN__';
|
||||
$exportFilters = array_filter(
|
||||
$filters,
|
||||
static fn (mixed $value): bool => $value !== '' && $value !== null,
|
||||
@ -1000,6 +1000,7 @@
|
||||
window.fetch(statusUrl(token), {
|
||||
headers: { Accept: 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
cache: 'no-store',
|
||||
})
|
||||
.then((response) => {
|
||||
if (! response.ok) throw new Error('refresh status unavailable');
|
||||
@ -1035,15 +1036,11 @@
|
||||
}
|
||||
|
||||
setStatus('正在刷新当前页审批中的流程…');
|
||||
window.fetch(refreshUrl, {
|
||||
method: 'POST',
|
||||
const requestUrl = `${refreshUrl}&business_ids=${encodeURIComponent(businessIds.join(','))}`;
|
||||
window.fetch(requestUrl, {
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': window.Laravel?.csrfToken || '',
|
||||
},
|
||||
body: JSON.stringify({ business_ids: businessIds }),
|
||||
cache: 'no-store',
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
.then((response) => {
|
||||
if (! response.ok) throw new Error('refresh request rejected');
|
||||
|
||||
@ -176,12 +176,15 @@ class ProcessDetailsPageTest extends FeatureTestCase
|
||||
$this->app->instance(DingProcessDetailMirrorRepository::class, $repository);
|
||||
$this->app->instance(DingProcessRefreshQueue::class, $queue);
|
||||
|
||||
$this->loginAs()->postJson(route('business.process-details.refresh'), [
|
||||
'business_ids' => [
|
||||
'202601011200000000001',
|
||||
'202602031200000000002',
|
||||
],
|
||||
])->assertOk()
|
||||
$this->loginAs();
|
||||
$baseUrl = route('business.pages.show', [
|
||||
'section' => 'process-data',
|
||||
'page' => 'oa-process',
|
||||
]);
|
||||
$this->getJson($baseUrl . '?' . http_build_query([
|
||||
'refresh_current' => 1,
|
||||
'business_ids' => '202601011200000000001,202602031200000000002',
|
||||
]))->assertOk()
|
||||
->assertJson([
|
||||
'success' => true,
|
||||
'queued' => true,
|
||||
@ -189,8 +192,8 @@ class ProcessDetailsPageTest extends FeatureTestCase
|
||||
'count' => 1,
|
||||
]);
|
||||
|
||||
$this->getJson(route('business.process-details.refresh-status', [
|
||||
'token' => '00000000-0000-4000-8000-000000000001',
|
||||
$this->getJson($baseUrl . '?' . http_build_query([
|
||||
'refresh_status' => '00000000-0000-4000-8000-000000000001',
|
||||
]))->assertOk()
|
||||
->assertJsonPath('refresh.status', 'completed')
|
||||
->assertJsonPath('refresh.count', 1);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user