mgb / index.html
GGGeddd's picture
undefined - Initial Deployment
e1c9f24 verified
Raw History Blame Contribute Delete
59 kB
<!DOCTYPE html> <html lang="ru"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Интерактивная панель заявок — Demo</title> <link rel="icon" type="image/x-icon" href="/static/favicon.ico" /> <!-- Tailwind --> <script src="https://cdn.tailwindcss.com"></script> <!-- Feather icons --> <script src="https://unpkg.com/feather-icons"></script> <!-- AOS --> <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" /> <script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script> <!-- Leaflet --> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script> <!-- Leaflet MarkerCluster --> <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" /> <link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" /> <script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script> <!-- SheetJS for Excel export --> <script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script> <style> .status-badge{padding:.125rem .5rem;border-radius:.5rem;font-size:.75rem;font-weight:600} .status-new{background:#dbeafe;color:#1d4ed8} .status-inprogress{background:#fef9c3;color:#92400e} .status-completed{background:#dcfce7;color:#065f46} .status-rejected{background:#fee2e2;color:#991b1b} .toast{animation:slideIn .25s ease-out} @keyframes slideIn{from{transform:translateX(120%);opacity:0}to{transform:translateX(0);opacity:1}} .map-container{transition:all .3s ease} .map-container:hover{box-shadow:0 10px 25px rgba(0,0,0,.1)} /* Новые стили для синей темы */ .stat-card { background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%); color: white; border-radius: 1rem; padding: 1.25rem; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } .nav-link.active { background-color: #dbeafe; color: #1e40af; font-weight: 600; } .nav-link.active i { color: #1e40af; } .btn-primary { background-color: #2563eb; color: white; transition: all 0.2s; } .btn-primary:hover { background-color: #1e40af; } .sidebar-header { background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%); color: white; padding: 1rem; border-radius: 1rem 1rem 0 0; } </style> </head> <body class="bg-gray-50 min-h-screen"> <!-- Topbar --> <header class="sticky top-0 z-40 bg-white border-b"> <div class="max-w-7xl mx-auto px-4 py-3 flex items-center justify-between"> <div class="flex items-center gap-3"> <button id="btnToggleSidebar" class="p-2 rounded-xl hover:bg-gray-100" aria-label="Меню"> <i data-feather="menu"></i> </button> <h1 class="text-xl font-semibold">Панель заявок</h1> <span id="onlineIndicator" class="ml-3 px-2 py-1 rounded-full text-xs bg-green-100 text-green-700 hidden">Онлайн</span> <span id="offlineIndicator" class="ml-3 px-2 py-1 rounded-full text-xs bg-yellow-100 text-yellow-700 hidden">Оффлайн</span> </div> <div class="flex items-center gap-3"> <button id="btnNotifications" class="relative p-2 rounded-xl hover:bg-gray-100"> <i data-feather="bell"></i> <span id="notifDot" class="absolute -top-1 -right-1 w-2 h-2 rounded-full bg-red-500 hidden"></span> </button> <div class="flex items-center gap-2"> <div id="currentUserEmail" class="text-sm text-gray-600"></div> <button id="btnLogout" class="text-sm text-gray-500 hover:text-gray-800">Выйти</button> </div> </div> </div> </header> <!-- Layout --> <div class="max-w-7xl mx-auto px-4 py-6 grid grid-cols-12 gap-6" id="appRoot"> <!-- Sidebar --> <aside id="sidebar" class="col-span-12 md:col-span-3 lg:col-span-2 space-y-2 transition-all"> <nav class="bg-white rounded-2xl shadow overflow-hidden"> <div class="sidebar-header"> <h2 class="font-bold text-lg">Главная панель</h2> </div> <div class="p-3"> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50 text-blue-700" data-target="dashboard"> <i data-feather="activity" class="inline w-4 mr-2"></i>Дашборд </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="registry"> <i data-feather="list" class="inline w-4 mr-2"></i>Реестр заявок </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="tc"> <i data-feather="package" class="inline w-4 mr-2"></i>Танк‑контейнеры </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="act"> <i data-feather="file-text" class="inline w-4 mr-2"></i>Акт обследования </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="dicts"> <i data-feather="book" class="inline w-4 mr-2"></i>Справочники </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="log"> <i data-feather="clock" class="inline w-4 mr-2"></i>Журнал действий </button> <button class="nav-link w-full text-left px-3 py-2 rounded-xl hover:bg-blue-50" data-target="settings"> <i data-feather="settings" class="inline w-4 mr-2"></i>Настройки </button> </div> </nav> <!-- Import/Export --> <div class="bg-white rounded-2xl shadow overflow-hidden"> <div class="sidebar-header"> <h3 class="font-semibold">Импорт/Экспорт</h3> </div> <div class="p-4 flex flex-col gap-2"> <input type="file" id="importJson" accept="application/json" class="block w-full text-sm" /> <button id="btnExportJSON" class="px-3 py-2 text-sm rounded-xl btn-primary">Экспорт JSON</button> <button id="btnExportExcel" class="px-3 py-2 text-sm rounded-xl btn-primary">Экспорт Excel</button> </div> </div> </aside> <!-- Main content --> <main class="col-span-12 md:col-span-9 lg:col-span-10 space-y-6"> <!-- Dashboard --> <section id="screen-dashboard" class="screen hidden"> <div class="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4"> <div class="stat-card"> <div class="text-blue-100">Всего заявок</div> <div id="statNew" class="text-3xl font-semibold">5</div> <div class="text-sm text-blue-200 mt-1">+2.5% с прошлой недели</div> </div> <div class="stat-card"> <div class="text-blue-100">В работе</div> <div id="statInProgress" class="text-3xl font-semibold">2</div> <div class="text-sm text-blue-200 mt-1">-1.2% с прошлой недели</div> </div> <div class="stat-card"> <div class="text-blue-100">Завершено</div> <div id="statCompleted" class="text-3xl font-semibold">1</div> <div class="text-sm text-blue-200 mt-1">+5.3% с прошлой недели</div> </div> <div class="stat-card"> <div class="text-blue-100">Танк-контейнеров</div> <div id="statTotal" class="text-3xl font-semibold">4</div> <div class="text-sm text-blue-200 mt-1">+8.7% с прошлого месяца</div> </div> </div> <!-- Map --> <div class="mt-6 p-4 bg-white rounded-3xl shadow map-container" data-aos="fade-up"> <div class="flex items-center justify-between mb-3"> <h3 class="font-semibold">Карта заявок</h3> <div class="text-sm flex gap-2"> <label class="flex items-center gap-1"><input type="checkbox" id="toggleLayerNew" checked /> Новые</label> <label class="flex items-center gap-1"><input type="checkbox" id="toggleLayerCompleted" checked /> Завершённые</label> </div> </div> <!-- Уменьшили высоту карты с 420px до 300px --> <div id="map" class="h-[300px] w-full rounded-2xl"></div> </div> <!-- Notifications panel --> <div class="bg-white rounded-2xl shadow p-4"> <div class="flex items-center justify-between mb-3"> <h3 class="font-semibold">Уведомления</h3> <button id="btnClearNotifs" class="text-sm text-blue-600 hover:text-blue-800">Очистить</button> </div> <ul id="notifList" class="space-y-2 text-sm"></ul> </div> </section> <!-- Registry --> <section id="screen-registry" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <div class="flex flex-wrap items-end gap-3"> <div class="grow"> <label class="text-xs text-gray-500">Поиск</label> <input id="searchInput" class="w-full border rounded-xl px-3 py-2" placeholder="Организация / Номер / Адрес" /> </div> <div> <label class="text-xs text-gray-500">Статус</label> <select id="filterStatus" class="border rounded-xl px-3 py-2"> <option value="">Все</option> <option value="new">Новая</option> <option value="in-progress">В работе</option> <option value="completed">Завершена</option> <option value="rejected">Отменена</option> </select> </div> <div> <label class="text-xs text-gray-500">Регион</label> <select id="filterRegion" class="border rounded-xl px-3 py-2"> <option value="">Все</option> </select> </div> <button id="btnAddRequest" class="px-4 py-2 rounded-xl btn-primary"><i data-feather="plus" class="inline w-4 mr-1"></i>Добавить</button> </div> <div class="mt-4 overflow-x-auto"> <table class="min-w-full"> <thead> <tr class="text-left text-xs uppercase text-gray-500 bg-blue-50"> <th class="p-2">#</th> <th class="p-2">Дата</th> <th class="p-2">Номер</th> <th class="p-2">Организация</th> <th class="p-2">Адрес</th> <th class="p-2">ТК</th> <th class="p-2">Регион</th> <th class="p-2">Статус</th> <th class="p-2">Действия</th> </tr> </thead> <tbody id="registryTbody" class="text-sm"></tbody> </table> </div> </div> </section> <!-- TC characteristics --> <section id="screen-tc" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <div class="flex items-center justify-between mb-3"> <h3 class="font-semibold">Характеристики танк‑контейнера</h3> <div class="text-sm flex gap-2 items-center"> <span>Статус карточки:</span> <select id="tcStatus" class="border rounded-xl px-2 py-1"> <option value="draft">Формируется</option> <option value="review">На проверке</option> <option value="approved">Проверен</option> </select> <button id="btnSendTcForReview" class="px-3 py-2 rounded-xl btn-primary">Отправить на проверку</button> </div> </div> <form id="tcForm" class="grid grid-cols-1 md:grid-cols-2 gap-4"> <!-- Left column: numbers/dates --> <div class="space-y-3"> <div> <label class="text-xs text-gray-500">Заводской номер</label> <input id="tcSerial" class="w-full border rounded-xl px-3 py-2" placeholder="Напр. FV 17056940" /> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Мин. доп. толщина днища</label> <input id="tcMinFloor" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">Мин. замер. толщина днища</label> <input id="tcMeasFloor" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Номинал толщины обечайки</label> <input id="tcNomCyl" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">Мин. доп. толщина обечайки</label> <input id="tcMinCyl" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">МДРД сосуда (МПа)</label> <input id="tcMdrcVessel" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">МДРД пароподогревателя (МПа)</label> <input id="tcMdrcHeater" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Давление испытаний сосуда</label> <input id="tcTestPressV" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">Давление испытаний пароподогревателя</label> <input id="tcTestPressH" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div> <label class="text-xs text-gray-500">Дата испытаний на прочность</label> <input id="tcTestDate" type="date" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <!-- Right column: equipment block --> <div class="space-y-3"> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Верхний слив</label> <select id="tcTopDrain" class="w-full border rounded-xl px-3 py-2"><option>Ок</option><option>Отсутствует</option></select> </div> <div> <label class="text-xs text-gray-500">Нижний слив</label> <select id="tcBottomDrain" class="w-full border rounded-xl px-3 py-2"><option>Ок</option><option>Отсутствует</option></select> </div> </div> <div> <label class="text-xs text-gray-500">Клапан предохранительный №</label> <input id="tcReliefValveNo" class="w-full border rounded-xl px-3 py-2" placeholder="Напр. FV 17056940" /> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Кол-во пред. клапанов</label> <input id="tcReliefCount" type="number" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">Давл. открытия (МПа)</label> <input id="tcReliefOpenP" type="text" class="w-full border rounded-xl px-3 py-2" placeholder="0,43/-0,20" /> </div> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Разрывные мембраны, кол-во</label> <input id="tcBurstCount" type="number" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">Производитель П/К</label> <input id="tcReliefMaker" class="w-full border rounded-xl px-3 py-2" placeholder="FV" /> </div> </div> <div class="grid grid-cols-2 gap-3"> <div> <label class="text-xs text-gray-500">Солнцезащитный экран</label> <select id="tcSunShield" class="w-full border rounded-xl px-3 py-2"><option>—</option><option>Да</option><option>Нет</option></select> </div> <div> <label class="text-xs text-gray-500">Уровнемер</label> <select id="tcLevelGauge" class="w-full border rounded-xl px-3 py-2"><option>—</option><option>Да</option><option>Нет</option></select> </div> </div> <div> <button id="btnSaveTc" type="button" class="px-4 py-2 rounded-xl btn-primary">Сохранить</button> </div> </div> </form> </div> </section> <!-- Act form --> <section id="screen-act" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <div class="flex items-center justify-between mb-3"> <h3 class="font-semibold">Акт обследования</h3> <div class="flex gap-2"> <label class="flex items-center gap-1 text-sm"><input type="checkbox" id="signInspector" /> Подписано инспектором</label> <label class="flex items-center gap-1 text-sm"><input type="checkbox" id="signDepot" /> Подписано депо</label> <button id="btnPrintAct" class="px-3 py-2 rounded-xl bg-gray-100 hover:bg-gray-200">Печать</button> </div> </div> <form id="actForm" class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div> <label class="text-xs text-gray-500">№ Акта</label> <input id="actNumber" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Место составления акта</label> <input id="actPlace" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Дата обследования</label> <input id="actDate" type="date" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Время начала</label> <input id="actTime" type="time" class="w-full border rounded-xl px-3 py-2" required /> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">Основания для проведения обследования</label> <input id="actReason" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Номер контейнера</label> <input id="actContainerNo" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Заводской номер контейнера</label> <input id="actSerialNo" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Акт составлен (ФИО, должность)</label> <input id="actAuthor" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Представитель депо (ФИО, должность)</label> <input id="actDepotRep" class="w-full border rounded-xl px-3 py-2" required /> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">1.1 Визуальный осмотр</label> <textarea id="actInspect1" class="w-full border rounded-xl px-3 py-2" rows="2" placeholder="Несущая конструкция, изоляция, наружная поверхность..." required></textarea> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">1.2 Неразрушающий контроль швов</label> <textarea id="actInspect2" class="w-full border rounded-xl px-3 py-2" rows="2" required></textarea> </div> <div class="grid grid-cols-2 gap-3 md:col-span-2"> <div> <label class="text-xs text-gray-500">1.3 Мин. толщина днища (мм)</label> <input id="actTminFloor" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">1.3 Мин. толщина обечайки (мм)</label> <input id="actTminCyl" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">1.4–1.7 Оборудование/клапаны/мембраны/маркировка</label> <textarea id="actEquip" class="w-full border rounded-xl px-3 py-2" rows="2" required></textarea> </div> <div class="grid grid-cols-3 gap-3 md:col-span-2"> <div> <label class="text-xs text-gray-500">1.8 Давление (МПа)</label> <input id="actPtest" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">1.8 Дата</label> <input id="actPtestDate" type="date" class="w-full border rounded-xl px-3 py-2" /> </div> <div> <label class="text-xs text-gray-500">1.9 Давление пароподогрева</label> <input id="actPsteam" type="number" step="0.01" class="w-full border rounded-xl px-3 py-2" /> </div> </div> <div class="md:col-span-2 flex gap-2"> <button id="btnSaveAct" type="button" class="px-4 py-2 rounded-xl btn-primary">Сохранить</button> <button id="btnResetAct" type="button" class="px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200">Очистить</button> </div> </form> </div> </section> <!-- Dictionaries --> <section id="screen-dicts" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <h3 class="font-semibold mb-3">Справочники</h3> <div class="grid md:grid-cols-3 gap-4"> <div> <div class="flex items-center justify-between mb-2"><div class="font-medium">Компании</div><button class="text-sm text-blue-600" data-add-dict="companies">Добавить</button></div> <ul id="dictCompanies" class="text-sm space-y-1"></ul> </div> <div> <div class="flex items-center justify-between mb-2"><div class="font-medium">Адреса</div><button class="text-sm text-blue-600" data-add-dict="addresses">Добавить</button></div> <ul id="dictAddresses" class="text-sm space-y-1"></ul> </div> <div> <div class="flex items-center justify-between mb-2"><div class="font-medium">Инспекторы</div><button class="text-sm text-blue-600" data-add-dict="inspectors">Добавить</button></div> <ul id="dictInspectors" class="text-sm space-y-1"></ul> </div> </div> </div> </section> <!-- Action log --> <section id="screen-log" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <div class="flex items-center justify-between mb-3"> <h3 class="font-semibold">Журнал действий</h3> <button id="btnClearLog" class="text-sm text-blue-600 hover:text-blue-800">Очистить</button> </div> <ul id="logList" class="text-sm space-y-1"></ul> </div> </section> <!-- Settings --> <section id="screen-settings" class="screen hidden"> <div class="bg-white rounded-2xl shadow p-4"> <h3 class="font-semibold mb-3">Настройки</h3> <div class="space-y-3"> <div>Версия демо: <span id="appVersion" class="font-mono"></span></div> <div>Роль: <span id="userRoleLabel" class="font-semibold"></span></div> </div> </div> </section> </main> </div> <!-- Floating toasts --> <div id="toastArea" class="fixed right-4 top-16 space-y-2 z-50"></div> <!-- Login overlay (shown when not authenticated) --> <div id="loginOverlay" class="fixed inset-0 bg-gradient-to-br from-blue-100 via-indigo-100 to-pink-100 flex items-center justify-center p-4 hidden"> <!-- Убрали правую колонку с информацией по проекту, оставили только форму входа --> <div class="w-full max-w-md"> <!-- LEFT: Login form (не трогаем логику входа) --> <div class="bg-white rounded-3xl shadow-xl p-8"> <h2 class="text-center mb-4 font-bold text-2xl text-blue-700">Вход в систему</h2> <form id="loginForm" class="space-y-3"> <input type="email" id="loginEmail" class="w-full border rounded-2xl px-4 py-3" placeholder="Логин (email)" required /> <input type="password" id="loginPassword" class="w-full border rounded-2xl px-4 py-3" placeholder="Пароль" required /> <div class="text-xs text-gray-500">Демо-логин: <b>kuxtenko82@inbox.ru</b> Пароль: <b>irik2005</b></div> <button type="submit" class="w-full py-3 rounded-2xl btn-primary">Войти</button> </form> </div> </div> </div> <!-- Modal Add/Edit Request --> <div id="modalRequest" class="fixed inset-0 bg-black/30 items-center justify-center hidden z-50"> <div class="bg-white w-full max-w-3xl rounded-2xl shadow-xl p-6"> <div class="flex items-center justify-between mb-3"> <h3 id="modalRequestTitle" class="font-semibold">Заявка</h3> <button id="btnCloseModalRequest" class="p-2 hover:bg-gray-100 rounded-xl"><i data-feather="x"></i></button> </div> <form id="requestForm" class="grid grid-cols-1 md:grid-cols-2 gap-4"> <div> <label class="text-xs text-gray-500">Заявитель / Компания</label> <div class="flex gap-2"> <input id="reqCompany" class="w-full border rounded-xl px-3 py-2" list="listCompanies" required /> <button type="button" class="px-3 py-2 rounded-xl bg-gray-100 hover:bg-gray-200" data-add-dict="companies"><i data-feather="plus"></i></button> </div> <datalist id="listCompanies"></datalist> </div> <div> <label class="text-xs text-gray-500">Дата заявки</label> <input id="reqDate" type="date" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Номер заявки</label> <input id="reqNumber" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Место оказания услуг (адрес)</label> <div class="flex gap-2"> <input id="reqAddress" class="w-full border rounded-xl px-3 py-2" list="listAddresses" required /> <button type="button" class="px-3 py-2 rounded-xl bg-gray-100 hover:bg-gray-200" data-add-dict="addresses"><i data-feather="plus"></i></button> </div> <datalist id="listAddresses"></datalist> </div> <div> <label class="text-xs text-gray-500">Количество ТК</label> <input id="reqTcCount" type="number" min="1" class="w-full border rounded-xl px-3 py-2" required /> </div> <div> <label class="text-xs text-gray-500">Сроки предоставления услуги</label> <input id="reqServiceDates" class="w-full border rounded-xl px-3 py-2" placeholder="ДД.ММ.ГГГГ–ДД.ММ.ГГГГ" /> </div> <div> <label class="text-xs text-gray-500">Регион</label> <select id="reqRegion" class="w-full border rounded-xl px-3 py-2" required></select> </div> <div> <label class="text-xs text-gray-500">Инспекторы (можно несколько)</label> <select id="reqInspectors" class="w-full border rounded-xl px-3 py-2" multiple size="3"></select> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">Документы (загрузка)</label> <input id="reqDocs" type="file" multiple class="block w-full" /> </div> <div class="md:col-span-2"> <label class="text-xs text-gray-500">Счета</label> <div id="invoiceArea" class="space-y-2"></div> <button type="button" id="btnAddInvoice" class="mt-2 px-3 py-2 rounded-xl bg-gray-100 hover:bg-gray-200">Добавить счёт</button> </div> <div class="md:col-span-2 flex gap-2 mt-1"> <button id="btnSaveRequest" type="submit" class="px-4 py-2 rounded-xl btn-primary">Сохранить</button> <button id="btnCancelRequest" type="button" class="px-4 py-2 rounded-xl bg-gray-100 hover:bg-gray-200">Отмена</button> </div> </form> </div> </div> <!-- Templates --> <template id="tplInvoice"> <div class="grid grid-cols-1 md:grid-cols-4 gap-2 border rounded-xl p-2"> <input class="invoice-number border rounded-xl px-3 py-2" placeholder="счёт № 12 от 02.07.2025" /> <input class="invoice-sum border rounded-xl px-3 py-2" placeholder="50 000" /> <input type="date" class="invoice-date border rounded-xl px-3 py-2" /> <select class="invoice-status border rounded-xl px-3 py-2"><option value="PAID">ОПЛАЧЕНО</option><option value="UNPAID">НЕОПЛАЧЕНО</option></select> </div> </template> <script> const APP_VERSION = '1.6.0'; // --- Simple state --- const state = { user: null, role: 'ADMIN', data: { requests: [], dicts: {companies: [], addresses: [], inspectors: []}, notifs: [], log: [] }, map: null, layers: { new: null, completed: null }, clusters: { new: null, completed: null } }; // --- Utilities --- const el = id => document.getElementById(id); const fmtDate = ts => new Date(ts).toLocaleDateString('ru-RU'); function saveAll(){ localStorage.setItem('appData', JSON.stringify(state.data)); } function loadAll(){ const raw = localStorage.getItem('appData'); if(raw){ try{ state.data = JSON.parse(raw);}catch(e){ console.warn('Reset appData due parse error'); localStorage.removeItem('appData'); } } if(!state.data.requests) state.data.requests=[]; if(!state.data.dicts) state.data.dicts={companies:[],addresses:[],inspectors:[]}; if(!state.data.notifs) state.data.notifs=[]; if(!state.data.log) state.data.log=[]; } function logAction(text){ const item = { id: Date.now(), text, at: Date.now(), user: state.user?.email||'anon' }; state.data.log.unshift(item); saveAll(); renderLog(); } function notify(text){ const id = Date.now(); state.data.notifs.unshift({ id, text, at: Date.now() }); saveAll(); renderNotifs(); const li = document.createElement('div'); li.className = 'toast bg-white shadow rounded-xl p-3 text-sm'; li.textContent = text; el('toastArea').appendChild(li); setTimeout(()=> li.remove(), 3500); el('notifDot').classList.remove('hidden'); } function statusBadge(st){ const map = { 'new':'status-new', 'in-progress':'status-inprogress', 'completed':'status-completed', 'rejected':'status-rejected' }; const title = { 'new':'Новая', 'in-progress':'В работе', 'completed':'Завершена', 'rejected':'Отменена' }; return `<span class="status-badge ${map[st]}">${title[st]||st}</span>`; } function genId(){ return Math.floor(Math.random()*1e6); } // --- Auth --- function checkAuth(){ const raw = localStorage.getItem('sessionUser'); if(raw){ try{ state.user = JSON.parse(raw);}catch(_){} } if(!state.user){ showLogin(); } else { hideLogin(); } } function showLogin(){ el('loginOverlay').classList.remove('hidden'); } function hideLogin(){ el('loginOverlay').classList.add('hidden'); } function doLogin(email, password){ // Credentials from user const VALID_EMAIL = 'kuxtenko82@inbox.ru'; const VALID_PASS = 'irik2005'; if(email === VALID_EMAIL && password === VALID_PASS){ state.user = { email, role: 'ADMIN' }; localStorage.setItem('sessionUser', JSON.stringify(state.user)); hideLogin(); afterAuthInit(); notify('Вход выполнен'); return true; } return false; } function logout(){ localStorage.removeItem('sessionUser'); state.user=null; showLogin(); } // --- Seed demo data once --- function seed(){ if(state.data.requests.length) return; state.data.dicts.companies = ['ООО "ТрансКонтейнер"','АО "ЛогистикСервис"','ООО "РосТанк"']; state.data.dicts.addresses = ['Санкт‑Петербург, ул. Пушкина, 1','Москва, ул. Тверская, 10','Екатеринбург, пр. Ленина, 5','Владивосток, ул. Морская, 2']; state.data.dicts.inspectors = ['Семенов Владислав','Иванов Иван']; state.data.requests = [ {id: genId(), date: Date.now()-86400000, number:'Z-001', company:'ООО "ТрансКонтейнер"', address:'Санкт‑Петербург, ул. Пушкина, 1', tcCount:3, serviceDates:'02.02.2025–03.02.2025', region:'СЗФО', inspectors:['Семенов Владислав'], status:'new', docs:[], invoices:[], lat:59.93, lng:30.31}, {id: genId(), date: Date.now()-43200000, number:'Z-002', company:'АО "ЛогистикСервис"', address:'Москва, ул. Тверская, 10', tcCount:5, serviceDates:'05.02.2025–07.02.2025', region:'ЦФО', inspectors:['Иванов Иван'], status:'in-progress', docs:[], invoices:[], lat:55.75, lng:37.62}, {id: genId(), date: Date.now()-172800000, number:'Z-003', company:'ООО "РосТанк"', address:'Екатеринбург, пр. Ленина, 5', tcCount:2, serviceDates:'10.02.2025–12.02.2025', region:'УФО', inspectors:['Семенов Владислав','Иванов Иван'], status:'completed', docs:[], invoices:[], lat:56.83, lng:60.60}, {id: genId(), date: Date.now()-259200000, number:'Z-004', company:'ООО "РосТанк"', address:'Владивосток, ул. Морская, 2', tcCount:1, serviceDates:'15.02.2025–16.02.2025', region:'ДФО', inspectors:['Иванов Иван'], status:'new', docs:[], invoices:[], lat:43.11, lng:131.87}, ]; saveAll(); } // --- Screens --- function showScreen(name){ document.querySelectorAll('.screen').forEach(s=>s.classList.add('hidden')); el('screen-'+name).classList.remove('hidden'); document.querySelectorAll('.nav-link').forEach(b=>{ if(b.dataset.target===name) b.classList.add('active'); else b.classList.remove('active'); }) if(name==='dashboard'){ renderStats(); renderMap(); renderNotifs(); } if(name==='registry'){ renderRegistry(); } if(name==='tc'){ /* keep */ } if(name==='act'){ /* keep */ } if(name==='dicts'){ renderDicts(); } if(name==='log'){ renderLog(); } if(name==='settings'){ el('appVersion').textContent = APP_VERSION; el('userRoleLabel').textContent = state.user?.role || '—'; } } // --- Dashboard --- function renderStats(){ const a = state.data.requests; el('statNew').textContent = a.filter(r=>r.status==='new').length; el('statInProgress').textContent = a.filter(r=>r.status==='in-progress').length; el('statCompleted').textContent = a.filter(r=>r.status==='completed').length; el('statTotal').textContent = a.length; } function renderMap(){ if(!state.map){ state.map = L.map('map').setView([58.5, 60], 4); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{attribution:'&copy; OpenStreetMap'}).addTo(state.map); state.layers.new = L.layerGroup(); state.layers.completed = L.layerGroup(); state.clusters.new = L.markerClusterGroup(); state.clusters.completed = L.markerClusterGroup(); state.layers.new.addLayer(state.clusters.new); state.layers.completed.addLayer(state.clusters.completed); } state.clusters.new.clearLayers(); state.clusters.completed.clearLayers(); state.data.requests.forEach(r=>{ if(!r.lat||!r.lng) return; const m = L.marker([r.lat,r.lng]); m.bindPopup(`<b>${r.number}</b><br>${r.company}<br>${r.address}<br>${statusBadge(r.status)}`); if(r.status==='new' || r.status==='in-progress') state.clusters.new.addLayer(m); if(r.status==='completed') state.clusters.completed.addLayer(m); }); if(!state.map.hasLayer(state.layers.new)) state.layers.new.addTo(state.map); if(!state.map.hasLayer(state.layers.completed)) state.layers.completed.addTo(state.map); // toggles el('toggleLayerNew').onchange = (e)=>{ if(e.target.checked){ state.map.addLayer(state.layers.new);} else { state.map.removeLayer(state.layers.new);} }; el('toggleLayerCompleted').onchange = (e)=>{ if(e.target.checked){ state.map.addLayer(state.layers.completed);} else { state.map.removeLayer(state.layers.completed);} }; } function renderNotifs(){ const list = el('notifList'); list.innerHTML=''; state.data.notifs.slice(0,50).forEach(n=>{ const li = document.createElement('li'); li.className='border rounded-xl p-2 flex items-center justify-between'; li.innerHTML = `<div>${n.text}</div><div class='text-xs text-gray-500'>${new Date(n.at).toLocaleString('ru-RU')}</div>`; list.appendChild(li); }); el('notifDot').classList.toggle('hidden', state.data.notifs.length===0); } // --- Registry --- function renderRegistry(){ // fill filters const regions = ['ЦФО','СЗФО','ЮФО','СКФО','ПФО','УФО','СФО','ДФО']; const regionSel = el('filterRegion'); if(regionSel.options.length<=1){ regions.forEach(r=>{ const o=document.createElement('option'); o.value=o.textContent=r; regionSel.appendChild(o);});} const tbody = el('registryTbody'); tbody.innerHTML=''; const q = el('searchInput').value.toLowerCase(); const st = el('filterStatus').value; const reg = el('filterRegion').value; const rows = state.data.requests.filter(r=>{ const matchQ = !q || (r.company+r.number+r.address).toLowerCase().includes(q); const matchS = !st || r.status===st; const matchR = !reg || r.region===reg; return matchQ && matchS && matchR; }); rows.sort((a,b)=> b.date - a.date); rows.forEach(r=>{ const tr = document.createElement('tr'); tr.className='border-t'; tr.innerHTML = ` <td class='p-2'>${r.id}</td> <td class='p-2'>${fmtDate(r.date)}</td> <td class='p-2 font-mono'>${r.number}</td> <td class='p-2'>${r.company}</td> <td class='p-2'>${r.address}</td> <td class='p-2 text-center'>${r.tcCount}</td> <td class='p-2'>${r.region||'—'}</td> <td class='p-2'>${statusBadge(r.status)}</td> <td class='p-2'> <button class='text-blue-600 hover:text-blue-800 mr-2' data-view='${r.id}'>Просмотр</button> <button class='text-gray-600 hover:text-gray-800 mr-2' data-edit='${r.id}'>Редактировать</button> <button class='text-green-700 hover:text-green-900 mr-2' data-accept='${r.id}'>Принять</button> <button class='text-red-700 hover:text-red-900 mr-2' data-cancel='${r.id}'>Отменить</button> <button class='text-gray-700 hover:text-black mr-2' data-print='${r.id}'>Печать</button> <button class='text-gray-500 hover:text-black' data-del='${r.id}'>Удалить</button> </td>`; tbody.appendChild(tr); }); tbody.querySelectorAll('[data-edit]').forEach(b=> b.onclick=()=> openRequestModal( findReq(+b.dataset.edit) )); tbody.querySelectorAll('[data-view]').forEach(b=> b.onclick=()=> viewRequest( findReq(+b.dataset.view) )); tbody.querySelectorAll('[data-accept]').forEach(b=> b.onclick=()=> changeStatus(+b.dataset.accept,'in-progress')); tbody.querySelectorAll('[data-cancel]').forEach(b=> b.onclick=()=> changeStatus(+b.dataset.cancel,'rejected')); tbody.querySelectorAll('[data-print]').forEach(b=> b.onclick=()=> printRequest(findReq(+b.dataset.print)) ); tbody.querySelectorAll('[data-del]').forEach(b=> b.onclick=()=> deleteRequest(+b.dataset.del)); } function changeStatus(id, status){ const r = findReq(id); if(!r) return; const prev = r.status; r.status = status; saveAll(); renderRegistry(); renderStats(); renderMap(); logAction(`Статус заявки ${r.number} изменён: ${prev} → ${status}`); notify(`Статус ${r.number}: ${status}`); } function findReq(id){ return state.data.requests.find(r=>r.id===id); } function openRequestModal(data){ // fill selects const regions = ['ЦФО','СЗФО','ЮФО','СКФО','ПФО','УФО','СФО','ДФО']; const regionSel = el('reqRegion'); regionSel.innerHTML=''; regions.forEach(r=>{ const o=document.createElement('option'); o.value=o.textContent=r; regionSel.appendChild(o);}); const inspSel = el('reqInspectors'); inspSel.innerHTML=''; state.data.dicts.inspectors.forEach(n=>{ const o=document.createElement('option'); o.value=o.textContent=n; inspSel.appendChild(o);}); const dlCompanies = el('listCompanies'); dlCompanies.innerHTML=''; state.data.dicts.companies.forEach(n=>{ const o=document.createElement('option'); o.value=n; dlCompanies.appendChild(o);}); const dlAddresses = el('listAddresses'); dlAddresses.innerHTML=''; state.data.dicts.addresses.forEach(n=>{ const o=document.createElement('option'); o.value=n; dlAddresses.appendChild(o);}); el('invoiceArea').innerHTML=''; if(data){ el('modalRequestTitle').textContent = `Заявка ${data.number}`; el('reqCompany').value = data.company; el('reqDate').valueAsDate = new Date(data.date); el('reqNumber').value = data.number; el('reqAddress').value = data.address; el('reqTcCount').value = data.tcCount; el('reqServiceDates').value = data.serviceDates||''; el('reqRegion').value = data.region||''; Array.from(el('reqInspectors').options).forEach(o=> o.selected = data.inspectors?.includes(o.value)); (data.invoices||[]).forEach(addInvoiceRowFromData); el('requestForm').dataset.editId = data.id; } else { el('modalRequestTitle').textContent = 'Новая заявка'; el('requestForm').reset(); delete el('requestForm').dataset.editId; } el('modalRequest').classList.remove('hidden'); } function addInvoiceRow(){ const tpl = el('tplInvoice').content.cloneNode(true); el('invoiceArea').appendChild(tpl); } function addInvoiceRowFromData(inv){ addInvoiceRow(); const rows = el('invoiceArea').querySelectorAll('.grid'); const row = rows[rows.length-1]; row.querySelector('.invoice-number').value = inv.number||''; row.querySelector('.invoice-sum').value = inv.sum||''; row.querySelector('.invoice-date').value = inv.date||''; row.querySelector('.invoice-status').value = inv.status||'UNPAID'; } function viewRequest(r){ if(!r) return; openRequestModal(r); // Readonly view (lock fields) if both signatures present in act // For demo, just allow edit always } function deleteRequest(id){ const i = state.data.requests.findIndex(r=>r.id===id); if(i<0) return; const r = state.data.requests[i]; if(!confirm(`Удалить заявку ${r.number}?`)) return; state.data.requests.splice(i,1); saveAll(); renderRegistry(); renderStats(); renderMap(); logAction(`Удалена заявка ${r.number}`); } function requestFormToObj(){ const inspectors = Array.from(el('reqInspectors').selectedOptions).map(o=>o.value); const files = Array.from(el('reqDocs').files).map(f=>({name:f.name, size:f.size})); const invoices = Array.from(el('invoiceArea').querySelectorAll('.grid')).map(row=>({ number: row.querySelector('.invoice-number').value.trim(), sum: row.querySelector('.invoice-sum').value.trim(), date: row.querySelector('.invoice-date').value, status: row.querySelector('.invoice-status').value })); return { company: el('reqCompany').value.trim(), date: el('reqDate').valueAsDate?.getTime()||Date.now(), number: el('reqNumber').value.trim(), address: el('reqAddress').value.trim(), tcCount: +el('reqTcCount').value||0, serviceDates: el('reqServiceDates').value.trim(), region: el('reqRegion').value, inspectors, docs: files, invoices }; } function validateRequest(r){ if(!r.company||!r.date||!r.address||!r.number) return false; if(!r.tcCount||r.tcCount<1) return false; return true; } function saveRequest(e){ e.preventDefault(); const data = requestFormToObj(); if(!validateRequest(data)){ alert('Заполните обязательные поля'); return; } const editId = el('requestForm').dataset.editId; if(editId){ const r = findReq(+editId); Object.assign(r, data); logAction(`Изменена заявка ${r.number}`); } else { const id = genId(); state.data.requests.push({ id, status:'new', lat: guessLatLng(data.address).lat, lng: guessLatLng(data.address).lng, ...data }); logAction(`Создана заявка ${data.number}`); notify(`Новая заявка: ${data.number}`); } saveAll(); el('modalRequest').classList.add('hidden'); renderRegistry(); renderStats(); renderMap(); } function guessLatLng(address){ // Demo mapping if(address.includes('Санкт')) return {lat:59.93,lng:30.31}; if(address.includes('Москва')) return {lat:55.75,lng:37.62}; if(address.includes('Екатеринбург')) return {lat:56.83,lng:60.60}; if(address.includes('Владивосток')) return {lat:43.11,lng:131.87}; return {lat:58.5,lng:60}; } function printRequest(r){ const html = `<!doctype html><html><head><meta charset='utf-8'><title>${r.number}</title> <style>body{font-family:system-ui,-apple-system,Segoe UI,Roboto; padding:24px;} .badge{padding:2px 8px;border-radius:8px;border:1px solid #ddd;}</style> </head><body> <h2>Карточка заявки ${r.number}</h2> <div><span class='badge'>${r.company}</span> · ${r.address}</div> <div>Дата: ${fmtDate(r.date)} · ТК: ${r.tcCount} · Регион: ${r.region}</div> <div>Статус: ${r.status}</div> <hr/> <h3>Счета</h3> ${(r.invoices||[]).map(i=>`${i.number} · ${i.sum} · ${i.date} · ${i.status}`).join('<br>')} </body></html>`; const w = window.open('','_blank'); w.document.write(html); w.document.close(); w.focus(); w.print(); } // --- Dicts --- function renderDicts(){ const ulC = el('dictCompanies'); ulC.innerHTML=''; state.data.dicts.companies.forEach((n,i)=>{ const li=document.createElement('li'); li.className='flex items-center justify-between'; li.innerHTML=`<span>${n}</span><button class='text-red-500' data-del-company='${i}'>Удалить</button>`; ulC.appendChild(li); }); const ulA = el('dictAddresses'); ulA.innerHTML=''; state.data.dicts.addresses.forEach((n,i)=>{ const li=document.createElement('li'); li.className='flex items-center justify-between'; li.innerHTML=`<span>${n}</span><button class='text-red-500' data-del-address='${i}'>Удалить</button>`; ulA.appendChild(li); }); const ulI = el('dictInspectors'); ulI.innerHTML=''; state.data.dicts.inspectors.forEach((n,i)=>{ const li=document.createElement('li'); li.className='flex items-center justify-between'; li.innerHTML=`<span>${n}</span><button class='text-red-500' data-del-inspector='${i}'>Удалить</button>`; ulI.appendChild(li); }); ulC.querySelectorAll('[data-del-company]').forEach(b=> b.onclick=()=>{ state.data.dicts.companies.splice(+b.dataset.delCompany,1); saveAll(); renderDicts(); }); ulA.querySelectorAll('[data-del-address]').forEach(b=> b.onclick=()=>{ state.data.dicts.addresses.splice(+b.dataset.delAddress,1); saveAll(); renderDicts(); }); ulI.querySelectorAll('[data-del-inspector]').forEach(b=> b.onclick=()=>{ state.data.dicts.inspectors.splice(+b.dataset.delInspector,1); saveAll(); renderDicts(); }); } // --- Act --- function saveAct(){ const required = ['actNumber','actPlace','actDate','actTime','actReason','actContainerNo','actSerialNo','actAuthor','actDepotRep','actInspect1','actInspect2','actEquip']; for(const id of required){ if(!el(id).value){ alert('Заполните все обязательные поля акта'); return; } } notify('Акт обследования сохранён'); logAction('Сохранён акт обследования'); // Demo: lock editing when both signed if(el('signInspector').checked && el('signDepot').checked){ Array.from(el('actForm').elements).forEach(x=> x.disabled=true); notify('Документ заблокирован для редактирования'); } } function printAct(){ window.print(); } // --- Import/Export --- function exportJSON(){ const data = JSON.stringify(state.data.requests, null, 2); downloadFile(data, 'requests.json', 'application/json'); } function exportExcel(){ const rows = state.data.requests.map(r=>({ id:r.id, date:new Date(r.date).toISOString().slice(0,10), number:r.number, company:r.company, address:r.address, tcCount:r.tcCount, region:r.region, status:r.status })); const ws = XLSX.utils.json_to_sheet(rows); const wb = XLSX.utils.book_new(); XLSX.utils.book_append_sheet(wb, ws, 'Requests'); const wbout = XLSX.write(wb, {bookType:'xlsx', type:'array'}); downloadBlob(new Blob([wbout], {type:'application/octet-stream'}), 'requests.xlsx'); } function downloadFile(content, name, type){ const a=document.createElement('a'); a.href=URL.createObjectURL(new Blob([content],{type})); a.download=name; a.click(); URL.revokeObjectURL(a.href); } function downloadBlob(blob, name){ const a=document.createElement('a'); a.href=URL.createObjectURL(blob); a.download=name; a.click(); URL.revokeObjectURL(a.href); } function importJSONFile(file){ const reader = new FileReader(); reader.onload = () => { try{ const arr = JSON.parse(reader.result); if(Array.isArray(arr)) { state.data.requests = mergeById(state.data.requests, arr); saveAll(); renderRegistry(); renderStats(); renderMap(); notify('Импорт завершён'); logAction('Импорт заявок из JSON'); } else alert('Неверный формат файла'); }catch(e){ alert('Ошибка чтения файла'); } }; reader.readAsText(file); } function mergeById(oldArr, newArr){ const map = new Map(oldArr.map(x=>[x.id,x])); newArr.forEach(n=>{ if(map.has(n.id)) Object.assign(map.get(n.id), n); else map.set(n.id, n); }); return Array.from(map.values()); } // --- Online/Offline --- function updateOnlineStatus(){ const on = navigator.onLine; el('onlineIndicator').classList.toggle('hidden', !on); el('offlineIndicator').classList.toggle('hidden', on); state.data.isOnline = on; if(!on) notify('Оффлайн режим'); } // --- Events binding --- function bind(){ document.querySelectorAll('.nav-link').forEach(b=> b.onclick=()=> showScreen(b.dataset.target)); el('btnToggleSidebar').onclick = ()=> document.getElementById('sidebar').classList.toggle('hidden'); el('btnLogout').onclick = logout; // Registry el('btnAddRequest').onclick = ()=> openRequestModal(null); el('btnCloseModalRequest').onclick = ()=> el('modalRequest').classList.add('hidden'); el('btnCancelRequest').onclick = ()=> el('modalRequest').classList.add('hidden'); el('requestForm').onsubmit = saveRequest; el('btnAddInvoice').onclick = addInvoiceRow; el('searchInput').oninput = renderRegistry; el('filterStatus').onchange = renderRegistry; el('filterRegion').onchange = renderRegistry; // Import/Export el('btnExportJSON').onclick = exportJSON; el('btnExportExcel').onclick = exportExcel; el('importJson').onchange = (e)=>{ if(e.target.files[0]) importJSONFile(e.target.files[0]); }; // Dashboard el('btnNotifications').onclick = ()=> showScreen('dashboard'); el('btnClearNotifs').onclick = ()=> { state.data.notifs=[]; saveAll(); renderNotifs(); }; // Act el('btnSaveAct').onclick = saveAct; el('btnResetAct').onclick = ()=> el('actForm').reset(); el('btnPrintAct').onclick = printAct; // TC el('btnSaveTc').onclick = ()=>{ notify('Характеристики ТК сохранены'); logAction('Обновлены характеристики ТК'); }; el('btnSendTcForReview').onclick = ()=>{ el('tcStatus').value='review'; notify('Карточка ТК отправлена на проверку'); }; // Login el('loginForm').onsubmit = (e)=>{ e.preventDefault(); const ok = doLogin(el('loginEmail').value.trim(), el('loginPassword').value); if(!ok){ alert('Неверный логин или пароль'); } }; // Clear log el('btnClearLog').onclick = ()=>{ if(confirm('Очистить журнал?')){ state.data.log=[]; saveAll(); renderLog(); } }; // Dict add buttons document.querySelectorAll('[data-add-dict]').forEach(b=> b.onclick = ()=>{ const key = b.dataset.addDict; const val = prompt('Введите значение'); if(!val) return; state.data.dicts[key].push(val); saveAll(); renderDicts(); }); // Online status window.addEventListener('online', updateOnlineStatus); window.addEventListener('offline', updateOnlineStatus); } function renderLog(){ const ul = el('logList'); ul.innerHTML=''; state.data.log.slice(0,200).forEach(i=>{ const li = document.createElement('li'); li.className='border rounded-xl p-2 flex items-center justify-between'; li.innerHTML = `<div>${i.text} <span class='text-gray-400'>— ${i.user}</span></div><div class='text-xs text-gray-500'>${new Date(i.at).toLocaleString('ru-RU')}</div>`; ul.appendChild(li); }) } // --- After auth init --- function afterAuthInit(){ el('currentUserEmail').textContent = state.user?.email || ''; showScreen('dashboard'); renderStats(); renderMap(); renderNotifs(); renderDicts(); renderLog(); updateOnlineStatus(); } // --- Tiny unit tests (dev) --- function runUnitTests(){ console.group('Unit tests'); console.assert(validateRequest({company:'A',date:Date.now(),address:'B',number:'1',tcCount:1})===true,'validateRequest positive'); console.assert(validateRequest({company:'',date:Date.now(),address:'B',number:'1',tcCount:1})===false,'validateRequest requires company'); const merged = mergeById([{id:1,a:1}], [{id:1,a:2},{id:2,a:3}]); console.assert(merged.length===2 && merged.find(x=>x.id===1).a===2,'mergeById works'); console.groupEnd(); } // --- Bootstrap app --- (function init(){ AOS.init(); feather.replace(); loadAll(); seed(); bind(); checkAuth(); runUnitTests(); })(); </script> </body> </html>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Интерактивная панель заявок — Demo</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico" />
<!-- Tailwind -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Feather icons -->
<script src="https://unpkg.com/feather-icons"></script>
<!-- AOS -->
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet" />
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<!-- Leaflet -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"></script>
<!-- Leaflet MarkerCluster -->
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.css" />
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.5.3/dist/MarkerCluster.Default.css" />
<script src="https://unpkg.com/leaflet.markercluster@1.5.3/dist/leaflet.markercluster.js"></script>
<!-- SheetJS for Excel export -->
<script src="https://cdn.jsdelivr.net/npm/xlsx@0.18.5/dist/xlsx.full.min.js"></script>
<style>
.status-badge{padding:.125rem .5rem;border-radius:.5rem;font-size:.75rem;font-weight:600}
.status-new{background:#dbeafe;color:#1d4ed8}
.status-inprogress{background:#fef9c3;color:#92400e}
.status-completed{background:#dcfce7;color:#065f46}
.status-rejected{background:#fee2e2;color:#991b1b}
.toast{animation:slideIn .25s ease-out}
@keyframes slideIn{from{transform:translateX(120%);opacity:0}to{transform:translateX(0);opacity:1}}
.map-container{transition:all .3s ease}
.map-container:hover{box-shadow:0 10px 25px rgba(0,0,0,.1)}
/* Новые стили для синей темы */
.stat-card {
background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
color: white;
border-radius: 1rem;
padding: 1.25rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.nav-link.active {
background-color: #dbeafe;
color: #1e40af;
font-weight: 600;
}
.nav-link.active i {
color: #1e40af;
}
.btn-primary {
background-color: #2563eb;
color: white;
transition: all 0.2s;
}
.btn-primary:hover {
background-color: #1e40af;
}
.sidebar-header {
background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
color: white;
padding: 1rem;
border-radius: 1rem 1rem 0 0;
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<!-- Topbar -->
<header class="sticky top-0 z-40 bg-white border-b">
<div class="max-w-7xl mx-auto px-4 py-3 flex items-center justify-between">
<div class="flex items-center gap-3">
<button id="btnToggleSidebar" class="p-2 rounded-xl hover:bg-gray-100" aria-label="Меню">
<i data-feather="menu"></i>
</button>
<h1 class="text-xl font-semibold">Панель заявок</h1>
<span id="onlineIndicator" class="ml-3 px-2 py-1 rounded-full text-xs bg-green-100 text-green-700 hidden">Онлайн</span>
<span id="offlineIndicator" class="ml-3 px-2 py-1 rounded-full text-xs bg-yellow-100 text-yellow-700 hidden">Оффлайн</span>
</div>
<div class="flex items-center gap-3">
<button id="btnNotifications" class="relative p-2 rounded-xl hover:bg-gray-100">
<i data-feather="bell"></i>
<span id="notifDot" class="absolute -top-1 -right-1 w-2 h-2 rounded-full bg-red-500 hidden"></span>
</button>
<div class="flex items-center gap-2">
<div id="currentUserEmail" class="text-sm text-gray-600"></div>
<button id="btnLogout" class="text-sm text-gray-500 hover:text-gray-800">Выйти</button>
</div>
</div>
</div>
</header>
<!-- Layout -->
<div class="max-w-7xl mx-auto px-4 py-6 grid grid-cols-12 gap-6" id="appRoot">
<!-- Sidebar -->
<aside id="sidebar" class="col-span-12 md:col-span-3 lg:col-span-2 space-y-2 transition-all">
<nav class="bg-white rounded-2xl shadow overflow-hidden">
<div class="sidebar-header">
<h2 class="font-bold text-lg">Главная панель</h2>
</div>
<div class="p-3">