@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.请编辑游戏配置：') }}{{$config->ServerName}}</h4>
                            {{--<p class="card-email">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                <div class="form-group" style="width: 55%;float: left">
                                    <label >* 档位基准值</label>
                                    <input type="text"  class="form-control required" name="BaseScore" placeholder="{{ __('auto.档位基准值') }}" value="{{ $config->BaseScore?? '' }}">
                                </div>

                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统赢的初始概率值</label>
                                    <input type="text"  class="form-control required" name="WinInitPercent" placeholder="{{ __('auto.系统赢的初始概率值') }}" value="{{ $config->WinInitPercent?? '' }}">
                                </div>
                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统输的初始概率值</label>
                                    <input type="text"  class="form-control required" name="LostInitPercent" placeholder="{{ __('auto.系统输的初始概率值') }}" value="{{ $config->LostInitPercent?? '' }}">
                                </div>
                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统赢增加概率/档位</label>
                                    <input type="text"  class="form-control required" name="WinBasePercent" placeholder="{{ __('auto.系统赢增加概率/档位') }}" value="{{ $config->WinBasePercent ?? ''}}">
                                </div>
                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统赢增加概率上限</label>
                                    <input type="text"  class="form-control required" name="WinMaxPercent" placeholder="{{ __('auto.系统赢增加概率上限') }}" value="{{ $config->WinMaxPercent ?? ''}}">
                                </div>
                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统输增加概率/档位</label>
                                    <input type="text"  class="form-control required" name="LostBasePercent" placeholder="{{ __('auto.系统输增加概率/档位') }}" value="{{ $config->LostBasePercent?? '' }}">
                                </div>
                                <div class="form-group" style="width: 50%;float: left">
                                    <label >* 系统输增加概率上限</label>
                                    <input type="text"  class="form-control required" name="LostMaxPercent" placeholder="{{ __('auto.系统输增加概率上限') }}" value="{{ $config->LostMaxPercent ?? '' }}">
                                </div>

                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();

            if (data.LostBasePercent > 100 || data.LostBasePercent < 0){
                layer.msg('{{ __('auto.系统赢的初始概率值区间为') }}0-100')
                return false;
            }
            if (data.LostInitPercent > 100 || data.LostInitPercent < 0){
                layer.msg('{{ __('auto.系统输的初始概率值区间为') }}0-100')
                return false;
            }
            if (data.LostMaxPercent > 100 || data.LostMaxPercent < 0){
                layer.msg('{{ __('auto.系统赢增加概率/档位区间为') }}0-100')
                return false;
            }
            if (data.WinBasePercent > 100 || data.WinBasePercent < 0){
                layer.msg(' {{ __('auto.系统赢增加概率上限区间为') }}0-100')
                return false;
            }
            if (data.WinInitPercent > 100 || data.WinInitPercent < 0){
                layer.msg('{{ __('auto.系统输增加概率/档位区间为') }}0-100')
                return false;
            }
            if (data.WinMaxPercent > 100 || data.WinMaxPercent < 0){
                layer.msg('{{ __('auto.系统输增加概率上限区间为') }}0-100')
                return false;
            }

            myRequest("/admin/gold/gameconfig/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
