Spaces:
Sleeping

doluong6 commited on
Commit
7091e4e
·
verified ·
1 Parent(s): b42982f

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +26 -3
static/script.js CHANGED
@@ -760,7 +760,7 @@ async function hienThiHSKH() {
760
 
761
  for (let j = 0; j < data.columns.length; j++) {
762
  const col = data.columns[j];
763
- const cell = (row[j] != null) ? row[j] : ""; // tránh null
764
 
765
  if (["Full", "PYC", "BB", "GCN"].includes(col)) {
766
  const checked = cell.toString().toLowerCase() === "x" ? "checked" : "";
@@ -855,6 +855,31 @@ async function hienThiHSKH() {
855
  capNhatMauDong();
856
  });
857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
858
  document.getElementById("nutLuuHSKH").style.display = "inline-block";
859
 
860
  } catch (error) {
@@ -864,8 +889,6 @@ async function hienThiHSKH() {
864
  }
865
 
866
 
867
-
868
-
869
  async function luuHSKH() {
870
  try {
871
  const headers = [];
 
760
 
761
  for (let j = 0; j < data.columns.length; j++) {
762
  const col = data.columns[j];
763
+ const cell = (row[j] != null) ? row[j] : "";
764
 
765
  if (["Full", "PYC", "BB", "GCN"].includes(col)) {
766
  const checked = cell.toString().toLowerCase() === "x" ? "checked" : "";
 
855
  capNhatMauDong();
856
  });
857
 
858
+ // ✅ Tự động thêm dòng mới nếu dòng cuối được điền
859
+ function themDongMoiNeuCan() {
860
+ $("#bangHSKH tbody").on("input", "input, textarea, select", function () {
861
+ const lastRow = $("#bangHSKH tbody tr").last();
862
+ let isEmpty = true;
863
+
864
+ lastRow.find("input[type='text'], textarea, select").each(function () {
865
+ const val = $(this).val();
866
+ if (val && val !== "--chọn--") {
867
+ isEmpty = false;
868
+ }
869
+ });
870
+
871
+ if (!isEmpty) {
872
+ const newRow = lastRow.clone();
873
+ newRow.find("input[type='text'], textarea").val("");
874
+ newRow.find("select").val("");
875
+ newRow.find("input[type='checkbox']").prop("checked", false);
876
+ newRow.removeClass("full-row not-full-row");
877
+ $("#bangHSKH tbody").append(newRow);
878
+ }
879
+ });
880
+ }
881
+ themDongMoiNeuCan();
882
+
883
  document.getElementById("nutLuuHSKH").style.display = "inline-block";
884
 
885
  } catch (error) {
 
889
  }
890
 
891
 
 
 
892
  async function luuHSKH() {
893
  try {
894
  const headers = [];