@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="regCapital" class="form-control" onchange="filter_company()">
                                        <option value="">注册资本</option>
                                        @foreach($fields['regCapital'] as $regCapital)
                                            <option value="{{$regCapital['value']}}"
                                                    @if($regCapital['value']== Request::get('regCapital')) selected @endif>{{$regCapital['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="startDate" class="form-control" onchange="filter_company()">
                                        <option value="">成立年限</option>
                                        @foreach($fields['startDate'] as $startDate)
                                            <option value="{{$startDate['value']}}"
                                                    @if($startDate['value']== Request::get('startDate')) selected @endif>{{$startDate['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="entType" class="form-control" onchange="filter_company()">
                                        <option value="">企业类型</option>
                                        @foreach($fields['entType'] as $entType)
                                            <option value="{{$entType['value']}}"
                                                    @if($entType['value']== Request::get('entType')) selected @endif>{{$entType['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>
                                <th>
                                    <select name="openStatus" class="form-control" onchange="filter_company()">
                                        <option value="">企业状态</option>
                                        @foreach($fields['openStatus'] as $openStatus)
                                            <option value="{{$openStatus['value']}}"
                                                    @if($openStatus['value']== Request::get('openStatus')) selected @endif>{{$openStatus['name']}}</option>
                                        @endforeach
                                    </select>
                                </th>

                                <th>
                                    <div class="input-group">
                                        <input type="text" class="form-control"
                                               value="{{Request::get('companyName')}}"
                                               placeholder="请输入企业名称"
                                               name="companyName">
                                        <span class="input-group-append">
                                                <span class="btn btn-sm btn-default"
                                                      style="height: 100%" onclick="filter_company()">搜索</span>
                                            </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