@extends('base.base')
@section('base')

    <style>
        .form-control:disabled, .form-control[readonly] {
            background-color: white;
            opacity: 1;
        }
    </style>

    <h4 style="margin-left: 20px">
        {{ __('auto.请编辑游戏配置：') }}{{$showConfig->ServerName ?? ''}}
    </h4>

    <div class="form-control">

        <div>
            <div>
                <h4>

                    {{ __('auto.当日房间输赢：') }}{{$info->Winlost ?? 0}} {{ __('auto.当日房间流水：') }}{{$info->TurnOver ?? 0}} {{ __('auto.当前杀率：') }}{{$info->ShaLv ??0}} %

                    <a href="/admin/group_control/show_control_config/{{$info->GameID}}?SortID={{$info->SortID}}"
                       style="color: white">
                        <button class="btn btn-gradient-dark btn-sm">
                            {{ __('auto.刷新') }}
                        </button>
                    </a>
                </h4>


            </div>
            <div class="form-group" style="float:left;width: 48%">
                <label>* 入场下限</label>
                <input type="text" class="form-control required" name="BaseValue" placeholder="{{ __('auto.入场下限') }}"
                       value="{{$showConfig->MinEnterScore ?? 0}}" readonly>
            </div>
            <div class="form-group" style="float:right;width: 48%">
                <label>* 底分</label>
                <input type="text" class="form-control required" name="TopNum" placeholder="{{ __('auto.底分') }}"
                       value="{{$showConfig->CellScore ?? 0}}" readonly>
            </div>

        </div>

    </div>
    <br>
    <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text" onclick="add({{$GameID}},{{$SortID}})">
        <i class="mdi mdi-plus btn-icon-prepend"></i>
        {{ __('auto.增加控制档位') }}
    </button>
    <table class="table table-striped">
        @foreach($list as $key=>$val)
            <tr>
                <td colspan="5">{{ __('auto.档位') }}{{$key+1}}：{{$val->Name}}</td>
            </tr>
            <tr>
                <td>{{ __('auto.今日杀率：') }}{{$val->KillRateMin ?? 0}} {{ __('auto.到') }} {{$val->KillRateMax ?? 0}}</td>
                <td>{{ __('auto.平台赢概率：') }}{{$val->WinRate ?? 0}}</td>
                <td>{{ __('auto.平台输概率：') }}{{$val->LostRate ?? 0}}</td>
                <td>
                    <button class="btn btn-sm btn-gradient-dark" onclick="update({{$GameID}},{{$SortID}},{{$val->ID}})">
                        {{ __('auto.修改') }}
                    </button>
                </td>
                <td>

                    @if ($val->Status == 1)
                        {{ __('auto.已开启') }}
                        <button class="btn btn-sm btn-gradient-danger" onclick="updateStatus({{$val->ID}},2)">{{ __('auto.关闭') }}
                        </button>
                    @else
                        {{ __('auto.已关闭') }}
                        <button class="btn btn-sm btn-gradient-dark" onclick="updateStatus({{$val->ID}},1)">{{ __('auto.开启') }}</button>
                    @endif
                    <button class="btn btn-sm btn-gradient-dark" onclick="delFunc({{ $val->ID }})">{{ __('auto.删除') }}</button>
                </td>
            </tr>
        @endforeach

    </table>

@endsection

<script>
    function updateStatus(id, status) {

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

    }

    function update(GameID, SortID, ID) {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.修改配置') }}',
            shadeClose: true,
            offset: 't',
            shade: 0.8,
            area: ['60%', '70%'],
            content: '/admin/group_control/control_update/' + GameID + '?SortID=' + SortID + '&ID=' + ID
        });
    }

    function add(GameID, SortID) {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.添加配置') }}',
            shadeClose: true,
            offset: 't',
            shade: 0.8,
            area: ['60%', '70%'],
            content: '/admin/group_control/control_add/' + GameID + '?SortID=' + SortID
        });
    }

    function delFunc(ID) {
        myConfirm("{{ __('auto.是否继续') }}?", function () {
            myRequest("/admin/group_control/control_del/"+ID, "post", {}, function (res) {
                if (res.code == '200') {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                } else {
                    layer.msg(res.msg)
                }
            });
        });
    }
</script>
