Spaces:
Sleeping

doluong6 commited on
Commit
4e898f6
·
verified ·
1 Parent(s): 06b1fb1

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +7 -11
static/script.js CHANGED
@@ -669,7 +669,6 @@ async function hienThiHSKH() {
669
  return;
670
  }
671
 
672
- // Tìm chỉ số cột "Full"
673
  const fullIndex = data.columns.indexOf("Full");
674
 
675
  if ($.fn.DataTable.isDataTable("#bangHSKH")) {
@@ -678,24 +677,21 @@ async function hienThiHSKH() {
678
 
679
  let tbodyHtml = "";
680
  data.rows.forEach(row => {
681
- const fullChecked = row[fullIndex]?.toLowerCase() === "x";
682
- const rowClass = fullChecked ? "full-row" : "not-full-row";
683
-
684
- tbodyHtml += `<tr class="${rowClass}">`;
685
 
686
  for (let j = 0; j < data.columns.length; j++) {
687
  const col = data.columns[j];
688
- const cell = row[j] || "";
689
 
690
  if (["Full", "PYC", "BB", "GCN"].includes(col)) {
691
- const checked = cell.toLowerCase() === "x" ? "checked" : "";
692
- tbodyHtml += `<td><input type="checkbox" class="checkbox-cell" ${checked}></td>`;
693
  } else {
 
694
  tbodyHtml += `<td><input class="input-cell" type="text" value="${cell}" /></td>`;
695
  }
696
  }
697
 
698
- tbodyHtml += "</tr>";
699
  });
700
 
701
  $("#bangHSKH tbody").html(tbodyHtml);
@@ -718,7 +714,7 @@ async function hienThiHSKH() {
718
  }
719
  });
720
 
721
- // ✅ Cập nhật màu theo checkbox tại đúng cột "Full"
722
  function capNhatMauDong() {
723
  $("#bangHSKH tbody tr").each(function () {
724
  const checkbox = $(this).find(`td:eq(${fullIndex}) input[type="checkbox"]`);
@@ -732,7 +728,7 @@ async function hienThiHSKH() {
732
 
733
  capNhatMauDong();
734
 
735
- // Lắng nghe thay đổi ở ô "Full"
736
  $("#bangHSKH").off("change", `td:eq(${fullIndex}) input[type="checkbox"]`)
737
  .on("change", `td:eq(${fullIndex}) input[type="checkbox"]`, function () {
738
  capNhatMauDong();
 
669
  return;
670
  }
671
 
 
672
  const fullIndex = data.columns.indexOf("Full");
673
 
674
  if ($.fn.DataTable.isDataTable("#bangHSKH")) {
 
677
 
678
  let tbodyHtml = "";
679
  data.rows.forEach(row => {
680
+ tbodyHtml += `<tr>`;
 
 
 
681
 
682
  for (let j = 0; j < data.columns.length; j++) {
683
  const col = data.columns[j];
 
684
 
685
  if (["Full", "PYC", "BB", "GCN"].includes(col)) {
686
+ // ✅ Bỏ checked mặc định
687
+ tbodyHtml += `<td><input type="checkbox" class="checkbox-cell"></td>`;
688
  } else {
689
+ const cell = row[j] || "";
690
  tbodyHtml += `<td><input class="input-cell" type="text" value="${cell}" /></td>`;
691
  }
692
  }
693
 
694
+ tbodyHtml += `</tr>`;
695
  });
696
 
697
  $("#bangHSKH tbody").html(tbodyHtml);
 
714
  }
715
  });
716
 
717
+ // ✅ Tô màu khi người dùng tích vào ô "Full"
718
  function capNhatMauDong() {
719
  $("#bangHSKH tbody tr").each(function () {
720
  const checkbox = $(this).find(`td:eq(${fullIndex}) input[type="checkbox"]`);
 
728
 
729
  capNhatMauDong();
730
 
731
+ // ✅ Khi tích vào "Full"
732
  $("#bangHSKH").off("change", `td:eq(${fullIndex}) input[type="checkbox"]`)
733
  .on("change", `td:eq(${fullIndex}) input[type="checkbox"]`, function () {
734
  capNhatMauDong();