Update static/script.js
Browse files- static/script.js +31 -18
static/script.js
CHANGED
|
@@ -4,25 +4,19 @@ function login() {
|
|
| 4 |
if (u === "admin" && p === "1234") {
|
| 5 |
document.getElementById("login").style.display = "none";
|
| 6 |
document.getElementById("dashboard").style.display = "block";
|
| 7 |
-
hienThiPYCChoXuLy(); //
|
| 8 |
} else {
|
| 9 |
alert("Sai tên đăng nhập hoặc mật khẩu!");
|
| 10 |
}
|
| 11 |
}
|
| 12 |
|
|
|
|
| 13 |
async function hienThiPYCChoXuLy() {
|
| 14 |
try {
|
| 15 |
-
// Ẩn tất cả
|
| 16 |
document.querySelectorAll(".fade-in").forEach(el => el.style.display = "none");
|
| 17 |
|
| 18 |
const bang = document.getElementById("bangPYCChoXuLy");
|
| 19 |
const tbody = document.querySelector("#tablePYCChoXuLy tbody");
|
| 20 |
-
|
| 21 |
-
if (!bang || !tbody) {
|
| 22 |
-
console.error("❌ Không tìm thấy phần tử bảng để hiển thị.");
|
| 23 |
-
return;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
tbody.innerHTML = "";
|
| 27 |
|
| 28 |
const res = await fetch("/ds_pyc_cho_xu_ly");
|
|
@@ -41,25 +35,44 @@ async function hienThiPYCChoXuLy() {
|
|
| 41 |
tbody.appendChild(row);
|
| 42 |
});
|
| 43 |
|
| 44 |
-
// Hiện bảng
|
| 45 |
bang.style.display = "block";
|
| 46 |
|
| 47 |
-
//
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
table.DataTable().clear().destroy();
|
| 51 |
}
|
| 52 |
-
table.DataTable();
|
| 53 |
-
|
| 54 |
} catch (error) {
|
| 55 |
-
console.error("
|
| 56 |
-
alert("Lỗi khi tải dữ liệu
|
| 57 |
}
|
| 58 |
}
|
| 59 |
|
|
|
|
| 60 |
function chonMuc(muc) {
|
| 61 |
-
console.log("⏺ Mục được chọn:", muc);
|
| 62 |
if (muc === "cho_xu_ly") {
|
| 63 |
hienThiPYCChoXuLy();
|
| 64 |
}
|
| 65 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
if (u === "admin" && p === "1234") {
|
| 5 |
document.getElementById("login").style.display = "none";
|
| 6 |
document.getElementById("dashboard").style.display = "block";
|
| 7 |
+
hienThiPYCChoXuLy(); // Có thể đổi sang hienThiTongQuan nếu muốn tổng quan
|
| 8 |
} else {
|
| 9 |
alert("Sai tên đăng nhập hoặc mật khẩu!");
|
| 10 |
}
|
| 11 |
}
|
| 12 |
|
| 13 |
+
// Gọi API hiển thị danh sách phiếu chờ xử lý
|
| 14 |
async function hienThiPYCChoXuLy() {
|
| 15 |
try {
|
|
|
|
| 16 |
document.querySelectorAll(".fade-in").forEach(el => el.style.display = "none");
|
| 17 |
|
| 18 |
const bang = document.getElementById("bangPYCChoXuLy");
|
| 19 |
const tbody = document.querySelector("#tablePYCChoXuLy tbody");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
tbody.innerHTML = "";
|
| 21 |
|
| 22 |
const res = await fetch("/ds_pyc_cho_xu_ly");
|
|
|
|
| 35 |
tbody.appendChild(row);
|
| 36 |
});
|
| 37 |
|
|
|
|
| 38 |
bang.style.display = "block";
|
| 39 |
|
| 40 |
+
// Chỉ khởi tạo DataTable nếu chưa có
|
| 41 |
+
if (!$.fn.DataTable.isDataTable("#tablePYCChoXuLy")) {
|
| 42 |
+
$("#tablePYCChoXuLy").DataTable();
|
|
|
|
| 43 |
}
|
|
|
|
|
|
|
| 44 |
} catch (error) {
|
| 45 |
+
console.error("Lỗi khi tải phiếu chờ xử lý:", error);
|
| 46 |
+
alert("Lỗi khi tải dữ liệu: " + error.message);
|
| 47 |
}
|
| 48 |
}
|
| 49 |
|
| 50 |
+
// Gọi khi click vào menu
|
| 51 |
function chonMuc(muc) {
|
|
|
|
| 52 |
if (muc === "cho_xu_ly") {
|
| 53 |
hienThiPYCChoXuLy();
|
| 54 |
}
|
| 55 |
}
|
| 56 |
+
|
| 57 |
+
// Xử lý mở rộng / thu gọn submenu
|
| 58 |
+
function toggleSubmenu(id) {
|
| 59 |
+
const allMenus = document.querySelectorAll(".submenu");
|
| 60 |
+
const allArrows = document.querySelectorAll(".arrow");
|
| 61 |
+
|
| 62 |
+
allMenus.forEach(menu => {
|
| 63 |
+
if (menu.id !== id) menu.style.display = "none";
|
| 64 |
+
});
|
| 65 |
+
|
| 66 |
+
allArrows.forEach(arrow => arrow.textContent = "►");
|
| 67 |
+
|
| 68 |
+
const submenu = document.getElementById(id);
|
| 69 |
+
const arrow = document.getElementById("arrow-" + id.split("-")[0]);
|
| 70 |
+
|
| 71 |
+
if (submenu.style.display === "block") {
|
| 72 |
+
submenu.style.display = "none";
|
| 73 |
+
if (arrow) arrow.textContent = "►";
|
| 74 |
+
} else {
|
| 75 |
+
submenu.style.display = "block";
|
| 76 |
+
if (arrow) arrow.textContent = "▼";
|
| 77 |
+
}
|
| 78 |
+
}
|