@extends('vip.layouts')
@section('content')
    <link href={{ asset("baidu/themes/default/css/umeditor.css") }} type="text/css" rel="stylesheet">
    <form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
        {!! csrf_field() !!}
        <div class="layui-form-item">
            <label class="layui-form-label">层级标题</label>
            <div class="layui-input-block">
                <input type="text" name="title" required lay-verify="required" autocomplete="off" class="layui-input"
                       value="{{isset($data['cate_name'])?$data['cate_name']:''}}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">上级目录</label>
            <div class="layui-input-block">
                <select name="type" id="testSelect" class="Selects" lay-filter="testSelect">

                    <option value="" selected>请选择</option>

                    @if(count($selectdata)>0)
                    @foreach ($selectdata as $k=>$v)

                        <option @if($v["id"]==$select) selected = "selected"  @endif value={{$v["id"]}} }}>{{$v["name"]}}</option>
                    @endforeach
                    @endif
                </select>
            </div>
        </div>





        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" required lay-verify="required" autocomplete="off" class="layui-input"  value="{{isset($data['sort'])?$data['sort']:''}}">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                @if(checkRriv('/admin/Notice/view'))<button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>@endif
                <button type="reset" class="layui-btn layui-btn-normal">重置</button>
            </div>
        </div>
    </form>
    <script type="text/javascript" src={{ asset("baidu/third-party/jquery.min.js") }}></script>
    <script type="text/javascript" charset="utf-8" src={{ asset("baidu/umeditor.config.js") }}></script>
    <script type="text/javascript" charset="utf-8" src={{ asset("baidu/umeditor.min.js") }}></script>
    <script type="text/javascript" src={{ asset("baidu/lang/zh-cn/zh-cn.js") }}></script>
    <script>
        //Demo
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;
            //图片上传接口
            layedit.set({
                uploadImage: {
                    url: '/admin/notice/upImg' //接口url
                    ,type: 'post' //默认post
                }
            });
            //var um = UM.getEditor('myEditor');
            var um = UM.getEditor('myEditor',{
                initialFrameWidth : 1000,
                initialFrameHeight: 400
            });
            /*var editIndex = layedit.build('LAY_demo_editor');*/
            form.verify({
                title: function(value){
                    if(value.length < 4){
                        return '标题至少得4个字符啊';
                    }
                }
                ,pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,content: function(value){
                    layedit.sync(editIndex);
                }
            });
            form.on('select(testSelect)', function(data){
               console.log(data.value);
               if (data.value==20) {
                    $('.single').show();
                    // $('#labels').hide();
               }else{
                   $('.single').hide();
                   // $('#labels').show();
               }
            });

            //监听提交
            form.on('submit(submitForm)', function (data) {
                return true;
            });


        });
        //创建一个编辑器
function cbFormSuccess(data){
	layer.msg(data.msg);
	setTimeout(function(){
        window.history.back(-1);
    },1);
}
</script>
@endsection
