@extends('vip.layouts')
@section('content')
    <style>
        .layui-laydate-range {
            width: auto;
        }
    </style>
    <script type="text/html" id="title">
        @{{d.title}}
       
    </script>
    <!---注单管理-->
    <div class="layui-row">

        <!-- <div class="layui-col-xs12 layui-col-sm2 layui-col-md2">
            <ul id="tree" class="tree-table-tree-box"></ul>
        </div>-->
        <div class="layui-col-xs12 layui-col-sm12 layui-col-md12">

            <form class="layui-form rewrite" id="layui-form" eventType="eventForm" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('notice.title') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="title" id="title" eventType="event-query"  value="{{ $title }}" lay-verify="required" autocomplete="off"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('notice.type') }}</label>
                        <div class="layui-input-inline" id="layui-sel">
                            <select name="type" id="type" lay-verify="" autocomplete="off" eventType="event-query">
                                    <option value="">{{ trans('menu.select_menutype') }}</option>
                                @foreach(trans('status.article.type') as $k=>$v):
                                    <option value="{{$k}}" @if($k==$type) selected @endif>{{$v}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>
                   {{--<!--  <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('notice.add_startime') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="add_startime" id="add_startime" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" value="{{trans('status.default_time.atime')}}" eventType=event-query>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">{{ trans('notice.add_endtime') }}</label>
                        <div class="layui-input-inline">
                            <input type="text" name="add_endtime" id="add_endtime" placeholder=" - " lay-verify=""
                                   autocomplete="off" class="layui-input test-item" value="{{trans('status.default_time.etime')}}" eventType=event-query>
                        </div>
                    </div> -->--}}
                    <div class="layui-inline">
                        <!--<a class="layui-btn layui-btn-sm lay-btn-diy" id="sub"  eventType="event-query-submit"
                           style="opacity: 1; pointer-events: auto;">提交</a>-->
                        <a class="layui-btn layui-btn-sm lay-btn-diy" id="sub" style="opacity: 1; pointer-events: auto;">提交</a>
                        <a class="layui-btn   layui-btn-sm  layui-btn-normal reset" data-type="reload"
                           style="opacity: 1; pointer-events: auto;">重置</a>
                       <a class="layui-btn layui-btn-sm layui-btn-green set" data-type="reload"
                       style="opacity: 1; pointer-events: auto;"><i class="layui-icon">ဂ</i></a>
                    </div>
                    @if(checkRriv('/admin/Notice/addNotice'))<div class="layui-inline">
                        <a href="/admin/Notice/addNotice" class="layui-btn layui-btn-sm  ">添加</a>

                    </div>@endif
                    @if(checkRriv('/admin/Notice/delete'))<div class="layui-inline"><a href="javascript:delWin('/admin/Notice/delete?id=');" class="layui-btn layui-btn-sm  layui-btn-danger">删除</a></div>@endif
                </div>
            </form>
    </div>
        <script type="text/html" id="closeTool">
            <!-- 这里的 checked 的状态只是演示 -->
            @if(checkRriv('/admin/BankInfo/GameClose'))<input type="checkbox" name="status" value="@{{d.id}}" lay-skin="switch" lay-text="开启|禁用" lay-filter="openStatus"  @{{ d.status == '1' ? 'checked' : '' }}>@endif
        </script>

            @push('dataTableJS')
//                var active = {
//                reload: function(){
//                //执行重载
//                table.reload('{{ $dataId }}', {
//            page: {
//                curr: 1 //重新从第 1 页开始
//                }
//                ,where: {
///                title:$("#title").val(),
//                type:$('#type').val(),
//                add_startime:$('#add_startime').val(),
//                add_endtime:$('#add_endtime').val(),
//                }
//                });
//                }
//                };
//                $('.lay-btn-diy').on('click', function(){
//                var type = $(this).data('type');
//                active[type] ? active[type].call(this) : '';
//                });

                $('#sub').on('click', function(){
                    var title = $('#title').val();
                    var type = $('#type').val();

                    if((title == '' || title == null) && (type == '' || type == null) )
                    {
                        layer.tips('请填写标题','#title',{
                            tips: 3
                        });
                    }
                    else
                    {
                        $('#layui-form').submit();
                    }
                });

                //重置表单
                $('.reset').on('click',function(){
                $('input').val('');
                $('#type').val('');
               // var type = $(this).data('type');
               // active[type] ? active[type].call(this) : '';
                });

                //刷新表单
              //  $('.set').on('click',function(){
             //   var type = $(this).data('type');
            //    active[type] ? active[type].call(this) : '';
            //    });
            form.on('switch(openStatus)', function(obj){
            var status = 0;
            if(obj.elem.checked==true){
            status =1;
            }

            setcolumn('/admin/Notice/activeClose',this.name,status,this.value,obj);
        console.log(obj);
            //layer.tips(msg, obj.othis);
            });

            function setcolumn(url,column,value,id,obj){

            $.ajax({
            url: url+'?'+column+'='+value+'&id='+id,
            dataType: 'json',
            type: 'get',
            success:function(data){
            layer.msg(data.msg);
            if(data.status!=1){
            if(value==1){
            obj.othis[0].setAttribute("class", "layui-unselect layui-form-switch");
            obj.othis[0].innerHTML='<em>开启</em><i></i>';
            }else{
            obj.othis[0].setAttribute("class",'layui-unselect layui-form-switch layui-form-onswitch');
            obj.othis[0].innerHTML='<em>禁用</em><i></i>';
            }
            }
            },
            error:function(){
            }

            });
            }


        @endpush

            @include('vip.datatable')
            <link rel="stylesheet" href="{{ asset('/css/untablelist.css') }}"  />
        </div>
    </div>

@endsection
