fix: remove duplicate renderDashboard code, close HTML tags
This commit is contained in:
parent
2eccacde8b
commit
89b94fbdfd
@ -137,6 +137,9 @@ body{font:17px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
|||||||
<h2 class="text-xl font-bold mb-4" id="emp-title">Моё HSE обучение</h2>
|
<h2 class="text-xl font-bold mb-4" id="emp-title">Моё HSE обучение</h2>
|
||||||
<div id="emp-courses"></div>
|
<div id="emp-courses"></div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div><!-- /app -->
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||||
<script src="script.js"></script>
|
<script src="script.js"></script>
|
||||||
|
|||||||
36
script.js
36
script.js
@ -526,7 +526,6 @@ function renderDashboard() {
|
|||||||
<div class="card text-center"><div class="text-3xl font-bold text-yellow-500">${notStarted}</div><div class="text-sm text-gray-500">Не начато</div></div>
|
<div class="card text-center"><div class="text-3xl font-bold text-yellow-500">${notStarted}</div><div class="text-sm text-gray-500">Не начато</div></div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Проблемные филиалы
|
|
||||||
const cityStats = CITIES.map(city => {
|
const cityStats = CITIES.map(city => {
|
||||||
const emps = EMPLOYEES.filter(e => e.city === city);
|
const emps = EMPLOYEES.filter(e => e.city === city);
|
||||||
const ov = emps.reduce((sum, e) => sum + e.courses.filter(c => c.overdue).length, 0);
|
const ov = emps.reduce((sum, e) => sum + e.courses.filter(c => c.overdue).length, 0);
|
||||||
@ -541,41 +540,6 @@ function renderDashboard() {
|
|||||||
</div>`
|
</div>`
|
||||||
).join('');
|
).join('');
|
||||||
|
|
||||||
// Самые непройденные курсы
|
|
||||||
const courseStats = COURSES.map(c => {
|
|
||||||
const total = EMPLOYEES.length;
|
|
||||||
const notDone = EMPLOYEES.filter(e => !e.courses.find(cc => cc.courseId === c.id && cc.completed)).length;
|
|
||||||
return { name: c.name, notDone, pct: Math.round((notDone / total) * 100) };
|
|
||||||
}).sort((a, b) => b.pct - a.pct).slice(0, 5);
|
|
||||||
|
|
||||||
document.getElementById('dash-courses').innerHTML = courseStats.map((s, i) =>
|
|
||||||
`<div class="flex justify-between items-center py-2 ${i < courseStats.length - 1 ? 'border-b' : ''}">
|
|
||||||
<span class="text-sm">${i + 1}. ${s.name}</span>
|
|
||||||
<span class="status-danger text-sm">${s.pct}%</span>
|
|
||||||
</div>`
|
|
||||||
).join('');
|
|
||||||
<div class="card text-center"><div class="text-3xl font-bold">${totalEmp}</div><div class="text-sm text-gray-500">Сотрудников</div></div>
|
|
||||||
<div class="card text-center"><div class="text-3xl font-bold">${progress}%</div><div class="text-sm text-gray-500">Выполнено</div></div>
|
|
||||||
<div class="card text-center"><div class="text-3xl font-bold text-red-500">${overdue}</div><div class="text-sm text-gray-500">Просрочено</div></div>
|
|
||||||
<div class="card text-center"><div class="text-3xl font-bold text-yellow-500">${notStarted}</div><div class="text-sm text-gray-500">Не начато</div></div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Проблемные филиалы
|
|
||||||
const cityStats = CITIES.map(city => {
|
|
||||||
const emps = EMPLOYEES.filter(e => e.city === city);
|
|
||||||
const ov = emps.reduce((sum, e) => sum + e.courses.filter(c => c.overdue).length, 0);
|
|
||||||
const total = emps.reduce((sum, e) => sum + e.courses.length, 0);
|
|
||||||
return { city, overdue: ov, pct: total > 0 ? Math.round((ov / total) * 100) : 0 };
|
|
||||||
}).sort((a, b) => b.pct - a.pct);
|
|
||||||
|
|
||||||
document.getElementById('dash-problems').innerHTML = cityStats.map((s, i) =>
|
|
||||||
`<div class="flex justify-between items-center py-2 ${i < cityStats.length - 1 ? 'border-b' : ''}">
|
|
||||||
<span>${i + 1}. ${s.city}</span>
|
|
||||||
<span class="status-danger">${s.pct}% просрочено (${s.overdue})</span>
|
|
||||||
</div>`
|
|
||||||
).join('');
|
|
||||||
|
|
||||||
// Самые непройденные курсы
|
|
||||||
const courseStats = COURSES.map(c => {
|
const courseStats = COURSES.map(c => {
|
||||||
const total = EMPLOYEES.length;
|
const total = EMPLOYEES.length;
|
||||||
const notDone = EMPLOYEES.filter(e => !e.courses.find(cc => cc.courseId === c.id && cc.completed)).length;
|
const notDone = EMPLOYEES.filter(e => !e.courses.find(cc => cc.courseId === c.id && cc.completed)).length;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user