@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>
                            <p class="card-description">
                                <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>
                            </p>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.菜单名称') }}</th>
                                    <th>
                                        {{ __('auto.条件') }}1 <br>
                                        {{ __('auto.累计咖啡额度') }}
                                    </th>
                                    <th>
                                        {{ __('auto.条件') }}2 <br>
                                        {{ __('auto.累计输赢之和额度') }}
                                    </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>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>{{$v->ConfigName}}</td>

                                        <td>{{$v->RechargeMin}} - {{$v->RechargeMax}}</td>
                                        <td>{{ __('auto.固定值：') }}{{ $v->ScoreWin }}</td>
                                        <td>
                                            @if ($v->ControlType == 1)
                                                <span style="color: red">{{ __('auto.输') }}</span>
                                            @else
                                                <span style="color: #0bb20c">{{ __('auto.赢') }}</span>
                                            @endif
                                        </td>
                                        <td>{{$v->ScoreBase}}</td>
                                        <td>{{$v->ProbBase}} %</td>
                                        <td>{{$v->ProbAdd}} %</td>
                                        <td>{{$v->ProbMax}} %</td>
                                        <td>
                                            <button class="btn btn-sm btn-gradient-dark" onclick="update({{$v->ID}})">
                                                {{ __('auto.修改') }}
                                            </button>
                                        </td>
                                        <td>
                                            @if ($v->Status == 1)
                                                <span style="color: #0bb20c"> {{ __('auto.已开启') }}</span>
                                            @elseif ($v->Status == 2)
                                                <span style="color: red">{{ __('auto.已关闭') }}</span>
                                            @endif
                                            @if ($v->Status == 1)
                                                <button type="button" class="btn btn-sm btn-danger"
                                                        onclick="switch_control({{$v->ID}},'off')">{{ __('auto.关闭') }}
                                                </button>
                                            @elseif ($v->Status == 2)
                                                <button type="button" class="btn btn-sm btn-primary"
                                                        onclick="switch_control({{$v->ID}},'on')">{{ __('auto.开启') }}
                                                </button>
                                            @endif
                                        </td>

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

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

        function add() {
            layer.open({
                type: 2,
                title: '{{ __('auto.增加个人档位') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '70%'],
                content: '/admin/recharge_control_config/add'
            });
        }

        function update(id) {
            layer.open({
                type: 2,
                title: '{{ __('auto.修改个人档位') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['50%', '70%'],
                content: '/admin/recharge_control_config/update/'+id
            });
        }

        function switch_control(id, type) {

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

        function update_sort(obj, id) {
            sort = $(obj).html();
            if (sort != '') {
                myRequest("/admin/recharge/update_sort/" + id, "post", {sort}, function (res) {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 1500)
                });
            } else {
                window.location.reload();
            }

        }

    </script>
@endsection
