@extends('admin.layouts.app')
@section('header')
    <style>
        .company-info {
            border: 1px solid #eee;
            padding: 10px 0;
            margin-bottom: 10px;
            border-radius: 5px
        }

        .company-info p {
            margin-bottom: 0;
            font-size: 14px
        }

        .company-info p label {
            color: #aaa;
            font-weight: 400
        }

        .company-info p span {
            margin-right: 20px;
            color: #111
        }

    </style>
@endsection

@section('content')
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>挖掘线索</h5>

                    <div class="ibox-tools">
                        <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="form-group">
                        <div class="row">
                            <div class="col-sm-4">

                            </div>

                            {{--@if(role('Company/Info/collection'))--}}
                            {{--<div class="col-sm-8 pull-right">--}}
                            {{--<span class="btn btn-warning pull-right" onclick="save_collection()">保存为我的公海--}}
                            {{--</span>--}}
                            {{--</div>--}}
                            {{--@endif--}}

                        </div>
                    </div>


                    <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                        <tr>
                            <th> 过滤条件</th>
                            <form method="GET" action="" accept-charset="UTF-8" id="filter_company">
                                {{ csrf_field() }}
                                <th>
                                    <select name="district" class="form-control" onchange="filter_company()">
                                        <option value="">所在地区</option>
                                        @foreach($fields['district'] as $district)
                                            <option value="{{$district['value']}}"
                                                    @if($district['value'] == Request::get('district')) selected @endif>{{$district['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="industry" class="form-control" onchange="filter_company()">
                                        <option value="">所属行业</option>
                                        @foreach($fields['industry'] as $industry)
                                            <option value="{{$industry['value']}}"
                                                    @if($industry['value'] == Request::get('industry')) selected @endif>{{$industry['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="reg_capital" class="form-control" onchange="filter_company()">
                                        <option value="">注册资本</option>
                                        @foreach($fields['reg_capital'] as $reg_capital)
                                            <option value="{{$reg_capital['value']}}"
                                                    @if($reg_capital['value']== Request::get('reg_capital')) selected @endif>{{$reg_capital['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="start_date" class="form-control" onchange="filter_company()">
                                        <option value="">成立年限</option>
                                        @foreach($fields['start_date'] as $start_date)
                                            <option value="{{$start_date['value']}}"
                                                    @if($start_date['value']== Request::get('start_date')) selected @endif>{{$start_date['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="ent_type" class="form-control" onchange="filter_company()">
                                        <option value="">企业类型</option>
                                        @foreach($fields['ent_type'] as $ent_type)
                                            <option value="{{$ent_type['value']}}"
                                                    @if($ent_type['value']== Request::get('ent_type')) selected @endif>{{$ent_type['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="open_status" class="form-control" onchange="filter_company()">
                                        <option value="">企业状态</option>
                                        @foreach($fields['open_status'] as $open_status)
                                            <option value="{{$open_status['value']}}"
                                                    @if($open_status['value']== Request::get('open_status')) selected @endif>{{$open_status['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>

                                <th>
                                    <div class="input-group">
                                        <input type="text" class="form-control"
                                               value="{{Request::get('company_name')}}"
                                               placeholder="请输入企业名称"
                                               name="company_name">

                                        <span class="input-group-append">
                                                <button type="button" class="btn btn-sm btn-default"
                                                       onclick="filter_company()">搜索</button>
                                            </span>
                                    </div>
                                </th>
                            </form>
                        </tr>
                    </table>

                    <div id="company-list">
                        @include('admin.company.collection.data')
                    </div>

                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script type="text/javascript">
        /*对字段进行过滤*/
        function filter_company() {
            data = $('#filter_company').serialize()
            $.ajax({
                type: 'get',
                data: data,
            }).done(function (data) {
                $('#company-list').html(data.html)
            })
        }

        /*Ajax分页*/
        $('body').on('click', '.pagination a', function (e) {
            e.preventDefault();
            if ($(this).attr('href') != '#') {
                data = $('#filter_company').serialize()
                $.ajax({
                    url: $(this).attr('href'),
                    type: 'get',
                    data: data,
                }).done(function (data) {
                    $('#company-list').html(data.html)
                })
            }

        });

    </script>
@endsection