@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                        <i class="mdi mdi-settings"></i>
                    </span>
                    {{ __('auto.渠道审核修改') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.渠道管理') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.渠道审核修改') }}</li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.渠道审核修改') }}</h4>

                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th width="5%">{{ __('auto.渠道名称') }}</th>
                                        <th width="8%">{{ __('auto.审核状态') }}</th>
                                        <th width="8%">{{ __('auto.修改日期') }}</th>
                                        <th width="8%">{{ __('auto.允许开放地区') }}</th>
                                        <th width="8%">{{ __('auto.审核开关') }}</th>

                                    </tr>
                                    </thead>
                                    <tbody>
                                    @foreach($list as $k=>$v)
                                        <tr>
                                            <td>{{ $v->name }}</td>
                                            <td>
                                                @if ($v->status == 1)
                                                    {{ __('auto.开放中') }}
                                                @else
                                                    {{ __('auto.关闭中') }}
                                                @endif
                                            </td>
                                            <td>{{$v->updated_at}}</td>
                                            <td>{{$v->open_region}}</td>
                                            <td>
                                                @if ($v->status == 1)
                                                    <button type="button" class="btn btn-sm btn-danger" onclick="switch_control({{$v->id}},'off')">{{ __('auto.关闭') }}</button>
                                                @elseif ($v->status == -1)
                                                    <button type="button" class="btn btn-sm btn-primary" onclick="switch_control({{$v->id}},'on')">{{ __('auto.开启') }}</button>
                                                @endif

                                                <button class="btn btn-sm btn-gradient-dark" onclick="update_region({{$v->id}})">{{ __('auto.修改开放地区') }}</button>
                                            </td>


                                        </tr>
                                   @endforeach
                                    </tbody>
                                </table>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function switch_control(id,type){

            myConfirm("{{ __('auto.操作不可逆,是否继续') }}?",function(){
                myRequest("/admin/channel/switch/"+id,"post",{type},function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
        }

        function update_region(id) {
            layer.open({
                type: 2,
                title: '{{ __('auto.修改开放地区') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/channel/update/'+id
            });
        }


    </script>
@endsection
