feat: [business-cards] 처리완료 삭제 기능 추가 및 기본 매수 500매로 변경

- 관리자 화면 처리완료 카드에 삭제 버튼 추가
- processed 상태만 삭제 가능 (서비스 검증)
- 파트너 명함신청 기본 매수 100매 → 500매 변경
This commit is contained in:
김보곤
2026-02-26 13:56:59 +09:00
parent b01d7a0ed6
commit 5793845def
5 changed files with 82 additions and 4 deletions

View File

@@ -124,4 +124,26 @@ public function process(Request $request, int $id)
return redirect()->route('sales.business-cards.manage')
->with('success', '처리가 완료되었습니다.');
}
/**
* 처리완료 건 삭제 (관리자 전용)
*/
public function destroy(Request $request, int $id)
{
if (! auth()->user()->isAdmin()) {
abort(403, '관리자만 삭제할 수 있습니다.');
}
$this->service->delete($id);
if ($request->expectsJson() || $request->header('Accept') === 'application/json') {
return response()->json([
'success' => true,
'message' => '삭제되었습니다.',
]);
}
return redirect()->route('sales.business-cards.manage')
->with('success', '삭제되었습니다.');
}
}

View File

@@ -119,6 +119,21 @@ public function process(int $id, ?string $memo = null): BusinessCardRequest
return $request;
}
/**
* 처리완료 건 삭제
*/
public function delete(int $id): void
{
$tenantId = session('selected_tenant_id', 1);
$request = BusinessCardRequest::ofTenant($tenantId)->findOrFail($id);
if ($request->status !== BusinessCardRequest::STATUS_PROCESSED) {
abort(422, '처리완료 상태만 삭제할 수 있습니다.');
}
$request->delete();
}
private function buildQuery(string $status, ?string $search)
{
$tenantId = session('selected_tenant_id', 1);

View File

@@ -207,6 +207,7 @@ class="px-3 py-1 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-med
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">의뢰일</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">처리일</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">처리자</th>
<th class="px-4 py-2 text-center text-xs font-medium text-gray-500 uppercase" style="width: 50px;"></th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@@ -231,10 +232,19 @@ class="px-3 py-1 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-med
<td class="px-4 py-2 text-xs text-gray-500">
{{ $req->processor?->name }}
</td>
<td class="px-4 py-2 text-center">
<button type="button"
onclick="deleteRequest({{ $req->id }}, '{{ $req->name }}')"
class="text-red-400 hover:text-red-600 transition" title="삭제">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</td>
</tr>
@empty
<tr>
<td colspan="6" class="px-4 py-6 text-center text-gray-500 text-sm">
<td colspan="7" class="px-4 py-6 text-center text-gray-500 text-sm">
처리된 명함 신청이 없습니다.
</td>
</tr>
@@ -312,5 +322,35 @@ function processRequest(id, name) {
{ title: '처리 완료', icon: 'question', confirmText: '처리완료' }
);
}
function deleteRequest(id, name) {
showConfirm(
`<strong>${name}</strong>님의 처리완료된 명함신청을 삭제하시겠습니까?`,
() => {
fetch(`/sales/business-cards/${id}`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Accept': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
showToast(data.message, 'success');
window.location.reload();
} else {
showToast(data.message || '삭제에 실패했습니다.', 'error');
}
})
.catch(error => {
showToast('서버 오류가 발생했습니다.', 'error');
console.error(error);
});
},
{ title: '삭제 확인', icon: 'warning', confirmText: '삭제' }
);
}
</script>
@endpush

View File

@@ -69,10 +69,10 @@ class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none foc
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">수량</label>
<input type="number" name="quantity" value="{{ old('quantity', 100) }}" min="1" max="9999"
<input type="number" name="quantity" value="{{ old('quantity', 500) }}" min="1" max="9999"
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
placeholder="100">
<p class="text-xs text-gray-400 mt-1">기본 100</p>
placeholder="500">
<p class="text-xs text-gray-400 mt-1">기본 500</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">메모</label>

View File

@@ -1298,6 +1298,7 @@
Route::get('business-cards/manage', [\App\Http\Controllers\Sales\BusinessCardRequestController::class, 'manage'])->name('business-cards.manage');
Route::post('business-cards/{id}/order', [\App\Http\Controllers\Sales\BusinessCardRequestController::class, 'order'])->name('business-cards.order');
Route::post('business-cards/{id}/process', [\App\Http\Controllers\Sales\BusinessCardRequestController::class, 'process'])->name('business-cards.process');
Route::delete('business-cards/{id}', [\App\Http\Controllers\Sales\BusinessCardRequestController::class, 'destroy'])->name('business-cards.destroy');
// 매니저 검색 (리소스 라우트보다 먼저 정의해야 함!)
Route::get('managers/list', [\App\Http\Controllers\Sales\SalesDashboardController::class, 'getManagers'])->name('managers.list');