@switch($type)
    @case('image')
    <style>
        .hiddenSimage {
            display: none;
        }
    </style>
    <div class="layui-form-item">
        <label for="link" class="layui-form-label">
            <span class="x-red">*</span>{{$description}}
        </label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn" id="{{$name}}_button">
                <i class="layui-icon">&#xe67c;</i>上传图片
            </button>
        </div>
    </div>
        <div id="{{$name}}_simage" class="layui-form-item {{empty($value)? 'hiddenSimage': ''}}">
            <label  class="layui-form-label">缩略图
            </label>
            <input type="hidden" id="{{$name}}" name="{{$name}}" value="{{$value}}">
            <img id="{{$name}}_upload" width="400" src="{{$value}}">
        </div>
    @push('scripts')
        <script>
            layui.use([ 'upload'], function() {
                $ = layui.jquery;
                var upload = layui.upload;
                //执行实例
                var uploadInst = upload.render({
                    elem: '#{{$name}}_button' //绑定元素
                    ,url: '{{route('file.upload')}}' //上传接口
                    ,done: function(res){
                        console.log(res);
                        $('#{{$name}}_upload').attr('src', res.url);
                        $('#{{$name}}').val(res.url);
                        $('#{{$name}}_simage').removeClass('hiddenSimage');
                    }
                    ,error: function(){
                        //请求异常回调
                    }
                });
            });
        </script>
    @endpush
    @break
    @case('number')
    <div class="layui-form-item">
        <label for="link" class="layui-form-label">
            <span class="x-red">*</span>{{$description}}
        </label>
        <div class="layui-input-inline">
            <input type="number" id="{{$name}}" name="{{$name}}" required="" value="{{$value}}" lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    @break
    @case('select')
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>{{$description}}</label>
        <div class="layui-input-inline" >
            <select required="" name="{{$name}}">
                @foreach($options as $option)
                    @if ($value == $option['id'])
                        <option selected="selected" value="{{$option['id']}}">{{$option['name']}}</option>
                    @else
                        <option value="{{$option['id']}}">{{$option['name']}}</option>
                    @endif
                @endforeach
            </select>
        </div>
    </div>
    @break
    @case('text')
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">{{$description}}</label>
        <div class="layui-input-block">
                        <textarea id="{{$name}}" name="{{$name}}"
                                  placeholder="请输入内容" class="layui-textarea fly-editor" style="height: 260px;">{{$value}}</textarea>
        </div>
    </div>
    @push('scripts')
        <script>
            layui.use(['layedit', 'upload'], function(){
                layedit = layui.layedit;
                layedit.set({
                    uploadImage: {
                        url: "./upimg.json" //接口url
                        ,type: 'post' //默认post
                    }
                });
                //创建一个编辑器
                let index = layedit.build('{{$name}}');
                //layedit.getContent(index)

                setInterval(function (){
                    $('#{{$name}}').val(layedit.getContent(index));
                }, 1000)
            });
        </script>
    @endpush
    @break

    @case('categories')
    <div class="layui-form-item">
        <label class="layui-form-label"><span class="x-red">*</span>{{$description}}</label>
        <div class="layui-input-inline" >
            <select required="" name="{{$name}}">
                @foreach($categories as $category)
                    @if ($value == $category->id)
                        <option selected="selected" value="{{$category->id}}">{{$category->name}}</option>
                    @else
                        <option value="{{$category->id}}">{{$category->name}}</option>
                    @endif
                @endforeach
            </select>
        </div>
    </div>
    @break

    @case('password')
    <div class="layui-form-item">
        <label for="link" class="layui-form-label">
            <span class="x-red">*</span>{{$description}}
        </label>
        <div class="layui-input-inline">
            <input type="password" id="{{$name}}" name="{{$name}}" required="" value="{{$value}}" lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    @break

    @default
    <div class="layui-form-item">
        <label for="link" class="layui-form-label">
            <span class="x-red">*</span>{{$description}}
        </label>
        <div class="layui-input-inline">
            <input type="text" id="{{$name}}" name="{{$name}}" required="" value="{{$value}}" lay-verify="required"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
@endswitch
