Spaces:
Sleeping

doluong6 commited on
Commit
bb0734d
·
verified ·
1 Parent(s): 9ffadeb

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +20 -2
static/script.js CHANGED
@@ -558,17 +558,34 @@ async function hienThiHoaChat() {
558
  const tbody = table.createTBody();
559
  rows.forEach(row => {
560
  const tr = tbody.insertRow();
561
- row.forEach(cell => {
562
  const td = tr.insertCell();
563
  const input = document.createElement("input");
564
  input.type = "text";
565
  input.value = cell;
566
  input.classList.add("input-cell");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  td.appendChild(input);
568
  });
569
  });
570
 
571
- // Hiện nút Lưu
572
  const nutLuu = document.getElementById("nutLuuHoaChat");
573
  if (nutLuu) nutLuu.style.display = "block";
574
 
@@ -578,6 +595,7 @@ async function hienThiHoaChat() {
578
  }
579
  }
580
 
 
581
  // ==== Lưu dữ liệu đã chỉnh sửa ====
582
  async function luuHoaChat() {
583
  const table = document.getElementById("bangHoaChat");
 
558
  const tbody = table.createTBody();
559
  rows.forEach(row => {
560
  const tr = tbody.insertRow();
561
+ row.forEach((cell, colIndex) => {
562
  const td = tr.insertCell();
563
  const input = document.createElement("input");
564
  input.type = "text";
565
  input.value = cell;
566
  input.classList.add("input-cell");
567
+ input.style.width = "100%";
568
+
569
+ // ✅ Tô màu cho cột "TÌNH TRẠNG"
570
+ if (columns[colIndex].toUpperCase().includes("TÌNH TRẠNG")) {
571
+ input.readOnly = true;
572
+ input.style.fontWeight = "bold";
573
+
574
+ if (cell.includes("HẾT HẠN")) {
575
+ input.style.color = "red";
576
+ } else if (cell.includes("CÒN:")) {
577
+ const match = cell.match(/CÒN: (\d+)/);
578
+ if (match && parseInt(match[1]) <= 30) {
579
+ input.style.color = "orange";
580
+ }
581
+ }
582
+ }
583
+
584
  td.appendChild(input);
585
  });
586
  });
587
 
588
+ // ✅ Hiện nút Lưu
589
  const nutLuu = document.getElementById("nutLuuHoaChat");
590
  if (nutLuu) nutLuu.style.display = "block";
591
 
 
595
  }
596
  }
597
 
598
+
599
  // ==== Lưu dữ liệu đã chỉnh sửa ====
600
  async function luuHoaChat() {
601
  const table = document.getElementById("bangHoaChat");