{% extends "bee_django_mission/base.html" %}
{% load bee_django_mission_filter %}

{% block content %}
    <div class="text-center"><h3>
        任务列表
    </h3>
    </div>
    <div class="text-right">
        <a class="btn btn-default" href="{% url 'bee_django_mission:mission_add' line_type=1 %}">添加里程碑</a>
        <a class="btn btn-default" href="{% url 'bee_django_mission:mission_add' line_type=2 %}">添加周任务</a>
    </div>
    <table class="table">
        <thead>
        <tr>
            <th></th>
            <th>分类</th>
            <th>任务类型</th>
            <th>名称</th>
            <th>添加时间</th>

        </tr>
        </thead>
        <tbody>
        {% for mission in mission_list %}
            <tr>
                <td>{{ forloop.counter }}</td>
                <td>{{ mission.stage.line.name }}-{{ mission.stage.name }}</td>
                <td>{{ mission.mission_type }}</td>
                <td>{{ mission.name|default:"" }}</td>
                <td>{{ mission.created_at|local_datetime|date:"Y-m-d H:i:s" }}</td>
                <td>
                    <a href="{% url 'bee_django_mission:mission_detail' mission.id %}  ">详情</a>
                    <a href="{% url 'bee_django_mission:mission_update' line_type=mission.stage.line.line_type pk=mission.id %}  ">修改</a>
                                        <a href="#" id="delete_{{ mission.id }}"
                                           data-confirm="{% url "bee_django_mission:mission_delete" mission.id %}"
                                           onclick="click_del(this)">删除</a>
                </td>
            </tr>

        {% endfor %}
        </tbody>
    </table>
    {% include 'bee_django_mission/paginator.html' %}
{% endblock %}
{% block scripts %}
    <script>
        function click_del(_this) {
            if (!confirm('确认要执行这个操作？')) {
                return false;
            }
            var url = $(_this).attr('data-confirm');
            $.post(url).done(function (data) {
                alert('删除成功!');
                location.reload();
            });
        }
    </script>
{% endblock %}