<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>大化重点项目工单管理平台</title>
    <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
    <link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/styles.css') }}">
</head>
<body>
    <nav class="navbar navbar-expand-lg nav_container">
        <div class="container-fluid">
            <a class="nav_brand">
                {% if request.endpoint == 'dispatch' %}
                    故障派单
                {% elif request.endpoint == 'receive' %}
                    在途工单
                {% elif request.endpoint == 'statistics' %}
                    工单统计
                {% elif request.endpoint == 'history' %}
                    历史工单
                {% elif request.endpoint == 'manual' %}
                    工单申报
                {% elif request.endpoint == 'dashboard' %}
                    设备仪表盘
                {% else %}
                重点项目工单管理平台
                {% endif %}
            </a>
            <button class="navbar-toggler nav_toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon nav_toggler_icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto mb-2 mb-lg-0 nav_menu">
                    {% if current_user.is_authenticated %}
                        {% if current_user.role in ['统计员', '管理员', 'admin'] or current_user.name == 'Admin' %}
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'dashboard' }}" href="{{ url_for('dashboard') }}">仪表盘</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'dispatch' }}" href="{{ url_for('dispatch') }}">派单</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'receive' }}" href="{{ url_for('receive') }}">在途</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'manual' }}" href="{{ url_for('manual') }}">申报</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'statistics' }}" href="{{ url_for('statistics') }}">统计</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'history' }}" href="{{ url_for('history') }}">历史</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'about' }}" href="{{ url_for('about') }}">关于</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'user_list' }}" href="{{ url_for('user_list') }}">用户管理</a>
                            </li>
                        {% elif current_user.role == '装维员' %}
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'dashboard' }}" href="{{ url_for('dashboard') }}">仪表盘</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'receive' }}" href="{{ url_for('receive') }}">在途</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'manual' }}" href="{{ url_for('manual') }}">申报</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'statistics' }}" href="{{ url_for('statistics') }}">统计</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'history' }}" href="{{ url_for('history') }}">历史</a>
                            </li>
                            <li class="nav-item">
                                <a class="nav_link {{ 'active' if request.endpoint == 'about' }}" href="{{ url_for('about') }}">关于</a>
                            </li>
                        {% endif %}
                    {% endif %}
                </ul>
                <ul class="navbar-nav nav_menu">
                    {% if current_user.is_authenticated %}
                        <li class="nav-item">
                            <a class="nav_link" href="{{ url_for('logout') }}">退出</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <div class="container mt-4">
        {% if not request.endpoint == 'login' %}
            {% with messages = get_flashed_messages() %}
                {% if messages %}
                    <div class="modal" id="flashModal" tabindex="-1" style="display: block; background: rgba(0,0,0,0.5);">
                        <div class="modal-dialog modal-dialog-centered" style="z-index: 1060;">
                            <div class="modal-content">

                                <div class="modal-body">
                                    {% for message in messages %}
                                        <p class="mb-0">{{ message }}</p>
                                    {% endfor %}
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-primary" onclick="closeFlashModal()">确定</button>
                                </div>
                            </div>
                        </div>
                    </div>
                {% endif %}
            {% endwith %}
        {% endif %}
        {% block content %}{% endblock %}
    </div>

    <script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
    <script>
    function closeFlashModal() {
        document.getElementById('flashModal').style.display = 'none';
    }
    </script>
</body>
</html>
