112 lines
3.4 KiB
HTML
112 lines
3.4 KiB
HTML
<!doctype html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>Реестр поручений СД</title>
|
||
<link rel="stylesheet" href="style.css">
|
||
</head>
|
||
<body>
|
||
<header class="header">
|
||
<div class="header-left">
|
||
<h1>Реестр поручений Совета директоров</h1>
|
||
</div>
|
||
<nav class="nav" id="mainNav">
|
||
<a href="index.html">Дашборд</a>
|
||
<a href="registry.html" class="active">Реестр</a>
|
||
<a href="card.html?id=new" id="newBtn" style="display:none">Новое поручение</a>
|
||
</nav>
|
||
</header>
|
||
|
||
<main class="registry">
|
||
<div class="search-box">
|
||
<input type="text" id="searchInput" placeholder="Поиск по тексту поручения, РМ или исполнителю...">
|
||
<button onclick="search()">Найти</button>
|
||
<button onclick="clearSearch()" class="btn-secondary">Сброс</button>
|
||
</div>
|
||
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>ID</th>
|
||
<th>Поручение</th>
|
||
<th>Статус</th>
|
||
<th>Дата выдачи</th>
|
||
<th>Плановый срок</th>
|
||
<th>РМ</th>
|
||
<th>Исполнитель</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="registryBody"></tbody>
|
||
</table>
|
||
</main>
|
||
|
||
<script src="auth.js"></script>
|
||
<script>
|
||
const user = requireAuth();
|
||
renderUserMenu();
|
||
|
||
if (canEdit()) {
|
||
document.getElementById("newBtn").style.display = "inline-block";
|
||
}
|
||
|
||
let allInstructions = [];
|
||
|
||
async function load() {
|
||
const res = await fetch("/api/instructions");
|
||
allInstructions = await res.json();
|
||
render();
|
||
}
|
||
|
||
function getStatusClass(status) {
|
||
if (status === "Выполнено") return "status-done";
|
||
if (status === "В работе") return "status-progress";
|
||
if (status === "На контроле") return "status-control";
|
||
if (status === "Просрочено") return "status-overdue";
|
||
return "";
|
||
}
|
||
|
||
function render(filtered = allInstructions) {
|
||
const tbody = document.getElementById("registryBody");
|
||
if (!filtered.length) {
|
||
tbody.innerHTML = '<tr><td colspan="7" style="text-align:center;padding:40px;">Нет поручений</td></tr>';
|
||
return;
|
||
}
|
||
tbody.innerHTML = filtered.map(i => `
|
||
<tr onclick="window.location='card.html?id=${i.id}'" style="cursor:pointer">
|
||
<td>${i.id}</td>
|
||
<td>${i.title}</td>
|
||
<td><span class="status ${getStatusClass(i.status)}">${i.status}</span></td>
|
||
<td>${i.issueDate}</td>
|
||
<td>${i.planDate}</td>
|
||
<td>${i.rm || "—"}</td>
|
||
<td>${i.delegate || "—"}</td>
|
||
</tr>
|
||
`).join("");
|
||
}
|
||
|
||
function search() {
|
||
const q = document.getElementById("searchInput").value.toLowerCase();
|
||
if (!q) { render(); return; }
|
||
const filtered = allInstructions.filter(i =>
|
||
(i.title && i.title.toLowerCase().includes(q)) ||
|
||
(i.rm && i.rm.toLowerCase().includes(q)) ||
|
||
(i.delegate && i.delegate.toLowerCase().includes(q))
|
||
);
|
||
render(filtered);
|
||
}
|
||
|
||
function clearSearch() {
|
||
document.getElementById("searchInput").value = "";
|
||
render();
|
||
}
|
||
|
||
document.getElementById("searchInput").addEventListener("keypress", (e) => {
|
||
if (e.key === "Enter") search();
|
||
});
|
||
|
||
load();
|
||
</script>
|
||
</body>
|
||
</html>
|