-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
646 lines (581 loc) · 30.6 KB
/
index.html
File metadata and controls
646 lines (581 loc) · 30.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>기간별 사용자 마일리지 신청서</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 20px;
background-color: #f4f4f4;
color: #333;
}
.container {
max-width: 900px; /* 테이블 포함으로 너비 확장 */
margin: auto;
background: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
display: flex; /* 폼과 테이블을 나란히 배치 */
flex-wrap: wrap; /* 반응형을 위해 wrap 설정 */
gap: 20px;
}
h1 {
text-align: center;
color: #2c3e50;
margin-bottom: 30px;
width: 100%; /* 제목은 전체 너비 사용 */
}
.form-section, .table-section {
flex: 1; /* 가용 공간을 균등하게 분할 */
min-width: 300px; /* 최소 너비 설정 */
}
.form-group {
margin-bottom: 20px;
padding-bottom: 15px;
border-bottom: 1px dashed #eee;
}
.form-group:last-of-type {
border-bottom: none;
padding-bottom: 0;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
.required-label::after {
content: ' *';
color: #e74c3c; /* 빨간색 별표 */
font-weight: bold;
margin-left: 3px;
}
input[type="text"],
input[type="date"],
textarea,
select {
width: calc(100% - 22px);
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
box-sizing: border-box;
}
input[type="radio"] {
margin-right: 5px;
}
.radio-group label {
display: inline-block;
margin-right: 20px;
font-weight: normal;
}
.radio-group input[type="radio"] + label {
font-weight: normal; /* 라디오 버튼 라벨 글씨 굵기 통일 */
}
.address-input-group {
display: flex;
gap: 5px;
}
.address-input-group input[type="text"] {
flex-grow: 1;
}
.address-input-group button {
width: auto;
white-space: nowrap;
padding: 8px 12px;
font-size: 0.9rem;
margin-top: 0;
}
.button-group {
margin-top: 20px;
text-align: right; /* 버튼 정렬 */
width: 100%;
}
input[type="submit"],
button {
background-color: #3498db;
color: white;
padding: 10px 18px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 0.95rem;
margin-left: 5px;
transition: background-color 0.3s ease;
}
input[type="submit"]:hover,
button:hover {
background-color: #2980b9;
}
button.secondary {
background-color: #7f8c8d;
}
button.secondary:hover {
background-color: #6c7a7e;
}
button.danger {
background-color: #e74c3c;
}
button.danger:hover {
background-color: #c0392b;
}
button.success {
background-color: #27ae60;
}
button.success:hover {
background-color: #229954;
}
button:disabled {
opacity: 0.6; /* 투명도를 낮춰 비활성화 상태를 더 명확히 */
background-color: #bdc3c7; /* 더 눈에 띄는 회색으로 변경 */
cursor: not-allowed; /* 마우스 커서를 변경하여 클릭 불가임을 표시 */
}
input:disabled {
background-color: #e9ecef;
cursor: not-allowed;
}
.note {
font-size: 0.9em;
color: #777;
margin-top: 5px;
}
/* Table Styles */
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th, td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
font-size: 0.9em;
}
th {
background-color: #ecf0f1;
font-weight: bold;
}
tbody tr:nth-child(even) {
background-color: #f9f9f9;
}
tbody tr:hover {
background-color: #f0f0f0;
cursor: pointer;
}
tbody tr.selected {
background-color: #dbe4f0; /* 선택된 행 배경색 */
font-weight: bold;
}
</style>
<!-- 다음 우편번호 서비스 스크립트 로드 -->
<script src="//t1.daumcdn.net/mapjsapi/bundle/postcode/prod/postcode.v2.js"></script>
</head>
<body>
<div class="container">
<h1>기간별 사용자 마일리지 신청서</h1>
<div class="form-section">
<form id="mileageApplicationForm">
<input type="hidden" id="editMileageId" value=""> <!-- 수정 모드일 때 ID 저장 -->
<div class="form-group">
<label for="companyProjectName" class="required-label">고객사(프로젝트)명</label>
<input type="text" id="companyProjectName" name="companyProjectName" maxlength="100" placeholder="예: (주)알파프로젝트" required>
</div>
<div class="form-group">
<label class="required-label">구분</label>
<div class="radio-group">
<input type="radio" id="oneWay" name="tripType" value="편도">
<label for="oneWay">편도</label>
<input type="radio" id="roundTrip" name="tripType" value="왕복" checked required>
<label for="roundTrip">왕복</label>
</div>
</div>
<div class="form-group">
<label for="tripDate" class="required-label">일자</label>
<input type="date" id="tripDate" name="tripDate" required>
</div>
<div class="form-group">
<label class="required-label">출발지</label>
<div class="radio-group">
<input type="radio" id="startOffice" name="startLocationType" value="사무실" checked>
<label for="startOffice">사무실</label>
<input type="radio" id="startCustom" name="startLocationType" value="직접입력">
<label for="startCustom">직접 입력</label>
</div>
<div class="address-input-group">
<input type="text" id="startLocationAddress" name="startLocationAddress" placeholder="사무실 주소 또는 검색된 주소" readonly required>
<button type="button" id="searchStartAddrBtn" class="secondary" disabled>주소 검색</button>
</div>
<input type="hidden" id="startLocationFullAddress" name="startLocationFullAddress"> <!-- 전체 도로명 주소 숨김 필드 -->
<p class="note">주소 검색 버튼을 눌러 정확한 주소를 입력해주세요.</p>
</div>
<div class="form-group">
<label for="destinationAddress" class="required-label">목적지</label>
<div class="address-input-group">
<input type="text" id="destinationAddress" name="destinationAddress" placeholder="목적지 주소" readonly required>
<button type="button" id="searchDestAddrBtn" class="secondary">주소 검색</button>
</div>
<input type="hidden" id="destinationFullAddress" name="destinationFullAddress"> <!-- 전체 도로명 주소 숨김 필드 -->
<p class="note">주소 검색 버튼을 눌러 정확한 주소를 입력해주세요.</p>
</div>
<div class="form-group">
<label for="distance">거리(km)</label>
<input type="text" id="distance" name="distance" value="0" disabled>
<p class="note">네이버 지도 API와 연동하여 자동 처리됩니다.</p>
</div>
<div class="form-group">
<label for="mileageAmount">마일리지(원)</label>
<input type="text" id="mileageAmount" name="mileageAmount" value="0" disabled>
<p class="note">네이버 지도 API와 연동하여 자동 처리됩니다.</p>
</div>
<div class="form-group">
<label class="required-label">교통수단</label>
<div class="radio-group">
<input type="radio" id="publicTransport" name="transportation" value="대중교통" checked required>
<label for="publicTransport">대중교통</label>
<input type="radio" id="privateCar" name="transportation" value="개인차량" required>
<label for="privateCar">개인차량</label>
</div>
</div>
<div class="form-group">
<label for="passengers">동승자</label>
<input type="text" id="passengers" name="passengers" placeholder="예: 홍길동, 김철수 (콤마로 구분)" disabled>
<p class="note">교통수단이 '개인차량'인 경우에만 입력 가능합니다.</p>
</div>
<div class="form-group">
<label class="required-label">방문목적</label>
<div class="radio-group">
<input type="radio" id="purposeRegularCheck" name="visitPurpose" value="정기점검" checked required>
<label for="purposeRegularCheck">정기점검</label>
<input type="radio" id="purposeMeeting" name="visitPurpose" value="회의" required>
<label for="purposeMeeting">회의</label>
<input type="radio" id="purposeTroubleshoot" name="visitPurpose" value="장애처리" required>
<label for="purposeTroubleshoot">장애처리</label>
<input type="radio" id="purposeOther" name="visitPurpose" value="기타" required>
<label for="purposeOther">기타</label>
</div>
<input type="text" id="otherPurposeDetail" name="otherPurposeDetail" placeholder="기타 방문목적 입력" disabled>
</div>
<div class="form-group">
<label for="processingResult">처리결과</label>
<input type="text" id="processingResult" name="processingResult" value="대기중" disabled>
<p class="note">관리자가 처리 후 수정하는 항목입니다.</p>
</div>
<div class="button-group">
<button type="submit" id="submitButton" class="success">신청하기</button>
<button type="button" id="resetFormButton" class="secondary">초기화</button>
</div>
</form>
</div>
<div class="table-section">
<h2>신청 내역 조회</h2>
<div class="button-group">
<button type="button" id="editEntryButton" class="secondary">수정</button>
<button type="button" id="deleteEntryButton" class="danger">삭제</button>
</div>
<table>
<thead>
<tr>
<th>고객사</th>
<th>구분</th>
<th>일자</th>
<th>출발지</th>
<th>목적지</th>
<th>교통수단</th>
<th>동승자</th>
<th>방문목적</th>
<th>처리결과</th>
</tr>
</thead>
<tbody id="mileageTableBody">
<!-- 데이터가 여기에 로드됩니다 -->
</tbody>
</table>
</div>
</div>
<script>
let mileageData = []; // 마일리지 데이터를 저장할 배열
let nextMileageId = 1; // 고유 ID 생성용
let selectedRowId = null; // 현재 선택된 테이블 행의 ID
let currentTargetAddressField = null; // 현재 주소 팝업을 띄운 대상 필드 ('start' 또는 'destination')
// 사무실 주소 정의
const OFFICE_FULL_ADDRESS = '서울시 강서구 양천로 583';
// 사무실 도로명 주소만 (화면에 표시할 용도)
const OFFICE_DISPLAY_ADDRESS = '양천로 583';
document.addEventListener('DOMContentLoaded', function() {
loadMileageData(); // 초기 데이터 로드 (빈 테이블 또는 샘플 데이터)
// === 출발지 라디오 버튼 이벤트 리스너 ===
const startLocationTypeRadios = document.querySelectorAll('input[name="startLocationType"]');
const startLocationAddressInput = document.getElementById('startLocationAddress');
const searchStartAddrBtn = document.getElementById('searchStartAddrBtn');
const startLocationFullAddressInput = document.getElementById('startLocationFullAddress'); // 숨김 필드
startLocationTypeRadios.forEach(radio => {
radio.addEventListener('change', function() {
if (this.value === '직접입력') {
searchStartAddrBtn.disabled = false; // 주소 검색 버튼 활성화
startLocationAddressInput.value = ''; // 기존 주소 초기화
startLocationFullAddressInput.value = ''; // 전체 주소 초기화
} else { // 사무실 선택 시
searchStartAddrBtn.disabled = true; // 주소 검색 버튼 비활성화
startLocationAddressInput.value = OFFICE_DISPLAY_ADDRESS;
startLocationFullAddressInput.value = OFFICE_FULL_ADDRESS;
}
});
});
// 초기 로드 시 '사무실' 선택되어 있으므로 한 번 실행하여 기본값 설정
document.querySelector('input[name="startLocationType"]:checked').dispatchEvent(new Event('change'));
// === 주소 검색 버튼 이벤트 리스너 ===
document.getElementById('searchStartAddrBtn').addEventListener('click', function() {
currentTargetAddressField = 'start'; // 현재 검색 대상이 출발지임을 표시
openDaumPostcode();
});
document.getElementById('searchDestAddrBtn').addEventListener('click', function() {
currentTargetAddressField = 'destination'; // 현재 검색 대상이 목적지임을 표시
openDaumPostcode();
});
// === 교통수단 라디오 버튼 이벤트 리스너 ===
const transportationRadios = document.querySelectorAll('input[name="transportation"]');
const passengersInput = document.getElementById('passengers');
transportationRadios.forEach(radio => {
radio.addEventListener('change', function() {
if (this.value === '개인차량') {
passengersInput.disabled = false;
passengersInput.focus();
} else {
passengersInput.disabled = true;
passengersInput.value = '';
}
});
});
// === 방문목적 라디오 버튼 이벤트 리스너 ===
const visitPurposeRadios = document.querySelectorAll('input[name="visitPurpose"]');
const otherPurposeDetailInput = document.getElementById('otherPurposeDetail');
visitPurposeRadios.forEach(radio => {
radio.addEventListener('change', function() {
if (this.value === '기타') {
otherPurposeDetailInput.disabled = false;
otherPurposeDetailInput.focus();
} else {
otherPurposeDetailInput.disabled = true;
otherPurposeDetailInput.value = '';
}
});
});
// === 폼 제출 이벤트 리스너 (신청 또는 수정) ===
document.getElementById('mileageApplicationForm').addEventListener('submit', function(event) {
event.preventDefault();
const form = event.target;
const newMileageEntry = {
companyProjectName: form.companyProjectName.value,
tripType: document.querySelector('input[name="tripType"]:checked').value, // 라디오 그룹 처리
tripDate: form.tripDate.value,
startLocationType: document.querySelector('input[name="startLocationType"]:checked').value, // 라디오 그룹 처리
startLocationAddress: form.startLocationAddress.value, // 화면 표시 주소
startLocationFullAddress: form.startLocationFullAddress.value, // 전체 주소 (숨김 필드)
destinationAddress: form.destinationAddress.value, // 화면 표시 주소
destinationFullAddress: form.destinationFullAddress.value, // 전체 주소 (숨김 필드)
distance: parseFloat(form.distance.value),
mileageAmount: parseFloat(form.mileageAmount.value),
transportation: document.querySelector('input[name="transportation"]:checked').value, // 라디오 그룹 처리
passengers: form.passengers.disabled ? '' : form.passengers.value,
visitPurpose: document.querySelector('input[name="visitPurpose"]:checked').value, // 라디오 그룹 처리
otherPurposeDetail: form.otherPurposeDetail.disabled ? '' : form.otherPurposeDetail.value,
processingResult: form.processingResult.value
};
// 주소 입력 필수 검증 (화면 표시 주소로 검증)
if (!newMileageEntry.startLocationAddress) {
alert("출발지 주소를 검색해주세요.");
return;
}
if (!newMileageEntry.destinationAddress) {
alert("목적지 주소를 검색해주세요.");
return;
}
const editId = document.getElementById('editMileageId').value;
if (editId) {
const index = mileageData.findIndex(item => item.id == editId);
if (index !== -1) {
mileageData[index] = { ...mileageData[index], ...newMileageEntry };
alert("신청 내역이 수정되었습니다.");
}
} else {
newMileageEntry.id = nextMileageId++;
mileageData.push(newMileageEntry);
alert("신청이 완료되었습니다. (실제 데이터 저장은 추후 구현 예정)");
}
resetForm();
loadMileageData();
});
// === 초기화 버튼 이벤트 리스너 ===
document.getElementById('resetFormButton').addEventListener('click', resetForm);
// === 수정 버튼 이벤트 리스너 ===
document.getElementById('editEntryButton').addEventListener('click', function() {
if (selectedRowId === null) {
alert("수정할 항목을 테이블에서 선택해주세요.");
return;
}
editMileageEntry(selectedRowId);
});
// === 삭제 버튼 이벤트 리스너 ===
document.getElementById('deleteEntryButton').addEventListener('click', function() {
if (selectedRowId === null) {
alert("삭제할 항목을 테이블에서 선택해주세요.");
return;
}
if (confirm("선택된 항목을 삭제하시겠습니까?")) {
deleteMileageEntry(selectedRowId);
}
});
}); // DOMContentLoaded 끝
// === 다음 우편번호 서비스 팝업 오픈 함수 ===
function openDaumPostcode() {
new daum.Postcode({
oncomplete: function(data) {
var fullAddr = ''; // hidden field에 저장할 전체 주소 (도로명, 건물번호 등)
var displayAddr = ''; // 화면에 표시할 주소 (도로명, 건물번호)
if (data.userSelectedType === 'R') { // 사용자가 도로명 주소를 선택했을 경우
if (data.roadAddress) { // 도로명 주소가 있을 경우
// hidden field에 저장할 주소는 '시도 시군구'를 제외한 '도로명 건물번호'로 설정
// data.roadname (도로명), data.bname (법정동), data.buildingName (건물명), data.apartment (공동주택 여부)
// data.roadAddress (전체 도로명 주소: 시도 시군구 도로명 건물번호(건물명))
// '시도 시군구'를 제외한 부분만 추출
let tempAddr = data.roadAddress;
if (data.sido) tempAddr = tempAddr.replace(data.sido, '').trim();
if (data.sigungu) tempAddr = tempAddr.replace(data.sigungu, '').trim();
fullAddr = data.roadname;
displayAddr = tempAddr; // "양천로 583 (가양동)"
}
} else if (data.userSelectedType === 'J') { // 사용자가 지번 주소를 선택했을 경우
fullAddr = data.jibunAddress;
displayAddr = data.jibunAddress;
}
if (currentTargetAddressField === 'start') {
document.getElementById('startLocationAddress').value = displayAddr; // 화면 표시
document.getElementById('startLocationFullAddress').value = fullAddr; // 숨김 필드에 전체 저장
} else if (currentTargetAddressField === 'destination') {
document.getElementById('destinationAddress').value = displayAddr; // 화면 표시
document.getElementById('destinationFullAddress').value = fullAddr; // 숨김 필드에 전체 저장
}
}
}).open();
}
// === 데이터 테이블 로드 및 업데이트 함수 (조회 기능) ===
function loadMileageData() {
const tableBody = document.getElementById('mileageTableBody');
tableBody.innerHTML = '';
if (mileageData.length === 0) {
const noDataRow = tableBody.insertRow();
noDataRow.innerHTML = '<td colspan="9" style="text-align:center;">신청된 마일리지 내역이 없습니다.</td>';
return;
}
mileageData.forEach(entry => {
const row = tableBody.insertRow();
row.dataset.id = entry.id;
row.insertCell().textContent = entry.companyProjectName;
row.insertCell().textContent = entry.tripType;
row.insertCell().textContent = entry.tripDate;
// 테이블에는 화면 표시 주소를 사용
row.insertCell().textContent = entry.startLocationAddress;
row.insertCell().textContent = entry.destinationAddress;
row.insertCell().textContent = entry.transportation;
row.insertCell().textContent = entry.passengers || '-';
row.insertCell().textContent = entry.visitPurpose === '기타' ? `${entry.visitPurpose} (${entry.otherPurposeDetail})` : entry.visitPurpose;
row.insertCell().textContent = entry.processingResult;
row.addEventListener('click', function() {
const currentSelected = document.querySelector('#mileageTableBody .selected');
if (currentSelected) {
currentSelected.classList.remove('selected');
}
this.classList.add('selected');
selectedRowId = this.dataset.id;
});
});
if (selectedRowId !== null) {
const rowToSelect = document.querySelector(`#mileageTableBody tr[data-id="${selectedRowId}"]`);
if (rowToSelect) {
rowToSelect.classList.add('selected');
} else {
selectedRowId = null;
}
}
}
// === 폼 초기화 함수 ===
function resetForm() {
document.getElementById('mileageApplicationForm').reset();
// 주소 필드 초기화
document.getElementById('startLocationAddress').value = '';
document.getElementById('startLocationFullAddress').value = '';
document.getElementById('destinationAddress').value = '';
document.getElementById('destinationFullAddress').value = '';
// 라디오 버튼 기본값으로 돌리고 이벤트 강제 발생
document.getElementById('oneWay').checked = false; // 명시적으로 비선택
document.getElementById('roundTrip').checked = true; // 왕복으로 초기화
document.getElementById('publicTransport').checked = true;
document.getElementById('purposeRegularCheck').checked = true;
document.getElementById('startOffice').checked = true;
document.getElementById('startOffice').dispatchEvent(new Event('change')); // 사무실 주소로 초기화 (자동으로 '사무실' 주소 채워짐)
document.getElementById('passengers').disabled = true;
document.getElementById('passengers').value = '';
document.getElementById('otherPurposeDetail').disabled = true;
document.getElementById('otherPurposeDetail').value = '';
document.getElementById('editMileageId').value = '';
document.getElementById('submitButton').textContent = '신청하기';
document.getElementById('submitButton').classList.remove('secondary');
document.getElementById('submitButton').classList.add('success');
const currentSelected = document.querySelector('#mileageTableBody .selected');
if (currentSelected) {
currentSelected.classList.remove('selected');
}
selectedRowId = null;
}
// === 데이터 수정 (폼에 로드) 함수 ===
function editMileageEntry(id) {
const entry = mileageData.find(item => item.id == id);
if (!entry) return;
const form = document.getElementById('mileageApplicationForm');
form.companyProjectName.value = entry.companyProjectName;
// 구분 라디오 버튼 상태 복원
document.getElementById(entry.tripType === '편도' ? 'oneWay' : 'roundTrip').checked = true;
form.tripDate.value = entry.tripDate;
// 출발지 로딩 (사무실/직접입력 라디오 상태와 주소 복원)
document.getElementById(entry.startLocationType === '사무실' ? 'startOffice' : 'startCustom').checked = true;
document.querySelector(`input[name="startLocationType"][value="${entry.startLocationType}"]`).dispatchEvent(new Event('change'));
form.startLocationAddress.value = entry.startLocationAddress;
form.startLocationFullAddress.value = entry.startLocationFullAddress;
// 목적지 로딩
form.destinationAddress.value = entry.destinationAddress;
form.destinationFullAddress.value = entry.destinationFullAddress;
form.distance.value = entry.distance;
form.mileageAmount.value = entry.mileageAmount;
// 교통수단 라디오 버튼 상태 복원 및 동승자 필드 제어
document.getElementById(entry.transportation === '대중교통' ? 'publicTransport' : 'privateCar').checked = true;
document.querySelector(`input[name="transportation"][value="${entry.transportation}"]`).dispatchEvent(new Event('change'));
if (entry.transportation === '개인차량') {
form.passengers.value = entry.passengers;
}
const purposeIdMap = { '정기점검': 'purposeRegularCheck', '회의': 'purposeMeeting', '장애처리': 'purposeTroubleshoot', '기타': 'purposeOther' };
document.getElementById(purposeIdMap[entry.visitPurpose]).checked = true;
document.querySelector(`input[name="visitPurpose"][value="${entry.visitPurpose}"]`).dispatchEvent(new Event('change'));
if (entry.visitPurpose === '기타') {
form.otherPurposeDetail.value = entry.otherPurposeDetail;
}
form.processingResult.value = entry.processingResult;
document.getElementById('editMileageId').value = id;
document.getElementById('submitButton').textContent = '저장하기';
document.getElementById('submitButton').classList.remove('success');
document.getElementById('submitButton').classList.add('secondary');
window.scrollTo({ top: 0, behavior: 'smooth' });
}
// === 데이터 삭제 함수 ===
function deleteMileageEntry(id) {
mileageData = mileageData.filter(item => item.id != id);
alert("선택된 신청 내역이 삭제되었습니다.");
resetForm();
loadMileageData();
}
</script>
</body>
</html>