Update static/script.js
Browse files- static/script.js +62 -0
static/script.js
CHANGED
|
@@ -85,6 +85,14 @@ function chonMuc(muc) {
|
|
| 85 |
hienThiPDF();// ✅ Gọi API lấy danh sách PDF
|
| 86 |
}
|
| 87 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
}
|
| 89 |
|
| 90 |
|
|
@@ -420,6 +428,60 @@ function hienThiPDF() {
|
|
| 420 |
viewer.style.display = "block";
|
| 421 |
}
|
| 422 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
|
| 424 |
|
| 425 |
|
|
|
|
| 85 |
hienThiPDF();// ✅ Gọi API lấy danh sách PDF
|
| 86 |
}
|
| 87 |
}
|
| 88 |
+
if (muc === "qt") {
|
| 89 |
+
const section = document.getElementById("qt");
|
| 90 |
+
if (section) {
|
| 91 |
+
section.style.display = "block";
|
| 92 |
+
taiDanhSachQuyTrinh();
|
| 93 |
+
hienThiQT();
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
}
|
| 97 |
|
| 98 |
|
|
|
|
| 428 |
viewer.style.display = "block";
|
| 429 |
}
|
| 430 |
|
| 431 |
+
async function taiDanhSachQuyTrinh() {
|
| 432 |
+
try {
|
| 433 |
+
const res = await fetch(`${BACKEND_URL}/quy_trinh`);
|
| 434 |
+
const data = await res.json();
|
| 435 |
+
|
| 436 |
+
const select = document.getElementById("selectQT");
|
| 437 |
+
select.innerHTML = `<option value="">-- Chọn tài liệu --</option>`;
|
| 438 |
+
|
| 439 |
+
data.pdfs.forEach(item => {
|
| 440 |
+
let fileName, filePath;
|
| 441 |
+
if (typeof item === "string") {
|
| 442 |
+
fileName = item;
|
| 443 |
+
filePath = `Quy_trinh/${item}`;
|
| 444 |
+
} else {
|
| 445 |
+
fileName = item.name;
|
| 446 |
+
filePath = item.path;
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
const option = document.createElement("option");
|
| 450 |
+
option.value = filePath;
|
| 451 |
+
option.textContent = fileName;
|
| 452 |
+
select.appendChild(option);
|
| 453 |
+
});
|
| 454 |
+
} catch (error) {
|
| 455 |
+
console.error("Lỗi khi tải danh sách quy trình:", error);
|
| 456 |
+
alert("Không thể tải danh sách quy trình.");
|
| 457 |
+
}
|
| 458 |
+
}
|
| 459 |
+
function hienThiQT() {
|
| 460 |
+
const file = document.getElementById("selectQT").value;
|
| 461 |
+
const iframe = document.getElementById("qtFrame");
|
| 462 |
+
const viewer = document.getElementById("qtViewer");
|
| 463 |
+
const download = document.getElementById("qtDownload");
|
| 464 |
+
|
| 465 |
+
if (file) {
|
| 466 |
+
const ext = file.toLowerCase().split('.').pop();
|
| 467 |
+
const url = `${BACKEND_URL}/xem_pdf?file=${encodeURIComponent(file)}`;
|
| 468 |
+
|
| 469 |
+
if (ext === "pdf") {
|
| 470 |
+
iframe.src = url;
|
| 471 |
+
iframe.style.display = "block";
|
| 472 |
+
} else {
|
| 473 |
+
iframe.src = "";
|
| 474 |
+
iframe.style.display = "none";
|
| 475 |
+
alert("Không hỗ trợ xem trực tiếp định dạng này. Vui lòng tải về.");
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
download.href = url + "&download=true";
|
| 479 |
+
viewer.style.display = "block";
|
| 480 |
+
} else {
|
| 481 |
+
viewer.style.display = "none";
|
| 482 |
+
}
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
|
| 486 |
|
| 487 |
|