<form class="layui-form x-center" action="" method="GET" style="width:800px">
    <div class="layui-form-pane" style="margin-top: 15px;">
        <div class="layui-form-item">
            @foreach($search_fields as $field)
            @switch($field['type'])
                @case('date')
                <label class="layui-form-label">{{$field['description']}}</label>
                <div class="layui-input-inline">
                    <input class="layui-input" placeholder="开始日" value="{{$field["value"][0]}}" name="{{$field['name']}}_input" id="{{$field['name']}}_input">

                    <input class="layui-input" type="hidden" placeholder="截止日" value="{{$field["value"][0]}}" name="{{$field['name']}}_s" id="{{$field['name']}}_s">
                    <input class="layui-input" type="hidden" placeholder="截止日" value="{{$field["value"][1]}}" name="{{$field['name']}}_e" id="{{$field['name']}}_e">
                </div>
                @push('scripts')
                    <script>
                        layui.use(['laydate'], function(){
                            $ = layui.jquery;//jquery
                            laydate = layui.laydate;//日期插件

                            let data = '{{$field["value"][0]}}';
                            let edate = '{{$field["value"][1]}}';
                            let range = '';
                            if (data != '' && edate != '') {
                                range = data+" - "+edate;
                            }
                            laydate.render({
                                elem: "#{{$field['name']}}_input"
                                ,type: 'datetime'
                                ,value: range
                                ,range: true //或 range: '~' 来自定义分割字符
                                ,done: function(value, date, endDate){
                                    //year month date  hours  minutes seconds
                                    $("#{{$field['name']}}_s").val(date.year+"-"+date.month
                                        +"-"+date.date+" "+date.hours+":"+date.minutes+":"+date.seconds);
                                    $("#{{$field['name']}}_e").val(endDate.year+"-"+endDate.month
                                        +"-"+endDate.date+" "+endDate.hours+":"+endDate.minutes+":"+endDate.seconds);
                                }
                            });
                        });
                    </script>
                @endpush
                @break
                @default
                <div class="layui-input-inline">
                    <input type="text" name="{{$field["name"]}}" value="{{$field["value"]}}" placeholder="{{$field['description']}}" autocomplete="off" class="layui-input">
                </div>
            @endswitch
            @endforeach
            <div class="layui-input-inline" style="width:80px">
                <button class="layui-btn" type="submit"><i class="layui-icon">&#xe615;</i></button>
            </div>
        </div>
    </div>
</form>
