<!DOCTYPE html>
<html>

@include('admin.common_bak.commonMedia')

<body>

<!--====================================================
                         MAIN NAVBAR
======================================================-->
@include('admin.common_bak.header')

<!--====================================================
                        PAGE CONTENT
======================================================-->
<div class="page-content d-flex align-items-stretch">

    <!--***** SIDE NAVBAR *****-->
    @include('admin.common_bak.left')

    <div class="content-inner chart-cont">

        <div class="card form">
            <div class="card-header">
                <h3><i class="fa fa-user-circle"></i> 新建列表</h3>
            </div>
            <br>

            <!--***** CONTENT *****-->
            <div class="row" style="margin: 0 20px;">

                <div class="xblock">

                    <form method="get">
                        <a class="btn btn-primary" href="/web/news/create">添加</a>
                        <input type="text" class="form-input" name="title" value="{{$title}}" placeholder="搜索">
                        <!-- <select class="form-input" id="exampleSelect1">
                            <option>1</option>
                            <option>2</option>
                            <option>3</option>
                            <option>4</option>
                            <option>5</option>
                        </select> -->
                        <button type="submit" class="btn btn-primary">搜索</button>
                    </form>
                    <span style="display: inline-block;height: 40px;line-height: 40px; float: right">共{{$news_contents->total()}}
                        条</span>

                </div>


                <table class="table" id="test">
                    <thead>
                    <tr>
                        <th>
                            <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                                        class="layui-icon">&#xe605;</i></div>
                        </th>
                        <th>状态</th>
                        <th>新闻标题</th>
                        {{--<th>作者</th>--}}
                        {{--<th>新闻来源</th>--}}
                        <th>所属栏目</th>
                        <th>最新时间</th>
                        {{--<th>浏览量</th>--}}
                        <th>栏目<br>排序</th>
                        <th>首页<br>置顶</th>
                        <th>首页<br>排序</th>
                        <th>操作</th>
                    </thead>
                    <tbody>
                    @if(count($news_contents)>0)
                        @foreach ($news_contents as $k => $news_content)
                            <tr>
                                <td>
                                    <div class="layui-unselect layui-form-checkbox" lay-skin="primary"
                                         data-id='{{$news_content->id}}'><i class="layui-icon ">&#xe605;</i></div>
                                </td>
                                {{--<td>{{$news_content->id}}</td>--}}
                                <td>
                                    @include('admin.news.auditstatus')
                                </td>
                                <td>
                                    {{--点击一下置顶，取消置顶，点击一下轮播，取消轮播--}}
                                    @if($news_content->is_top == 'y') <font style="color: red"
                                                                            title="新闻置顶状态">[顶]</font>@endif
                                    @if($news_content->is_slide == 'y' && $news_content->	slide_type == 'home') <font
                                            style="color: red" title="新闻首页轮播">[首轮]</font>@endif
                                    @if($news_content->is_slide == 'y' && $news_content->	slide_type == 'column')
                                        <font style="color: red"
                                              title="新闻《{{$news_content->news_categories->title}}》栏目轮播">[栏轮]</font>@endif
                                    @if($news_content->is_hot == 'y' ) <font style="color: red"
                                                                             title="此条新闻为热门推荐新闻">[推荐]</font>@endif
                                    <a href="javascript:;"
                                       onclick="x_admin_show('新闻预览','/api/mobile/view_newsHtml/{{$news_content->id}}',400,550)"
                                       title="{{$news_content->title}}">{{str_limit($news_content->title,40,'')}}</a>
                                </td>
                                <td>{{$news_content->news_categories->title}}</td>
                                <td class="dbclicktd" data-id="{{$news_content->id}}"
                                    title="{{$news_content->new_datetime}}">{{substr($news_content->new_datetime,5)}}
                                    @if(Auth::user()->name==config('custom.supper_admin.name'))
                                        <a title="修改新闻发布时间" href="javascript:;"
                                           onclick="x_admin_show('修改新闻发布时间','/web/news/modify_newDatetime/{{$news_content->id}}/{{$news_content->title}}/{{$news_content->new_datetime}}',800,400)">
                                            <button class="layui-btn layui-btn-xs layui-btn-normal" title="修改此新闻的发布时间">
                                                改
                                            </button>
                                        </a>
                                    @else
                                        @ifHasPermission('news.modify_newDatetime')
                                        <a title="修改新闻发布时间" href="javascript:;"
                                           onclick="x_admin_show('修改新闻发布时间','/web/news/modify_newDatetime/{{$news_content->id}}/{{$news_content->title}}/{{$news_content->new_datetime}}',800,400)">
                                            <button class="layui-btn layui-btn-xs layui-btn-normal" title="修改此新闻的发布时间">
                                                改
                                            </button>
                                        </a>
                                        @endIfHasPermission
                                    @endif
                                </td>
                                {{--<td class="dbclicktd" ondblclick="sort_edit(this,'view_count')"
                                    data-id="{{$news_content->id}}">{{$news_content->view_count}}</td>--}}
                                <td class="dbclicktd" ondblclick="sort_edit(this,'sort')"
                                    data-id="{{$news_content->id}}">{{$news_content->sort}}</td>
                                <td>
                                    @if($news_content->hot_top =='y')<font color="red">是</font>@else否@endif
                                </td>
                                <td class="dbclicktd" ondblclick="sort_edit(this,'hot_sort')"
                                    data-id="{{$news_content->id}}">{{$news_content->hot_sort}}</td>
                                {{--@include('admin.news.setpoption')--}}


                                <td class="td-manage">
                                    @if(Auth::user()->name==config('custom.supper_admin.name'))
                                        <a title="编辑" href="/web/news/{{$news_content->id}}/edit"    >
                                            <i class="iconfont">&#xe609;</i>
                                        </a>
                                        <a title="删除" onclick="member_del(this,'{{$news_content->id}}')" href="javascript:;">
                                            <i class="iconfont">&#xe695;</i>
                                        </a>
                                        {{--<a title="" onclick="is_top(this,'{{$news_content->id}}','is_top','{{$news_content->is_top}}')" href="javascript:;">--}}
                                        {{--@if($news_content->is_top=='y')--}}
                                        {{--<button class="layui-btn layui-btn-xs layui-btn-normal" title="此新闻在栏目已经置顶">栏已顶</button>--}}
                                        {{--@else--}}
                                        {{--<button class="layui-btn layui-btn-xs" title="此新闻栏目未置顶">栏未顶</button>--}}
                                        {{--@endif--}}
                                        {{--</a>--}}
                                        {{--@if($news_content->is_hot=='y')--}}
                                        {{--<a title="" onclick="is_top(this,'{{$news_content->id}}','hot_top','{{$news_content->hot_top}}')" href="javascript:;">--}}
                                        {{--@if($news_content->hot_top=='y')--}}
                                        {{--<button class="layui-btn layui-btn-xs layui-btn-normal" title="此新闻在推荐栏目已经置顶">推已顶</button>--}}
                                        {{--@else--}}
                                        {{--<button class="layui-btn layui-btn-xs" title="此新闻推荐栏目未置顶">推未顶</button>--}}
                                        {{--@endif--}}
                                        {{--</a>--}}
                                        {{--@endif--}}
                                    @else
                                        @ifHasRole('admin|editor|one_auditor|two_auditor|report')
                                        @ifHasPermission('news.edit')

                                        <a title="编辑" href="/web/news/{{$news_content->id}}/edit" >
                                            <i class="iconfont">&#xe609;</i>
                                        </a>
                                        @endIfHasPermission
                                        @ifHasPermission('news.destroy')
                                        <a title="删除" onclick="member_del(this,'{{$news_content->id}}')" href="javascript:;">
                                            <i class="iconfont">&#xe695;</i>
                                        </a>
                                        @endIfHasPermission
                                        {{--<a title="" onclick="is_top(this,'{{$news_content->id}}','is_top','{{$news_content->is_top}}')" href="javascript:;">--}}
                                        {{--@if($news_content->is_top=='y')--}}
                                        {{--<button class="layui-btn layui-btn-xs layui-btn-normal" title="此新闻在栏目已经置顶">栏已顶</button>--}}
                                        {{--@else--}}
                                        {{--<button class="layui-btn layui-btn-xs" title="此新闻栏目未置顶">栏未顶</button>--}}
                                        {{--@endif--}}
                                        {{--</a>--}}
                                        @if($news_content->is_hot=='y')
                                            <a title="" onclick="is_top(this,'{{$news_content->id}}','hot_top','{{$news_content->hot_top}}')" href="javascript:;">
                                                @if($news_content->hot_top=='y')
                                                    <button class="layui-btn layui-btn-xs layui-btn-normal" title="此新闻在推荐栏目已经置顶">推已顶</button>
                                                @else
                                                    <button class="layui-btn layui-btn-xs" title="此新闻推荐栏目未置顶">推未顶</button>
                                                @endif
                                            </a>
                                        @endif


                                        @endIfHasRole
                                    @endif

                                    {{--<a title="" onclick="is_top(this,'{{$news_content->id}}','is_slide','{{$news_content->is_slide}}')" href="javascript:;">
                                      @if($news_content->is_slide=='y')
                                        <button class="layui-btn layui-btn-xs layui-btn-normal">已轮播</button>
                                      @else
                                        <button class="layui-btn layui-btn-xs">未轮播</button>
                                      @endif
                                    </a>--}}
                                    {{--<a title="修改浏览量" href="javascript:;" onclick="x_admin_show('修改浏览量','/web/news/changeViewCount/{{$news_content->id}}/{{$news_content->view_count}}/{{$news_content->title}}',400,300)"   >--}}
                                    {{--<i class="layui-icon">&#xe69e;</i>--}}
                                    {{--</a>--}}
                                </td>
                            </tr>
                        @endforeach
                    @else
                        <tr>
                            <td colspan="10" style="text-align:center">暂无数据</td>
                        </tr>
                    @endif
                    </tbody>
                </table>
                <div class="page">
                    <div>
                        {{$news_contents->appends(['start_time'=>$start_time,'end_time'=>$end_time,'title'=>$title,'category_id'=>$category_id])->links()}}
                    </div>
                </div>

            </div>
        </div>


    </div>
</div>

<!--Global Javascript -->
@include('admin.common_bak.foot')

<!--Core Javascript -->
<link rel="stylesheet" href="{{ asset('xadmin/extra/jqueryConfirm/css/jquery-confirm.css')}}">
<script src="{{ asset('xadmin/extra/jqueryConfirm/js/jquery-confirm.min.js')}}"></script>

<script src="{{ asset('xadmin/extra/toast/js/toast.js')}}"></script>
{{--<link rel="stylesheet" href="{{ asset('xadmin/extra/toast/css/toast.css')}}">--}}

<script src="{{ asset('xadmin/js/jquery.validate.js')}}"></script>

<script type="text/javascript">
    function x_admin_show(url) {
        window.location.href = url;

        // window.open(url);
    }

    /*权限-删除*/
    function member_del(row, id) {


        $.confirm({
            // confirmButtonClass: 'btn-info',
            // cancelButtonClass: 'btn-info',
            cancelButtonClass: 'btn-info',
            confirmButtonClass: 'btn-danger',


            confirm: function () {
                fetch_response('DELETE', "/web/news/" + id).then(function (res) {
                    $('body').toast({
                        position: 'fixed',
                        content: res.msg,
                        duration: 1000,
                        top: '50%'
                    });
                    setTimeout(function () {
                        window.location.href = '/web/news';
                    }, 2000)
                })

            },
            cancel: function () {
                $.alert('cancel triggered!');
            }
        });
    }


    $("tbody.x-cate tr[fid!='0']").hide();

    var cateIds = [];

    function getCateId(cateId) {

        $("tbody tr[fid=" + cateId + "]").each(function (index, el) {
            id = $(el).attr('cate-id');
            cateIds.push(id);
            getCateId(id);
        });
    }

    // 栏目多级显示效果
    $('.x-show').click(function () {
        if ($(this).attr('status') == 'true') {
            $(this).html('&#xe66b;');
            $(this).attr('status', 'false');
            cateId = $(this).parents('tr').attr('cate-id');
            $("tbody tr[fid=" + cateId + "]").show();
        } else {
            cateIds = [];
            $(this).html('&#xe79f;');
            $(this).attr('status', 'true');
            cateId = $(this).parents('tr').attr('cate-id');
            getCateId(cateId);
            for (var i in cateIds) {
                $("tbody tr[cate-id=" + cateIds[i] + "]").hide().find('.x-show').html('&#xe79f;').attr('status', 'true');
            }
        }
    })

</script>

</body>

</html>

