<!doctype html>
@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>
                        <form class="well form-inline margin-top-20" method="get"
                              action='/admin/return_water/config'>
                            <span style="padding-left: 5px">{{ __('auto.游戏：') }}</span>
                            <select class="form-control" name="kind_id" value="{{$kind_id}}" id="select"
                                    onchange="gradeChange(this.options[this.options.selectedIndex].value)">
                                <option value="">{{ __('auto.选择游戏') }}</option>
                                @foreach($game_name as $k=>$v)
                                    <option value="{{$k}}" @if($k==$kind_id) selected @endif >{{$v}}</option>
                                @endforeach
                            </select>
                            <span style="padding-left: 5px">{{ __('auto.房间：') }}</span>
                            <select class="form-control" name="game_level" value="" id="game_level">
                                <option value="">{{ __('auto.选择房间') }}</option>
                                @foreach($room_list as $k=>$v)
                                    <option value="{{$v->GameID}}-{{$v->SortID}}"
                                            @if(($v->GameID.'-'.$v->SortID)==$game_level) selected @endif>{{$v->RoomName}}</option>
                                @endforeach
                            </select> &nbsp;&nbsp;
                            <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                            <a href="/admin/return_water/config"
                               class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}&{{ __('auto.刷新') }}</a>

                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            {{ __('auto.用户最大额度配置：') }}
                            <button class="btn btn-sm btn-gradient-dark"
                                    onClick="return_water_gearFunc();return false;">{{ __('auto.修改') }}
                            </button>
                            &nbsp;&nbsp;&nbsp;
                            @if ($totalSwitch == 1)
                                {{ __('auto.已开启') }}&nbsp;
                                <button class="btn-sm btn btn-gradient-dark"  onclick="updateStatus(2);return false;">{{ __('auto.关闭') }}</button>
                            @else
                                &nbsp;{{ __('auto.已关闭') }}
                                <button class="btn-sm btn btn-gradient-dark" onclick="updateStatus(1);return false;">{{ __('auto.开启') }}</button>
                            @endif

                        </form>

                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th>{{ __('auto.游戏') }}ID</th>
                                <th>{{ __('auto.房间场次') }}</th>
                                <th>{{ __('auto.游戏名称') }}</th>
                                <th>{{ __('auto.游戏房间') }}</th>
                                <th>{{ __('auto.房间底分') }}</th>
                                <th>{{ __('auto.入场下限') }}</th>
                                <th>{{ __('auto.反水额度') }}</th>
                                <th>{{ __('auto.操作') }}</th>
                            </tr>
                            </thead>
                            <tbody>

                            {{ gamesButton('/admin/return_water/config') }}

                            @foreach($list as $k=>$v)
                                <tr>
                                    <td>{{ $v->GameID }}</td>
                                    <td>{{$v->SortIDTxt}}</td>
                                    <td>{{ $v->KindName }}</td>
                                    <td>{{ $v->RoomName }}</td>
                                    <td>{{$v->CellScore}}</td>
                                    <td>{{$v->MinEnterScore}}</td>
                                    <td>
                                        @if (!empty($v->Rate))
                                            {{$v->Rate}} %
                                        @else

                                        @endif
                                    </td>

                                    <td>

                                        <button type="button"
                                                class="btn btn-sm btn-gradient-danger btn-icon-text"
                                                onclick="update({{$v->GameID}},{{$v->SortID}})">
                                            {{ __('auto.修改') }}
                                        </button>

                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                        <div class="box-footer clearfix">
                            {{ __('auto.总共') }} <b>{{ $list->appends([
    'kind_id'=>$kind_id,
    'gameType' => $gameType,
    'game_level' => $game_level
    ])->total() }}</b>
                            {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                            {!! $list->links() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    function updateStatus(status) {

        myConfirm("{{ __('auto.是否继续') }}?", function () {
            myRequest("/admin/return_water/total_switch", "post", {status}, function (res) {
                if (res.code == '200') {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                } else {
                    layer.msg(res.msg)
                }
            });
        });

    }

    function return_water_gearFunc() {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.查看配置') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['60%', '70%'],
            content: '/admin/return_water/gear'
        });
    }

    // 配置修改
    function update(GameID, SortID) {

        var page = layer.open({
            type: 2,
            title: '{{ __('auto.配置修改') }}',
            shadeClose: true,
            shade: 0.8,
            area: ['50%', '40%'],
            content: '/admin/return_water/update/' + GameID + '?SortID=' + SortID
        });

    }

    function gradeChange(value) {

        myRequest("/admin/group_control/roomList", "post", {'GameID': value}, function (res) {
            var data = res.data
            var html = ''
            for (var i of data) {
                html += '<option value=' + i['GameID'] + '-' + i['SortID'] + '>' + i['RoomName'] + '</option>'
            }
            console.log(html)
            $("#game_level").html(html)
        });
    }

</script>
@endsection
