|
47 | 47 | background: white; |
48 | 48 | border-radius: 12px; |
49 | 49 | padding: 24px; |
50 | | - margin-bottom: 16px; /* Giảm margin để nhường chỗ cho summary */ |
| 50 | + margin-bottom: 16px; |
51 | 51 | box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); |
52 | 52 | } |
53 | 53 |
|
|
265 | 265 | <div class="container"> |
266 | 266 | <div class="search-section"> |
267 | 267 | <div class="search-grid"> |
268 | | - <!-- HTML MỚI: Thêm ô tìm kiếm SBD --> |
269 | 268 | <div class="search-item"> |
270 | 269 | <label for="searchSbd">Số báo danh</label> |
271 | 270 | <div class="input-wrapper"> |
272 | | - <input type="text" id="searchSbd" placeholder="Nhập SBD..." pattern="[0-9]*" maxlength="6"> |
| 271 | + <input type="number" id="searchSbd" placeholder="Nhập SBD..." maxlength="6"> |
273 | 272 | <span class="clear-input" data-target="searchSbd">×</span> |
274 | 273 | </div> |
275 | 274 | </div> |
|
303 | 302 | </div> |
304 | 303 | </div> |
305 | 304 | </div> |
306 | | - |
307 | | - <!-- HTML MỚI: Thêm dòng hiển thị kết quả --> |
| 305 | + |
308 | 306 | <div id="resultsSummary" class="results-summary"></div> |
309 | 307 |
|
310 | 308 | <div class="table-section"> |
|
354 | 352 | initElements() { |
355 | 353 | this.elements = { |
356 | 354 | tableBody: document.getElementById('tableBody'), |
357 | | - // JS CẬP NHẬT |
358 | 355 | searchSbd: document.getElementById('searchSbd'), |
359 | 356 | searchName: document.getElementById('searchName'), |
360 | 357 | searchSchool: document.getElementById('searchSchool'), |
361 | 358 | searchClass: document.getElementById('searchClass'), |
362 | 359 | searchTotal: document.getElementById('searchTotal'), |
363 | 360 | tableHeaders: document.querySelectorAll('th[data-column]'), |
364 | 361 | clearInputs: document.querySelectorAll('.clear-input'), |
365 | | - // JS CẬP NHẬT |
366 | 362 | resultsSummary: document.getElementById('resultsSummary') |
367 | 363 | }; |
368 | 364 | } |
369 | 365 |
|
370 | 366 | initEvents() { |
371 | | - // JS CẬP NHẬT |
372 | 367 | ['searchSbd', 'searchName', 'searchSchool', 'searchClass', 'searchTotal'].forEach(id => { |
373 | 368 | this.elements[id].addEventListener('input', () => this.handleSearch()); |
374 | 369 | }); |
|
394 | 389 | const csvText = await response.text(); |
395 | 390 | this.parseCSV(csvText); |
396 | 391 | this.filteredData = [...this.data]; |
397 | | - |
398 | | - // JS CẬP NHẬT |
399 | 392 | this.updateResultsSummary(); |
400 | 393 | this.renderTable(); |
401 | 394 | } catch (error) { |
|
438 | 431 | } |
439 | 432 |
|
440 | 433 | filterData() { |
441 | | - // JS CẬP NHẬT |
442 | 434 | const sbdFilter = this.elements.searchSbd.value.trim(); |
443 | 435 | const nameFilter = this.elements.searchName.value.toLowerCase().trim(); |
444 | 436 | const schoolFilter = this.elements.searchSchool.value.toLowerCase().trim(); |
|
449 | 441 | this.filteredData = [...this.data]; |
450 | 442 | } else { |
451 | 443 | this.filteredData = this.data.filter(row => { |
452 | | - // JS CẬP NHẬT |
453 | 444 | return (!sbdFilter || row.sbd.includes(sbdFilter)) && |
454 | 445 | (!nameFilter || row.name.toLowerCase().includes(nameFilter)) && |
455 | 446 | (!schoolFilter || row.school.toLowerCase().includes(schoolFilter)) && |
|
458 | 449 | }); |
459 | 450 | } |
460 | 451 |
|
461 | | - // JS CẬP NHẬT |
462 | 452 | this.updateResultsSummary(); |
463 | 453 | this.renderTable(); |
464 | 454 | } |
465 | 455 |
|
466 | | - // JS MỚI: Hàm cập nhật thông báo kết quả |
467 | 456 | updateResultsSummary() { |
468 | 457 | const filteredCount = this.filteredData.length; |
469 | 458 | const totalCount = this.data.length; |
|
526 | 515 | let r, g, b; |
527 | 516 |
|
528 | 517 | if (percentage < 50) { |
529 | | - // Dải màu từ Đỏ (229, 62, 62) -> Vàng (245, 158, 11) |
530 | 518 | const p = percentage / 50; |
531 | 519 | r = Math.round(229 + p * (245 - 229)); |
532 | 520 | g = Math.round(62 + p * (158 - 62)); |
533 | 521 | b = Math.round(62 + p * (11 - 62)); |
534 | 522 | } else { |
535 | | - // Dải màu từ Vàng (245, 158, 11) -> Xanh (16, 185, 129) |
536 | 523 | const p = (percentage - 50) / 50; |
537 | 524 | r = Math.round(245 + p * (16 - 245)); |
538 | 525 | g = Math.round(158 + p * (185 - 158)); |
|
562 | 549 |
|
563 | 550 | const sortKeys = ['sbd', 'name', 'class', 'school', 'van', 'toan', 'anh', 'total']; |
564 | 551 | const sortKey = sortKeys[columnIndex]; |
565 | | - const isNumeric = columnIndex >= 4 || columnIndex === 0; // SBD cũng là số |
| 552 | + const isNumeric = columnIndex >= 4 || columnIndex === 0; |
566 | 553 | const direction = this.currentSort.direction === 'asc' ? 1 : -1; |
567 | 554 |
|
568 | 555 | this.filteredData.sort((a, b) => { |
569 | 556 | const aVal = a[sortKey]; |
570 | 557 | const bVal = b[sortKey]; |
571 | 558 |
|
572 | 559 | if (isNumeric) { |
573 | | - // Sửa lại để so sánh SBD như số nếu có thể |
574 | 560 | if(sortKey === 'sbd') { |
575 | 561 | return (parseInt(aVal, 10) - parseInt(bVal, 10)) * direction; |
576 | 562 | } |
|
0 commit comments