File size: 18,043 Bytes
ac1db79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
077b24f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html>
<html lang="ru">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
  <title>MES System</title>
  <script src="https://cdn.tailwindcss.com "></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css "/>
  <style>
    .notification-badge {
      position: absolute;
      top: 0;
      right: 0;
      font-size: 0.625rem;
      line-height: 1.25rem;
      width: 1.25rem;
      height: 1.25rem;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 9999px;
    }
  </style>
</head>
<body class="bg-gray-100 text-gray-900">

<!-- Sidebar -->
<div id="sidebar" class="fixed top-0 left-0 h-full bg-blue-800 text-white w-64 p-4 transition-all duration-300 z-10">
  <div class="flex items-center justify-between mb-6">
    <h1 class="text-xl font-bold">MES System</h1>
    <button onclick="toggleSidebar()" class="text-white hover:text-blue-200">
      <i class="fas fa-bars"></i>
    </button>
  </div>

  <nav>
    <ul class="space-y-2">
      <li><button onclick="showTab('dashboard')" class="tab-btn active w-full text-left px-4 py-2 rounded-lg bg-blue-700"><i class="fas fa-tachometer-alt mr-2"></i> Главная</button></li>
      <li><button onclick="showTab('schedule')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-calendar-alt mr-2"></i> График ТО</button></li>
      <li><button onclick="showTab('equipment')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-tools mr-2"></i> Оборудование</button></li>
      <li><button onclick="showTab('repairs')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-wrench mr-2"></i> Ремонт</button></li>
      <li><button onclick="showTab('maintenance')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-clipboard-check mr-2"></i> Техобслуживание</button></li>
      <li><button onclick="showTab('reports')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-chart-line mr-2"></i> Отчеты</button></li>
      <li><button onclick="showTab('users')" class="tab-btn w-full text-left px-4 py-2 rounded-lg hover:bg-blue-700"><i class="fas fa-users-cog mr-2"></i> Пользователи</button></li>
    </ul>
  </nav>
</div>

<!-- Main Content -->
<div class="ml-64 p-6 min-h-screen">
  <!-- Header -->
  <header class="bg-white shadow-sm p-4 rounded-lg mb-6 flex justify-between items-center">
    <h1 id="page-title" class="text-2xl font-semibold">Главная панель</h1>
    <div class="flex space-x-4">
      <button class="p-2 rounded-full hover:bg-gray-100 relative">
        <i class="fas fa-bell text-gray-600"></i>
        <span class="notification-badge bg-red-500 text-white">3</span>
      </button>
      <div class="relative">
        <input type="text" placeholder="Поиск..." class="pl-10 pr-4 py-2 border rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
        <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
      </div>
    </div>
  </header>

  <!-- Tabs -->
  <div id="content" class="bg-white rounded-lg shadow p-6">
    <!-- Default Tab - Dashboard -->
    <div id="dashboard" class="tab-content active">
      <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">
        <div class="bg-white rounded-lg shadow p-6 border-l-4 border-blue-500">
          <h4 class="font-medium text-gray-500">Всего оборудования</h4>
          <p id="total-equipment" class="text-2xl font-bold">0</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 border-l-4 border-green-500">
          <h4 class="font-medium text-gray-500">Выполнено ТО</h4>
          <p id="completed-maintenance" class="text-2xl font-bold">0</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 border-l-4 border-yellow-500">
          <h4 class="font-medium text-gray-500">Просрочено ТО</h4>
          <p id="overdue-maintenance" class="text-2xl font-bold">0</p>
        </div>
        <div class="bg-white rounded-lg shadow p-6 border-l-4 border-red-500">
          <h4 class="font-medium text-gray-500">Текущие ремонты</h4>
          <p id="current-repairs" class="text-2xl font-bold">0</p>
        </div>
      </div>

      <div class="bg-white rounded-lg shadow overflow-hidden">
        <div class="p-4 border-b flex justify-between items-center">
          <h2 class="text-lg font-semibold">Оборудование</h2>
          <button onclick="showTab('equipment')" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg">
            Перейти к оборудованию
          </button>
        </div>
        <div class="overflow-x-auto">
          <table id="dashboard-table" class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
              <tr>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">ID</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Название</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Статус</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Последнее ТО</th>
              </tr>
            </thead>
            <tbody id="dashboard-body" class="bg-white divide-y divide-gray-200"></tbody>
          </table>
        </div>
      </div>
    </div>

    <!-- Equipment Tab -->
    <div id="equipment" class="tab-content hidden">
      <div class="mb-4 flex justify-between items-center">
        <h2 class="text-2xl font-bold">Оборудование</h2>
        <button onclick="openAddModal()" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg flex items-center">
          <i class="fas fa-plus mr-2"></i> Добавить оборудование
        </button>
      </div>

      <div class="bg-white rounded-lg shadow overflow-hidden">
        <div class="overflow-x-auto">
          <table class="min-w-full divide-y divide-gray-200">
            <thead class="bg-gray-50">
              <tr>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">ID</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Название</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Тип</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Статус</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Инвентарный номер</th>
                <th class="px-6 py-3 text-left text-xs uppercase tracking-wider">Действия</th>
              </tr>
            </thead>
            <tbody id="equipment-list" class="bg-white divide-y divide-gray-200"></tbody>
          </table>
        </div>
      </div>
    </div>

    <!-- Schedule Tab -->
    <div id="schedule" class="tab-content hidden">
      <h2 class="text-2xl font-bold mb-6">График ТО</h2>
      <div class="bg-white rounded-lg shadow p-6">
        <h3 class="text-lg font-semibold mb-4">Календарь ТО</h3>
        <div class="grid grid-cols-7 gap-1 mb-2">
          <div class="text-center text-sm font-medium text-gray-500">Пн</div>
          <div class="text-center text-sm font-medium text-gray-500">Вт</div>
          <div class="text-center text-sm font-medium text-gray-500">Ср</div>
          <div class="text-center text-sm font-medium text-gray-500">Чт</div>
          <div class="text-center text-sm font-medium text-gray-500">Пт</div>
          <div class="text-center text-sm font-medium text-gray-500">Сб</div>
          <div class="text-center text-sm font-medium text-gray-500">Вс</div>
        </div>
        <div id="calendar" class="grid grid-cols-7 gap-1 h-64 overflow-y-auto">
          <!-- Calendar days will be generated by JavaScript -->
        </div>
      </div>
    </div>

    <!-- Repairs Tab -->
    <div id="repairs" class="tab-content hidden">
      <h2 class="text-2xl font-bold mb-6">Ремонтные работы</h2>
      <div class="bg-white rounded-lg shadow p-6">
        <p>Здесь будет информация о ремонтных работах.</p>
      </div>
    </div>

    <!-- Maintenance Tab -->
    <div id="maintenance" class="tab-content hidden">
      <h2 class="text-2xl font-bold mb-6">Техническое обслуживание</h2>
      <div class="bg-white rounded-lg shadow p-6">
        <p>Здесь будет информация о техническом обслуживании.</p>
      </div>
    </div>

    <!-- Reports Tab -->
    <div id="reports" class="tab-content hidden">
      <h2 class="text-2xl font-bold mb-6">Отчеты</h2>
      <div class="bg-white rounded-lg shadow p-6">
        <p>Здесь будут отчеты по работе системы.</p>
      </div>
    </div>

    <!-- Users Tab -->
    <div id="users" class="tab-content hidden">
      <h2 class="text-2xl font-bold mb-6">Пользователи</h2>
      <div class="bg-white rounded-lg shadow p-6">
        <p>Здесь будет список пользователей.</p>
      </div>
    </div>
  </div>
