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

    <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.增加档位配置') }}
    </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->ChargeMin}} {{ __('auto.到') }} {{$val->ChargeMax}}</td>
                <td>{{ __('auto.每日最大累计返回上限：') }}{{$val->BetMax ?? 0}}</td>

                <td>
                    <button class="btn btn-sm btn-gradient-dark" onclick="update({{$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
                </td>
            </tr>
        @endforeach

    </table>

@endsection

<script>
    function updateStatus(id, status) {

        myConfirm("{{ __('auto.是否继续') }}?", function () {
            myRequest("/admin/return_water/gear_status/" + 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(ID) {
        var page = layer.open({
            type: 2,
            title: '{{ __('auto.修改配置') }}',
            shadeClose: true,
            offset: 't',
            shade: 0.8,
            area: ['60%', '70%'],
            content: '/admin/return_water/gear_update/' + 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/return_water/gear_add'
        });
    }
</script>
