Spaces:
Sleeping

doluong6 commited on
Commit
eba8f5e
·
verified ·
1 Parent(s): 20ee5e9

Update static/script.js

Browse files
Files changed (1) hide show
  1. static/script.js +40 -0
static/script.js CHANGED
@@ -45,6 +45,46 @@ function chonMuc(muc) {
45
  }
46
  }
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  async function hienThiDanhSachPYCChoXuLy() {
49
  try {
50
  const res = await fetch("/ds_pyc_cho_xu_ly");
 
45
  }
46
  }
47
  }
48
+ async function hienThiDanhSachPYC() {
49
+ try {
50
+ const res = await fetch("/ds_pyc_cho_xu_ly");
51
+ const data = await res.json();
52
+
53
+ console.log("DANH SÁCH PYC:", data);
54
+
55
+ document.getElementById("pycCount").textContent = `${data.length} phiếu`;
56
+
57
+ const tbody = document.querySelector("#tablePYCChoXuLy tbody");
58
+ tbody.innerHTML = "";
59
+
60
+ data.forEach(item => {
61
+ const danhSach = item["Danh sách thiết bị"] || [];
62
+
63
+ const htmlTB = danhSach.length
64
+ ? danhSach.map(tb => `${tb["Thiết bị"]} (${tb["Số lượng"]})`).join("<br>")
65
+ : "Không có thiết bị";
66
+
67
+ const row = `
68
+ <tr>
69
+ <td>${item["Khách hàng"]}</td>
70
+ <td>${item["File PYC"]}</td>
71
+ <td>${item["Người lập"] || ""}</td>
72
+ <td>${item["Ngày lập"] || ""}</td>
73
+ <td>${htmlTB}</td>
74
+ </tr>`;
75
+ tbody.innerHTML += row;
76
+ });
77
+
78
+ if (!$.fn.DataTable.isDataTable("#tablePYCChoXuLy")) {
79
+ $("#tablePYCChoXuLy").DataTable();
80
+ }
81
+
82
+ } catch (err) {
83
+ console.error("Lỗi khi tải danh sách PYC:", err);
84
+ document.getElementById("pycCount").textContent = "Lỗi";
85
+ }
86
+ }
87
+
88
  async function hienThiDanhSachPYCChoXuLy() {
89
  try {
90
  const res = await fetch("/ds_pyc_cho_xu_ly");