|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
@extends('layouts.app')
|
|
|
|
|
|
|
|
|
|
@section('title', '차량 유지비')
|
|
|
|
|
@section('title', '법인차량 관리')
|
|
|
|
|
|
|
|
|
|
@push('styles')
|
|
|
|
|
<style>
|
|
|
|
|
@@ -46,13 +46,24 @@
|
|
|
|
|
const Car = createIcon('car');
|
|
|
|
|
|
|
|
|
|
function VehicleMaintenanceManagement() {
|
|
|
|
|
// 탭 상태
|
|
|
|
|
const [activeTab, setActiveTab] = useState('maintenance');
|
|
|
|
|
|
|
|
|
|
// 차량 목록 (동적 관리)
|
|
|
|
|
const [vehicles, setVehicles] = useState([
|
|
|
|
|
{ id: 1, plateNumber: '12가 3456', model: '제네시스 G80', ownershipType: 'corporate', purchaseDate: '2023-05-15', purchasePrice: '', currentMileage: 15000 },
|
|
|
|
|
{ id: 2, plateNumber: '34나 5678', model: '현대 스타렉스', ownershipType: 'corporate', purchaseDate: '2022-03-10', purchasePrice: '', currentMileage: 48000 },
|
|
|
|
|
{ id: 3, plateNumber: '56다 7890', model: '기아 레이', ownershipType: 'rent', contractDate: '2024-01-01', rentCompany: '롯데렌터카', rentCompanyTel: '1588-1234', rentPeriod: '36개월', agreedMileage: '30000', vehiclePrice: '25000000', residualValue: '15000000', deposit: '3000000', monthlyRent: '450000', monthlyRentTax: '45000', insuranceCompany: '삼성화재', insuranceCompanyTel: '1588-5114', currentMileage: 62000 },
|
|
|
|
|
{ id: 4, plateNumber: '78라 1234', model: '포터2', ownershipType: 'lease', contractDate: '2023-06-01', rentCompany: '현대캐피탈', rentCompanyTel: '1588-1234', rentPeriod: '48개월', agreedMileage: '60000', vehiclePrice: '32000000', residualValue: '12000000', deposit: '5000000', monthlyRent: '520000', monthlyRentTax: '52000', insuranceCompany: 'DB손해보험', insuranceCompanyTel: '1588-0100', currentMileage: 95000 },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const [maintenances, setMaintenances] = useState([
|
|
|
|
|
{ id: 1, date: '2026-01-20', vehicle: '12가 3456 (제네시스 G80)', category: '주유', description: '휘발유', amount: 120000, mileage: 15000, vendor: 'GS칼텍스', memo: '' },
|
|
|
|
|
{ id: 2, date: '2026-01-18', vehicle: '34나 5678 (현대 스타렉스)', category: '주유', description: '경유', amount: 95000, mileage: 48000, vendor: 'SK에너지', memo: '' },
|
|
|
|
|
{ id: 3, date: '2026-01-15', vehicle: '78라 1234 (포터2)', category: '정비', description: '엔진오일 교환', amount: 150000, mileage: 95000, vendor: '현대오토', memo: '정기 점검' },
|
|
|
|
|
{ id: 4, date: '2026-01-10', vehicle: '56다 7890 (기아 레이)', category: '보험', description: '자동차보험 연납', amount: 850000, mileage: 62000, vendor: '삼성화재', memo: '2025.01~2026.01' },
|
|
|
|
|
{ id: 5, date: '2026-01-05', vehicle: '12가 3456 (제네시스 G80)', category: '세차', description: '세차 및 실내크리닝', amount: 50000, mileage: 14500, vendor: '카와시', memo: '' },
|
|
|
|
|
{ id: 6, date: '2025-12-20', vehicle: '34나 5678 (현대 스타렉스)', category: '정비', description: '타이어 교체', amount: 480000, mileage: 45000, vendor: '한국타이어', memo: '4개 교체' },
|
|
|
|
|
{ id: 1, date: '2026-01-20', vehicleId: 1, category: '주유', description: '휘발유', amount: 120000, mileage: 15000, vendor: 'GS칼텍스', memo: '' },
|
|
|
|
|
{ id: 2, date: '2026-01-18', vehicleId: 2, category: '주유', description: '경유', amount: 95000, mileage: 48000, vendor: 'SK에너지', memo: '' },
|
|
|
|
|
{ id: 3, date: '2026-01-15', vehicleId: 4, category: '정비', description: '엔진오일 교환', amount: 150000, mileage: 95000, vendor: '현대오토', memo: '정기 점검' },
|
|
|
|
|
{ id: 4, date: '2026-01-10', vehicleId: 3, category: '보험', description: '자동차보험 연납', amount: 850000, mileage: 62000, vendor: '삼성화재', memo: '2025.01~2026.01' },
|
|
|
|
|
{ id: 5, date: '2026-01-05', vehicleId: 1, category: '세차', description: '세차 및 실내크리닝', amount: 50000, mileage: 14500, vendor: '카와시', memo: '' },
|
|
|
|
|
{ id: 6, date: '2025-12-20', vehicleId: 2, category: '정비', description: '타이어 교체', amount: 480000, mileage: 45000, vendor: '한국타이어', memo: '4개 교체' },
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const [searchTerm, setSearchTerm] = useState('');
|
|
|
|
|
@@ -67,12 +78,41 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
const [modalMode, setModalMode] = useState('add');
|
|
|
|
|
const [editingItem, setEditingItem] = useState(null);
|
|
|
|
|
|
|
|
|
|
// 차량 등록 모달
|
|
|
|
|
const [showVehicleModal, setShowVehicleModal] = useState(false);
|
|
|
|
|
const [vehicleModalMode, setVehicleModalMode] = useState('add');
|
|
|
|
|
const [editingVehicle, setEditingVehicle] = useState(null);
|
|
|
|
|
|
|
|
|
|
const categories = ['주유', '정비', '보험', '세차', '주차', '통행료', '검사', '기타'];
|
|
|
|
|
const vehicles = ['12가 3456 (제네시스 G80)', '34나 5678 (현대 스타렉스)', '56다 7890 (기아 레이)', '78라 1234 (포터2)'];
|
|
|
|
|
const ownershipTypes = [
|
|
|
|
|
{ value: 'corporate', label: '법인차량' },
|
|
|
|
|
{ value: 'rent', label: '렌트차량' },
|
|
|
|
|
{ value: 'lease', label: '리스차량' }
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 차량 표시용 헬퍼
|
|
|
|
|
const getVehicleDisplay = (vehicleId) => {
|
|
|
|
|
const v = vehicles.find(v => v.id === vehicleId);
|
|
|
|
|
return v ? `${v.plateNumber} (${v.model})` : '-';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getOwnershipLabel = (type) => {
|
|
|
|
|
const found = ownershipTypes.find(t => t.value === type);
|
|
|
|
|
return found ? found.label : type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getOwnershipColor = (type) => {
|
|
|
|
|
switch(type) {
|
|
|
|
|
case 'corporate': return 'bg-blue-100 text-blue-700';
|
|
|
|
|
case 'rent': return 'bg-purple-100 text-purple-700';
|
|
|
|
|
case 'lease': return 'bg-orange-100 text-orange-700';
|
|
|
|
|
default: return 'bg-gray-100 text-gray-700';
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const initialFormState = {
|
|
|
|
|
date: new Date().toISOString().split('T')[0],
|
|
|
|
|
vehicle: vehicles[0],
|
|
|
|
|
vehicleId: vehicles[0]?.id || '',
|
|
|
|
|
category: '주유',
|
|
|
|
|
description: '',
|
|
|
|
|
amount: '',
|
|
|
|
|
@@ -82,6 +122,30 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
};
|
|
|
|
|
const [formData, setFormData] = useState(initialFormState);
|
|
|
|
|
|
|
|
|
|
// 차량 등록 초기 상태
|
|
|
|
|
const initialVehicleFormState = {
|
|
|
|
|
plateNumber: '',
|
|
|
|
|
model: '',
|
|
|
|
|
ownershipType: 'corporate',
|
|
|
|
|
purchaseDate: '',
|
|
|
|
|
purchasePrice: '',
|
|
|
|
|
currentMileage: '',
|
|
|
|
|
// 렌트/리스 전용 필드
|
|
|
|
|
contractDate: '',
|
|
|
|
|
rentCompany: '',
|
|
|
|
|
rentCompanyTel: '',
|
|
|
|
|
rentPeriod: '',
|
|
|
|
|
agreedMileage: '',
|
|
|
|
|
vehiclePrice: '',
|
|
|
|
|
residualValue: '',
|
|
|
|
|
deposit: '',
|
|
|
|
|
monthlyRent: '',
|
|
|
|
|
monthlyRentTax: '',
|
|
|
|
|
insuranceCompany: '',
|
|
|
|
|
insuranceCompanyTel: ''
|
|
|
|
|
};
|
|
|
|
|
const [vehicleFormData, setVehicleFormData] = useState(initialVehicleFormState);
|
|
|
|
|
|
|
|
|
|
const formatCurrency = (num) => num ? num.toLocaleString() : '0';
|
|
|
|
|
const formatInputCurrency = (value) => {
|
|
|
|
|
if (!value && value !== 0) return '';
|
|
|
|
|
@@ -94,7 +158,7 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
const matchesSearch = item.description.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
|
|
|
item.vendor.toLowerCase().includes(searchTerm.toLowerCase());
|
|
|
|
|
const matchesCategory = filterCategory === 'all' || item.category === filterCategory;
|
|
|
|
|
const matchesVehicle = filterVehicle === 'all' || item.vehicle === filterVehicle;
|
|
|
|
|
const matchesVehicle = filterVehicle === 'all' || item.vehicleId === parseInt(filterVehicle);
|
|
|
|
|
const matchesDate = item.date >= dateRange.start && item.date <= dateRange.end;
|
|
|
|
|
return matchesSearch && matchesCategory && matchesVehicle && matchesDate;
|
|
|
|
|
});
|
|
|
|
|
@@ -104,24 +168,45 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
const maintenanceAmount = filteredMaintenances.filter(m => m.category === '정비').reduce((sum, item) => sum + item.amount, 0);
|
|
|
|
|
const otherAmount = totalAmount - fuelAmount - maintenanceAmount;
|
|
|
|
|
|
|
|
|
|
const handleAdd = () => { setModalMode('add'); setFormData(initialFormState); setShowModal(true); };
|
|
|
|
|
// 유지비 등록/수정
|
|
|
|
|
const handleAdd = () => { setModalMode('add'); setFormData({...initialFormState, vehicleId: vehicles[0]?.id || ''}); setShowModal(true); };
|
|
|
|
|
const handleEdit = (item) => { setModalMode('edit'); setEditingItem(item); setFormData({ ...item }); setShowModal(true); };
|
|
|
|
|
const handleSave = () => {
|
|
|
|
|
if (!formData.description || !formData.amount) { alert('필수 항목을 입력해주세요.'); return; }
|
|
|
|
|
const amount = parseInt(formData.amount) || 0;
|
|
|
|
|
const mileage = parseInt(formData.mileage) || 0;
|
|
|
|
|
if (modalMode === 'add') {
|
|
|
|
|
setMaintenances(prev => [{ id: Date.now(), ...formData, amount, mileage }, ...prev]);
|
|
|
|
|
setMaintenances(prev => [{ id: Date.now(), ...formData, vehicleId: parseInt(formData.vehicleId), amount, mileage }, ...prev]);
|
|
|
|
|
} else {
|
|
|
|
|
setMaintenances(prev => prev.map(item => item.id === editingItem.id ? { ...item, ...formData, amount, mileage } : item));
|
|
|
|
|
setMaintenances(prev => prev.map(item => item.id === editingItem.id ? { ...item, ...formData, vehicleId: parseInt(formData.vehicleId), amount, mileage } : item));
|
|
|
|
|
}
|
|
|
|
|
setShowModal(false); setEditingItem(null);
|
|
|
|
|
};
|
|
|
|
|
const handleDelete = (id) => { if (confirm('정말 삭제하시겠습니까?')) { setMaintenances(prev => prev.filter(item => item.id !== id)); setShowModal(false); } };
|
|
|
|
|
|
|
|
|
|
// 차량 등록/수정
|
|
|
|
|
const handleAddVehicle = () => { setVehicleModalMode('add'); setVehicleFormData(initialVehicleFormState); setShowVehicleModal(true); };
|
|
|
|
|
const handleEditVehicle = (vehicle) => { setVehicleModalMode('edit'); setEditingVehicle(vehicle); setVehicleFormData({ ...vehicle }); setShowVehicleModal(true); };
|
|
|
|
|
const handleSaveVehicle = () => {
|
|
|
|
|
if (!vehicleFormData.plateNumber || !vehicleFormData.model) { alert('차량번호와 모델명은 필수입니다.'); return; }
|
|
|
|
|
if (vehicleModalMode === 'add') {
|
|
|
|
|
setVehicles(prev => [{ id: Date.now(), ...vehicleFormData }, ...prev]);
|
|
|
|
|
} else {
|
|
|
|
|
setVehicles(prev => prev.map(v => v.id === editingVehicle.id ? { ...v, ...vehicleFormData } : v));
|
|
|
|
|
}
|
|
|
|
|
setShowVehicleModal(false); setEditingVehicle(null);
|
|
|
|
|
};
|
|
|
|
|
const handleDeleteVehicle = (id) => {
|
|
|
|
|
if (confirm('차량을 삭제하시겠습니까? 관련 유지비 기록도 함께 삭제됩니다.')) {
|
|
|
|
|
setVehicles(prev => prev.filter(v => v.id !== id));
|
|
|
|
|
setMaintenances(prev => prev.filter(m => m.vehicleId !== id));
|
|
|
|
|
setShowVehicleModal(false);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDownload = () => {
|
|
|
|
|
const rows = [['차량 유지비', `${dateRange.start} ~ ${dateRange.end}`], [], ['날짜', '차량', '구분', '내용', '금액', '주행거리', '업체'],
|
|
|
|
|
...filteredMaintenances.map(item => [item.date, item.vehicle, item.category, item.description, item.amount, item.mileage, item.vendor])];
|
|
|
|
|
...filteredMaintenances.map(item => [item.date, getVehicleDisplay(item.vehicleId), item.category, item.description, item.amount, item.mileage, item.vendor])];
|
|
|
|
|
const csvContent = rows.map(row => row.join(',')).join('\n');
|
|
|
|
|
const blob = new Blob(['\uFEFF' + csvContent], { type: 'text/csv;charset=utf-8;' });
|
|
|
|
|
const link = document.createElement('a'); link.href = URL.createObjectURL(blob); link.download = `차량유지비_${dateRange.start}_${dateRange.end}.csv`; link.click();
|
|
|
|
|
@@ -137,86 +222,172 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
<header className="bg-white border-b border-gray-200 rounded-t-xl mb-6">
|
|
|
|
|
<div className="px-6 py-4 flex items-center justify-between">
|
|
|
|
|
<div className="flex items-center gap-4">
|
|
|
|
|
<div className="p-2 bg-amber-100 rounded-xl"><Wrench className="w-6 h-6 text-amber-600" /></div>
|
|
|
|
|
<div><h1 className="text-xl font-bold text-gray-900">차량 유지비</h1><p className="text-sm text-gray-500">Vehicle Maintenance</p></div>
|
|
|
|
|
<div className="p-2 bg-amber-100 rounded-xl"><Car className="w-6 h-6 text-amber-600" /></div>
|
|
|
|
|
<div><h1 className="text-xl font-bold text-gray-900">법인차량 관리</h1><p className="text-sm text-gray-500">Corporate Vehicle Management</p></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<button onClick={handleDownload} className="flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"><Download className="w-4 h-4" /><span className="text-sm">Excel</span></button>
|
|
|
|
|
<button onClick={handleAdd} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">비용 등록</span></button>
|
|
|
|
|
{activeTab === 'maintenance' ? (
|
|
|
|
|
<>
|
|
|
|
|
<button onClick={handleDownload} className="flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg"><Download className="w-4 h-4" /><span className="text-sm">Excel</span></button>
|
|
|
|
|
<button onClick={handleAdd} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">비용 등록</span></button>
|
|
|
|
|
</>
|
|
|
|
|
) : (
|
|
|
|
|
<button onClick={handleAddVehicle} className="flex items-center gap-2 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg"><Plus className="w-4 h-4" /><span className="text-sm font-medium">차량 등록</span></button>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
{/* 탭 */}
|
|
|
|
|
<div className="px-6 flex gap-1">
|
|
|
|
|
<button onClick={() => setActiveTab('maintenance')} className={`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${activeTab === 'maintenance' ? 'bg-gray-50 text-amber-600 border-b-2 border-amber-500' : 'text-gray-500 hover:text-gray-700'}`}>
|
|
|
|
|
유지비 관리
|
|
|
|
|
</button>
|
|
|
|
|
<button onClick={() => setActiveTab('vehicles')} className={`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${activeTab === 'vehicles' ? 'bg-gray-50 text-amber-600 border-b-2 border-amber-500' : 'text-gray-500 hover:text-gray-700'}`}>
|
|
|
|
|
차량 등록
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">총 유지비</span><DollarSign className="w-5 h-5 text-gray-400" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-gray-900">{formatCurrency(totalAmount)}원</p>
|
|
|
|
|
<p className="text-xs text-gray-400 mt-1">{filteredMaintenances.length}건</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-amber-200 p-6 bg-amber-50/30">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-amber-700">주유비</span><Fuel className="w-5 h-5 text-amber-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-amber-600">{formatCurrency(fuelAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-blue-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">정비비</span><Wrench className="w-5 h-5 text-blue-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-blue-600">{formatCurrency(maintenanceAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">기타</span></div>
|
|
|
|
|
<p className="text-2xl font-bold text-gray-900">{formatCurrency(otherAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-4 mb-6">
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<Search className="w-5 h-5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" />
|
|
|
|
|
<input type="text" placeholder="내용, 업체 검색..." value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-amber-500" />
|
|
|
|
|
{/* 유지비 관리 탭 */}
|
|
|
|
|
{activeTab === 'maintenance' && (
|
|
|
|
|
<>
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">총 유지비</span><DollarSign className="w-5 h-5 text-gray-400" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-gray-900">{formatCurrency(totalAmount)}원</p>
|
|
|
|
|
<p className="text-xs text-gray-400 mt-1">{filteredMaintenances.length}건</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-amber-200 p-6 bg-amber-50/30">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-amber-700">주유비</span><Fuel className="w-5 h-5 text-amber-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-amber-600">{formatCurrency(fuelAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-blue-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">정비비</span><Wrench className="w-5 h-5 text-blue-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-blue-600">{formatCurrency(maintenanceAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-6">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-gray-500">기타</span></div>
|
|
|
|
|
<p className="text-2xl font-bold text-gray-900">{formatCurrency(otherAmount)}원</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<select value={filterVehicle} onChange={(e) => setFilterVehicle(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 차량</option>{vehicles.map(v => <option key={v} value={v}>{v}</option>)}</select>
|
|
|
|
|
<select value={filterCategory} onChange={(e) => setFilterCategory(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 구분</option>{categories.map(c => <option key={c} value={c}>{c}</option>)}</select>
|
|
|
|
|
<div className="flex items-center gap-2 md:col-span-2">
|
|
|
|
|
<input type="date" value={dateRange.start} onChange={(e) => setDateRange(prev => ({ ...prev, start: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
|
|
|
|
|
<span>~</span>
|
|
|
|
|
<input type="date" value={dateRange.end} onChange={(e) => setDateRange(prev => ({ ...prev, end: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
|
|
|
|
|
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 p-4 mb-6">
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-5 gap-4">
|
|
|
|
|
<div className="relative">
|
|
|
|
|
<Search className="w-5 h-5 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2" />
|
|
|
|
|
<input type="text" placeholder="내용, 업체 검색..." value={searchTerm} onChange={(e) => setSearchTerm(e.target.value)} className="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-amber-500" />
|
|
|
|
|
</div>
|
|
|
|
|
<select value={filterVehicle} onChange={(e) => setFilterVehicle(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg">
|
|
|
|
|
<option value="all">전체 차량</option>
|
|
|
|
|
{vehicles.map(v => <option key={v.id} value={v.id}>{v.plateNumber} ({v.model})</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
<select value={filterCategory} onChange={(e) => setFilterCategory(e.target.value)} className="px-3 py-2 border border-gray-300 rounded-lg"><option value="all">전체 구분</option>{categories.map(c => <option key={c} value={c}>{c}</option>)}</select>
|
|
|
|
|
<div className="flex items-center gap-2 md:col-span-2">
|
|
|
|
|
<input type="date" value={dateRange.start} onChange={(e) => setDateRange(prev => ({ ...prev, start: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
|
|
|
|
|
<span>~</span>
|
|
|
|
|
<input type="date" value={dateRange.end} onChange={(e) => setDateRange(prev => ({ ...prev, end: e.target.value }))} className="flex-1 px-2 py-2 border border-gray-300 rounded-lg text-sm" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
|
|
|
|
|
<table className="w-full">
|
|
|
|
|
<thead className="bg-gray-50 border-b border-gray-200">
|
|
|
|
|
<tr>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">날짜</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">내용</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">금액</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">주행거리</th>
|
|
|
|
|
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody className="divide-y divide-gray-100">
|
|
|
|
|
{filteredMaintenances.length === 0 ? (
|
|
|
|
|
<tr><td colSpan="7" className="px-6 py-12 text-center text-gray-400">데이터가 없습니다.</td></tr>
|
|
|
|
|
) : filteredMaintenances.map(item => (
|
|
|
|
|
<tr key={item.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEdit(item)}>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-gray-600">{item.date}</td>
|
|
|
|
|
<td className="px-6 py-4"><p className="text-sm font-medium text-gray-900">{item.vehicle.split(' (')[0]}</p><p className="text-xs text-gray-400">{item.vehicle.split(' (')[1]?.replace(')', '')}</p></td>
|
|
|
|
|
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getCategoryColor(item.category)}`}>{item.category}</span></td>
|
|
|
|
|
<td className="px-6 py-4"><p className="text-sm text-gray-900">{item.description}</p>{item.vendor && <p className="text-xs text-gray-400">{item.vendor}</p>}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm font-bold text-right text-amber-600">{formatCurrency(item.amount)}원</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(item.mileage)}km</td>
|
|
|
|
|
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
|
|
|
|
|
<button onClick={() => handleEdit(item)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
|
|
|
|
|
<button onClick={() => handleDelete(item.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
|
|
|
|
|
<table className="w-full">
|
|
|
|
|
<thead className="bg-gray-50 border-b border-gray-200">
|
|
|
|
|
<tr>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">날짜</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">내용</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">금액</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">주행거리</th>
|
|
|
|
|
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody className="divide-y divide-gray-100">
|
|
|
|
|
{filteredMaintenances.length === 0 ? (
|
|
|
|
|
<tr><td colSpan="7" className="px-6 py-12 text-center text-gray-400">데이터가 없습니다.</td></tr>
|
|
|
|
|
) : filteredMaintenances.map(item => {
|
|
|
|
|
const vehicle = vehicles.find(v => v.id === item.vehicleId);
|
|
|
|
|
return (
|
|
|
|
|
<tr key={item.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEdit(item)}>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-gray-600">{item.date}</td>
|
|
|
|
|
<td className="px-6 py-4">
|
|
|
|
|
<p className="text-sm font-medium text-gray-900">{vehicle?.plateNumber || '-'}</p>
|
|
|
|
|
<p className="text-xs text-gray-400">{vehicle?.model || ''}</p>
|
|
|
|
|
</td>
|
|
|
|
|
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getCategoryColor(item.category)}`}>{item.category}</span></td>
|
|
|
|
|
<td className="px-6 py-4"><p className="text-sm text-gray-900">{item.description}</p>{item.vendor && <p className="text-xs text-gray-400">{item.vendor}</p>}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm font-bold text-right text-amber-600">{formatCurrency(item.amount)}원</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(item.mileage)}km</td>
|
|
|
|
|
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
|
|
|
|
|
<button onClick={() => handleEdit(item)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
|
|
|
|
|
<button onClick={() => handleDelete(item.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* 차량 등록 탭 */}
|
|
|
|
|
{activeTab === 'vehicles' && (
|
|
|
|
|
<>
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 mb-6">
|
|
|
|
|
<div className="bg-white rounded-xl border border-blue-200 p-6 bg-blue-50/30">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-blue-700">법인차량</span><Car className="w-5 h-5 text-blue-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-blue-600">{vehicles.filter(v => v.ownershipType === 'corporate').length}대</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-purple-200 p-6 bg-purple-50/30">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-purple-700">렌트차량</span><Car className="w-5 h-5 text-purple-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-purple-600">{vehicles.filter(v => v.ownershipType === 'rent').length}대</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="bg-white rounded-xl border border-orange-200 p-6 bg-orange-50/30">
|
|
|
|
|
<div className="flex items-center justify-between mb-2"><span className="text-sm text-orange-700">리스차량</span><Car className="w-5 h-5 text-orange-500" /></div>
|
|
|
|
|
<p className="text-2xl font-bold text-orange-600">{vehicles.filter(v => v.ownershipType === 'lease').length}대</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 overflow-hidden">
|
|
|
|
|
<table className="w-full">
|
|
|
|
|
<thead className="bg-gray-50 border-b border-gray-200">
|
|
|
|
|
<tr>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">차량번호</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">모델명</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">구분</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">계약/구입일</th>
|
|
|
|
|
<th className="px-6 py-3 text-left text-xs font-semibold text-gray-600">렌트/리스사</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">월 렌트료</th>
|
|
|
|
|
<th className="px-6 py-3 text-right text-xs font-semibold text-gray-600">현재 주행거리</th>
|
|
|
|
|
<th className="px-6 py-3 text-center text-xs font-semibold text-gray-600">관리</th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody className="divide-y divide-gray-100">
|
|
|
|
|
{vehicles.length === 0 ? (
|
|
|
|
|
<tr><td colSpan="8" className="px-6 py-12 text-center text-gray-400">등록된 차량이 없습니다.</td></tr>
|
|
|
|
|
) : vehicles.map(vehicle => (
|
|
|
|
|
<tr key={vehicle.id} className="hover:bg-gray-50 cursor-pointer" onClick={() => handleEditVehicle(vehicle)}>
|
|
|
|
|
<td className="px-6 py-4 text-sm font-medium text-gray-900">{vehicle.plateNumber}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.model}</td>
|
|
|
|
|
<td className="px-6 py-4"><span className={`px-2 py-1 rounded text-xs font-medium ${getOwnershipColor(vehicle.ownershipType)}`}>{getOwnershipLabel(vehicle.ownershipType)}</span></td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.contractDate || vehicle.purchaseDate || '-'}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-gray-600">{vehicle.rentCompany || '-'}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm font-bold text-right text-purple-600">{vehicle.monthlyRent ? `${formatCurrency(parseInt(vehicle.monthlyRent))}원` : '-'}</td>
|
|
|
|
|
<td className="px-6 py-4 text-sm text-right text-gray-600">{formatCurrency(vehicle.currentMileage)}km</td>
|
|
|
|
|
<td className="px-6 py-4 text-center" onClick={(e) => e.stopPropagation()}>
|
|
|
|
|
<button onClick={() => handleEditVehicle(vehicle)} className="p-1 text-gray-400 hover:text-blue-500"><Edit className="w-4 h-4" /></button>
|
|
|
|
|
<button onClick={() => handleDeleteVehicle(vehicle.id)} className="p-1 text-gray-400 hover:text-rose-500"><Trash2 className="w-4 h-4" /></button>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
))}
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* 유지비 등록/수정 모달 */}
|
|
|
|
|
{showModal && (
|
|
|
|
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
|
|
|
|
<div className="bg-white rounded-xl p-6 w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto">
|
|
|
|
|
@@ -229,7 +400,11 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">날짜 *</label><input type="date" value={formData.date} onChange={(e) => setFormData(prev => ({ ...prev, date: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">구분</label><select value={formData.category} onChange={(e) => setFormData(prev => ({ ...prev, category: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{categories.map(c => <option key={c} value={c}>{c}</option>)}</select></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량</label><select value={formData.vehicle} onChange={(e) => setFormData(prev => ({ ...prev, vehicle: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">{vehicles.map(v => <option key={v} value={v}>{v}</option>)}</select></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량</label>
|
|
|
|
|
<select value={formData.vehicleId} onChange={(e) => setFormData(prev => ({ ...prev, vehicleId: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">
|
|
|
|
|
{vehicles.map(v => <option key={v.id} value={v.id}>{v.plateNumber} ({v.model})</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">내용 *</label><input type="text" value={formData.description} onChange={(e) => setFormData(prev => ({ ...prev, description: e.target.value }))} placeholder="내용" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">금액 *</label><input type="text" value={formatInputCurrency(formData.amount)} onChange={(e) => setFormData(prev => ({ ...prev, amount: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
@@ -241,13 +416,88 @@ function VehicleMaintenanceManagement() {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex gap-3 mt-6">
|
|
|
|
|
{modalMode === 'edit' && <button onClick={() => handleDelete(editingItem.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg flex items-center gap-2"><span>🗑️</span> 삭제</button>}
|
|
|
|
|
{modalMode === 'edit' && <button onClick={() => handleDelete(editingItem.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg">삭제</button>}
|
|
|
|
|
<button onClick={() => setShowModal(false)} className="flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50">취소</button>
|
|
|
|
|
<button onClick={handleSave} className="flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">{modalMode === 'add' ? '등록' : '저장'}</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* 차량 등록/수정 모달 */}
|
|
|
|
|
{showVehicleModal && (
|
|
|
|
|
<div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">
|
|
|
|
|
<div className="bg-white rounded-xl p-6 w-full max-w-2xl mx-4 max-h-[90vh] overflow-y-auto">
|
|
|
|
|
<div className="flex items-center justify-between mb-6">
|
|
|
|
|
<h3 className="text-lg font-bold text-gray-900">{vehicleModalMode === 'add' ? '차량 등록' : '차량 수정'}</h3>
|
|
|
|
|
<button onClick={() => setShowVehicleModal(false)} className="p-1 hover:bg-gray-100 rounded-lg"><X className="w-5 h-5 text-gray-500" /></button>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="space-y-4">
|
|
|
|
|
{/* 기본 정보 */}
|
|
|
|
|
<div className="grid grid-cols-3 gap-4">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량번호 *</label><input type="text" value={vehicleFormData.plateNumber} onChange={(e) => setVehicleFormData(prev => ({ ...prev, plateNumber: e.target.value }))} placeholder="12가 3456" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">모델명 *</label><input type="text" value={vehicleFormData.model} onChange={(e) => setVehicleFormData(prev => ({ ...prev, model: e.target.value }))} placeholder="제네시스 G80" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">구분 *</label>
|
|
|
|
|
<select value={vehicleFormData.ownershipType} onChange={(e) => setVehicleFormData(prev => ({ ...prev, ownershipType: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg">
|
|
|
|
|
{ownershipTypes.map(t => <option key={t.value} value={t.value}>{t.label}</option>)}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="grid grid-cols-2 gap-4">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">현재 주행거리 (km)</label><input type="text" value={formatInputCurrency(vehicleFormData.currentMileage)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, currentMileage: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
{vehicleFormData.ownershipType === 'corporate' && (
|
|
|
|
|
<>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">구입일</label><input type="date" value={vehicleFormData.purchaseDate} onChange={(e) => setVehicleFormData(prev => ({ ...prev, purchaseDate: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* 렌트/리스 전용 필드 */}
|
|
|
|
|
{(vehicleFormData.ownershipType === 'rent' || vehicleFormData.ownershipType === 'lease') && (
|
|
|
|
|
<>
|
|
|
|
|
<div className="border-t pt-4 mt-4">
|
|
|
|
|
<h4 className="text-sm font-semibold text-gray-900 mb-3">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'} 계약 정보</h4>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">계약일자</label><input type="date" value={vehicleFormData.contractDate} onChange={(e) => setVehicleFormData(prev => ({ ...prev, contractDate: e.target.value }))} className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}회사명</label><input type="text" value={vehicleFormData.rentCompany} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentCompany: e.target.value }))} placeholder="렌터카/리스사명" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4 mt-3">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}회사 연락처</label><input type="text" value={vehicleFormData.rentCompanyTel} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentCompanyTel: e.target.value }))} placeholder="02-1234-5678" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">{vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}기간</label><input type="text" value={vehicleFormData.rentPeriod} onChange={(e) => setVehicleFormData(prev => ({ ...prev, rentPeriod: e.target.value }))} placeholder="36개월" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4 mt-3">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">약정운행거리 (km)</label><input type="text" value={formatInputCurrency(vehicleFormData.agreedMileage)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, agreedMileage: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">차량가격 (원)</label><input type="text" value={formatInputCurrency(vehicleFormData.vehiclePrice)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, vehiclePrice: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4 mt-3">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">추정잔존가액 (원)</label><input type="text" value={formatInputCurrency(vehicleFormData.residualValue)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, residualValue: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">보증금 (원)</label><input type="text" value={formatInputCurrency(vehicleFormData.deposit)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, deposit: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4 mt-3">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">월 {vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}료 - 공급가액 (원)</label><input type="text" value={formatInputCurrency(vehicleFormData.monthlyRent)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, monthlyRent: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">월 {vehicleFormData.ownershipType === 'rent' ? '렌트' : '리스'}료 - 세액 (원)</label><input type="text" value={formatInputCurrency(vehicleFormData.monthlyRentTax)} onChange={(e) => setVehicleFormData(prev => ({ ...prev, monthlyRentTax: parseInputCurrency(e.target.value) }))} placeholder="0" className="w-full px-3 py-2 border border-gray-300 rounded-lg text-right" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="border-t pt-4 mt-4">
|
|
|
|
|
<h4 className="text-sm font-semibold text-gray-900 mb-3">보험 정보</h4>
|
|
|
|
|
<div className="grid grid-cols-2 gap-4">
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">보험사명</label><input type="text" value={vehicleFormData.insuranceCompany} onChange={(e) => setVehicleFormData(prev => ({ ...prev, insuranceCompany: e.target.value }))} placeholder="삼성화재" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
<div><label className="block text-sm font-medium text-gray-700 mb-1">보험사 연락처</label><input type="text" value={vehicleFormData.insuranceCompanyTel} onChange={(e) => setVehicleFormData(prev => ({ ...prev, insuranceCompanyTel: e.target.value }))} placeholder="1588-0000" className="w-full px-3 py-2 border border-gray-300 rounded-lg" /></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex gap-3 mt-6">
|
|
|
|
|
{vehicleModalMode === 'edit' && <button onClick={() => handleDeleteVehicle(editingVehicle.id)} className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg">삭제</button>}
|
|
|
|
|
<button onClick={() => setShowVehicleModal(false)} className="flex-1 px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50">취소</button>
|
|
|
|
|
<button onClick={handleSaveVehicle} className="flex-1 px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg">{vehicleModalMode === 'add' ? '등록' : '저장'}</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|