- 모델 6개 (Equipment, InspectionTemplate, Inspection, InspectionDetail, Repair, Process) - 서비스 3개 (Equipment, Inspection, Repair) - API 컨트롤러 3개 + FormRequest 4개 - Blade 컨트롤러 + 라우트 등록 - 뷰: 대시보드, 등록대장(CRUD), 일상점검표(캘린더 그리드), 수리이력
135 lines
6.2 KiB
PHP
135 lines
6.2 KiB
PHP
@extends('layouts.app')
|
|
@section('title', '수리이력 등록')
|
|
@section('content')
|
|
|
|
<div class="max-w-3xl mx-auto">
|
|
<div class="flex justify-between items-center mb-6">
|
|
<h1 class="text-2xl font-bold text-gray-800">수리이력 등록</h1>
|
|
<a href="{{ route('equipment.repairs') }}" class="text-gray-600 hover:text-gray-800">
|
|
← 목록으로
|
|
</a>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<form id="repairForm" class="space-y-4">
|
|
@csrf
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">
|
|
설비 <span class="text-red-500">*</span>
|
|
</label>
|
|
<select name="equipment_id" required
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
<option value="">선택</option>
|
|
@foreach($equipmentList as $eq)
|
|
<option value="{{ $eq->id }}">{{ $eq->equipment_code }} - {{ $eq->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">
|
|
수리일 <span class="text-red-500">*</span>
|
|
</label>
|
|
<input type="date" name="repair_date" required value="{{ now()->format('Y-m-d') }}"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">
|
|
보전구분 <span class="text-red-500">*</span>
|
|
</label>
|
|
<select name="repair_type" required
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
<option value="">선택</option>
|
|
<option value="internal">사내</option>
|
|
<option value="external">외주</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">수리시간 (h)</label>
|
|
<input type="number" name="repair_hours" min="0" step="0.5"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">수리내용</label>
|
|
<textarea name="description" rows="3"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">수리비용 (원)</label>
|
|
<input type="number" name="cost" min="0" step="1"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">외주업체</label>
|
|
<input type="text" name="vendor"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">수리자</label>
|
|
<select name="repaired_by"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
|
|
<option value="">선택</option>
|
|
@foreach($users as $user)
|
|
<option value="{{ $user->id }}">{{ $user->name }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="block text-sm font-semibold text-gray-700 mb-2">비고</label>
|
|
<textarea name="memo" rows="2"
|
|
class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"></textarea>
|
|
</div>
|
|
|
|
<div class="flex gap-3 pt-2">
|
|
<button type="submit" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg transition">
|
|
등록
|
|
</button>
|
|
<a href="{{ route('equipment.repairs') }}"
|
|
class="bg-gray-200 hover:bg-gray-300 text-gray-800 px-6 py-2 rounded-lg transition">
|
|
취소
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
document.getElementById('repairForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(this);
|
|
const data = Object.fromEntries(formData.entries());
|
|
|
|
fetch('/admin/equipment/repairs', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
|
'Accept': 'application/json',
|
|
},
|
|
body: JSON.stringify(data)
|
|
})
|
|
.then(r => r.json())
|
|
.then(data => {
|
|
if (data.success) {
|
|
showToast(data.message, 'success');
|
|
window.location.href = '{{ route("equipment.repairs") }}';
|
|
} else {
|
|
showToast(data.message || '등록에 실패했습니다.', 'error');
|
|
}
|
|
})
|
|
.catch(() => showToast('서버 오류가 발생했습니다.', 'error'));
|
|
});
|
|
</script>
|
|
@endpush
|