@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.渠道审核屏蔽ID白名单') }}
                </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.渠道审核屏蔽ID白名单') }}</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.渠道审核屏蔽ID白名单') }}</h4>
                            <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text" onclick="add()">
                                <i class="mdi mdi-plus btn-icon-prepend"></i>
                                {{ __('auto.添加游戏') }}ID
                            </button> &nbsp;&nbsp;&nbsp;

{{--                            {{ __('auto.开关：') }}--}}
{{--                            @if ($State->StatusValue == 1)--}}
{{--                                {{ __('auto.已开启') }}--}}
{{--                                <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="updateState(2)">--}}
{{--                                    {{ __('auto.关闭') }}--}}
{{--                                </button>--}}
{{--                            @else--}}
{{--                                {{ __('auto.已关闭') }}--}}
{{--                                <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="updateState(1)">--}}
{{--                                    {{ __('auto.开启') }}--}}
{{--                                </button>--}}
{{--                            @endif--}}



                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="5%">{{ __('auto.已新增的') }}ID</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->GameID}}</td>
{{--                                        <td>--}}
{{--                                            @if ($v->State == 1)--}}
{{--                                                {{ __('auto.开放中') }}--}}
{{--                                            @else--}}
{{--                                                {{ __('auto.关闭中') }}--}}
{{--                                            @endif--}}
{{--                                            @if ($v->State == 1)--}}
{{--                                                <button type="button" class="btn btn-sm btn-danger"--}}
{{--                                                        onclick="updateState({{$v->UserID}},2)">--}}
{{--                                                    {{ __('auto.关闭') }}--}}
{{--                                                </button>--}}
{{--                                            @elseif ($v->State == 2)--}}
{{--                                                <button type="button" class="btn btn-sm btn-primary"--}}
{{--                                                        onclick="updateState({{$v->UserID}},1)">--}}
{{--                                                    {{ __('auto.开启') }}--}}
{{--                                                </button>--}}
{{--                                            @endif--}}

{{--                                        </td>--}}

                                        <td contentEditable="true"
                                            onblur="remarks(this,{{$v->UserID}})">{{$v->Remarks}}</td>
                                        <td>
                                            <button class="btn btn-sm btn-gradient-dark" onclick="delFunc({{$v->UserID}})">
                                                {{ __('auto.删除') }}
                                            </button>

                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix" id="pages">
                                {{ __('auto.总共') }} <b>{{ $list->appends([
                                        'list'=>$list,

])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>

        function updateState(State) {

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

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

        function remarks(obj, ID) {
            let Remarks = $(obj).html();

            myRequest("/admin/channel/channel_shield_id_white_edit/" + ID, "post", {Remarks}, function (res) {
                layer.msg(res.msg)
                setTimeout(function () {
                    window.location.reload();
                }, 1500)
            });


        }

        function update(ChannelType, ChannelIndex, AndroidVersion, ChannelName) {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加备注') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/channel/update/' + ChannelType + '?ChannelIndex=' + ChannelIndex + '&ChannelName=' + ChannelName + '&AndroidVersion=' + AndroidVersion
            });
        }

        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.添加') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '50%'],
                content: '/admin/channel/channel_shield_id_white_add'
            });
        }


    </script>
@endsection
