{% extends "fladmin/public/base.html" %}
{% block title %}文章列表{% endblock %}

{% block content %}
<h5 class="sub-header"><a href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/ArticleType/index">栏目管理</a> > 
    <a href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/index">文章列表</a> | <a
        href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/index?status=1">未审核文章</a> [ <a
        href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/add">发布文章</a> ]</h5>

<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
            <tr>
                <th>ID</th>
                <th>选择</th>
                <th>文章标题</th>
                <th>更新时间</th>
                <th>栏目</th>
                <th>点击</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for row in list %}
            <tr>
                <td>{{row.id}}</td>
                <td><input name="arcID" type="checkbox" value="{{row.id}}" class="np"></td>
                <td><a href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/edit?id={{row.id}}">{{row.title}}</a>
                    {% if row.litpic %}<small style='color:red'>[图]</small>{% endif %} {% if row.tuijian ==1 %} <small style='color:#22ac38'>[荐]</small> {% endif %}
                </td>
                <td>{{row.update_time|date}}</td>
                <td><a
                        href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/index?type_id={{row.type_id}}">{{row.type_name_text}}</a>
                </td>
                <td>{{row.click}}</td>
                <td><a target="_blank" href="/p/{{row.id}}">预览</a>&nbsp;<a
                        href="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/edit?id={{row.id}}">修改</a>&nbsp;<a
                        onclick="delconfirm('{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/del?id={{row.id}}')" href="javascript:;">删除</a>
                </td>
            </tr>
            {% endfor %}
            <tr>
                <td colspan="8">
                    <a href="javascript:selAll('arcID')" class="coolbg">反选</a>&nbsp;
                    <a href="javascript:delArc()" class="coolbg">删除</a>&nbsp;
                    <a href="javascript:tjArc()" class="coolbg">特荐</a>
                </td>
            </tr>
        </tbody>
    </table>
</div><!-- 表格结束 -->
<form id="searcharc" class="navbar-form" action="{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/index" method="get">
    <div class="form-group"><select class="form-control" name="type_id" id="type_id">
            <option value="0">选择栏目...</option>
                {% for row in article_type_list %}
                <option
                value="{{row.id}}">
                {% for i in range(row.deep|int) %}
                —
                {% endfor %}
                {{row.name}}</option>
                {% endfor %}
        </select></div>
    <div class="form-group"><input type="text" name="keyword" id="keyword" class="form-control required"
            placeholder="搜索关键词..."></div>
    <button type="submit" class="btn btn-info" value="Submit">搜索一下</button>
</form>
<ul class="pagination" style="margin: 0 20px 0 20px;">
</ul>

<script>
    //推荐文章
    function tjArc(aid) {
        var checkvalue = getItems();

        if (checkvalue == '') {
            alert('必须选择一个或多个文档！');
            return;
        }

        if (confirm("确定要推荐吗")) {
            location = "{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/recommendarc?id=" + checkvalue;
        } else {

        }
    }

    //批量删除文章
    function delArc(aid) {
        var checkvalue = getItems();

        if (checkvalue == '') {
            alert('必须选择一个或多个文档！');
            return;
        }

        if (confirm("确定删除吗")) {
            location = "{{'CMS_BASEHOST'|sysconfig}}/fladmin/article/del?id=" + checkvalue;
        } else {

        }
    }

    $(function () {
        $('.required').on('focus', function () {
            $(this).removeClass('input-error');
        });

        $("#searcharc").submit(function (e) {
            $(this).find('.required').each(function () {
                if ($(this).val() == "") {
                    e.preventDefault();
                    $(this).addClass('input-error');
                } else {
                    $(this).removeClass('input-error');
                }
            });
        });
    });
    //进行查询
    function query(e,page){
        window.location.href= '?page='+page
    }
    //这里回调
    $(".pagination").unbind();
    $(".pagination").pagination({
        total_pages:{{ page.total_page }},
        current_page:{{ page.current_page }},
        callback:query
    });
</script>
{% endblock %}