</div>

<!-- Add Equipment Modal -->
<div id="addEquipmentModal" class="hidden fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
  <div class="bg-white rounded-lg shadow-lg w-full max-w-md p-6">
    <div class="flex justify-between items-center mb-4">
      <h3 class="text-lg font-semibold">Добавить оборудование</h3>
      <button onclick="closeAddModal()" class="text-gray-500">&times;</button>
    </div>
    <form id="equipmentForm" class="space-y-4">
      <input type="text" name="name" placeholder="Название" required class="w-full border rounded px-4 py-2">
      <select name="type" required class="w-full border rounded px-4 py-2">
        <option value="">Выберите тип</option>
        <option>Станок</option>
        <option>Конвейер</option>
        <option>Компрессор</option>
        <option>Генератор</option>
        <option>Насос</option>
      </select>
      <input type="text" name="serial" placeholder="Серийный номер" required class="w-full border rounded px-4 py-2">
      <input type="text" name="inventory" placeholder="Инвентарный номер" required class="w-full border rounded px-4 py-2">
      <input type="date" name="commissionDate" required class="w-full border rounded px-4 py-2">
      <input type="number" name="interval" placeholder="Интервал ТО (дни)" required class="w-full border rounded px-4 py-2">
      <textarea name="description" rows="3" placeholder="Описание" class="w-full border rounded px-4 py-2"></textarea>
    </form>
    <div class="mt-4 flex justify-end space-x-2">
      <button onclick="closeAddModal()" class="border px-4 py-2 rounded hover:bg-gray-100">Отмена</button>
      <button onclick="saveEquipment()" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">Сохранить</button>
    </div>
  </div>
</div>

<script>
  // Mock data
  let equipmentData = [
    {id: 1, name: "Токарный станок", type: "Станок", serial: "SN-001", inventory: "INV-001", status: "active", lastMaintenance: "2023-05-15"},
    {id: 2, name: "Конвейер А-12", type: "Конвейер", serial: "SN-002", inventory: "INV-002", status: "maintenance", lastMaintenance: "2023-04-10"}
  ];

  const maintenanceEvents = [
    { equipmentId: 1, date: "2023-06-15", status: "planned" },
    { equipmentId: 2, date: "2023-06-10", status: "overdue" }
  ];

  const calendar = document.getElementById("calendar");

  function formatDate(dateStr) {
    if (!dateStr) return "";
    const d = new Date(dateStr);
    return `${d.getDate()}.${d.getMonth()+1}.${d.getFullYear()}`;
  }

  function toggleSidebar() {
    const sidebar = document.getElementById("sidebar");
    const isCollapsed = sidebar.classList.contains("collapsed");
    sidebar.classList.toggle("collapsed", !isCollapsed);
    document.querySelector(".ml-64").classList.toggle("ml-16", !isCollapsed);
  }

  function showTab(tabId) {
    document.querySelectorAll('.tab-content').forEach(el => el.classList.add('hidden'));
    document.getElementById(tabId).classList.remove('hidden');
    document.getElementById('page-title').innerText = tabId.charAt(0).toUpperCase() + tabId.slice(1);
    document.querySelectorAll('.tab-btn').forEach(btn => btn.classList.remove('bg-blue-700'));
    event.target.classList.add('bg-blue-700');
  }

  function openAddModal() {
    document.getElementById("addEquipmentModal").classList.remove("hidden");
  }

  function closeAddModal() {
    document.getElementById("addEquipmentModal").classList.add("hidden");
    document.getElementById("equipmentForm").reset();
  }

  function saveEquipment() {
    const form = document.getElementById("equipmentForm");
    const formData = new FormData(form);
    const newEq = {
      id: equipmentData.length ? Math.max(...equipmentData.map(e => e.id)) + 1 : 1,
      name: formData.get("name"),
      type: formData.get("type"),
      serial: formData.get("serial"),
      inventory: formData.get("inventory"),
      commissionDate: formData.get("commissionDate"),
      interval: formData.get("interval"),
      description: formData.get("description"),
      status: "active",
      lastMaintenance: "",
    };
    equipmentData.push(newEq);
    closeAddModal();
    renderEquipment();
    updateDashboardStats();
  }

  function deleteEquipment(id) {
    equipmentData = equipmentData.filter(eq => eq.id !== id);
    renderEquipment();
    updateDashboardStats();
  }

  function renderEquipment() {
    const tbody = document.getElementById("equipment-list");
    const dashboardTbody = document.getElementById("dashboard-body");
    tbody.innerHTML = '';
    dashboardTbody.innerHTML = '';

    equipmentData.forEach(eq => {
      const row = document.createElement("tr");
      row.innerHTML = `
        <td class="px-6 py-4">${eq.id}</td>
        <td class="px-6 py-4">${eq.name}</td>
        <td class="px-6 py-4">${eq.type}</td>
        <td class="px-6 py-4">
          <span class="px-2 py-1 rounded-full text-xs font-semibold ${eq.status === 'active' ? 'bg-green-100 text-green-800' : eq.status === 'maintenance' ? 'bg-yellow-100 text-yellow-800' : 'bg-red-100 text-red-800'}">
            ${eq.status === 'active' ? 'Активно' : eq.status === 'maintenance' ? 'ТО' : 'Ремонт'}
          </span>
        </td>
        <td class="px-6 py-4">${eq.inventory || '-'}</td>
        <td class="px-6 py-4">
          <button onclick="deleteEquipment(${eq.id})" class="text-red-600 hover:text-red-800">
            <i class="fas fa-trash"></i>
          </button>
        </td>
      `;
      tbody.appendChild(row);

      const dashRow = document.createElement("tr");
      dashRow.innerHTML = `
        <td class="px-6 py-4">${eq.id}</td>
        <td class="px-6 py-4">${eq.name}</td>
        <td class="px-6 py-4">
          <span class="px-2 py-1 rounded-full text-xs font-semibold ${eq.status === 'active' ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800'}">
            ${eq.status === 'active' ? 'Активно' : 'ТО'}
          </span>
        </td>
        <td class="px-6 py-4">${formatDate(eq.lastMaintenance)}</td>
      `;
      dashboardTbody.appendChild(dashRow);
    });
  }

  function updateDashboardStats() {
    document.getElementById("total-equipment").textContent = equipmentData.length;
    document.getElementById("completed-maintenance").textContent = equipmentData.filter(e => e.lastMaintenance).length;
    document.getElementById("overdue-maintenance").textContent = equipmentData.filter(e => new Date(e.nextMaintenance) < new Date()).length;
    document.getElementById("current-repairs").textContent = equipmentData.filter(e => e.status === "repair").length;
  }

  function generateCalendar() {
    const today = new Date();
    const year = today.getFullYear();
    const month = today.getMonth();
    const firstDay = new Date(year, month, 1).getDay();
    const daysInMonth = new Date(year, month + 1, 0).getDate();

    for (let i = 0; i < 42; i++) {
      const day = i - firstDay + 1;
      const cell = document.createElement("div");
      if (day > 0 && day <= daysInMonth) {
        cell.textContent = day;
        cell.className = "h-10 flex items-center justify-center border rounded cursor-pointer";
        if (maintenanceEvents.some(ev => ev.date === `${year}-${String(month+1).padStart(2,'0')}-${String(day).padStart(2,'0')}`)) {
          cell.style.backgroundColor = "#BFDBFE";
        }
      } else {
        cell.textContent = "";
      }
      calendar.appendChild(cell);
    }
  }

  function initApp() {
    renderEquipment();
    updateDashboardStats();
    generateCalendar();
  }

  window.onload = initApp;
</script>

<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Karmashek/ver2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>