@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.捕鱼控制') }}</h4>

                            <form class="forms-sample" id="form">

                                <div>
                                    <label for="">{{ __('auto.控制等级：') }}<span style="color: red">（* -3 ~ 3）</span></label>
                                    <input type="number" class="form-control" name="controlLevel"
                                           value="{{$info['controlLevel']}}">

                                    <label for="">{{ __('auto.控制金额：') }}</label>
                                    <input type="number" class="form-control" name="controlTarget"
                                           value="{{$info['controlTarget']}}">

                                    <label for="">{{ __('auto.生效分数：') }}</label>
                                    <input type="number" class="form-control" name="curControlValue"
                                           value="{{$info['curControlValue']}}" disabled>

                                </div>

                                <br>
                                <button type="button" onclick="commit({{$UserID}})"
                                        class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    {{ __('auto.提交') }}
                                </button>
                                <button type="button" onclick="cancel()"
                                        class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    {{ __('auto.取消') }}
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>


        function commit(UserID) {
            if (!checkForm()) {
                return false;
            }

            var data = $("#form").serializeObject();
            if (data.controlLevel > 3 || data.controlLevel < -3) {
                layer.msg('{{ __('auto.控制等级不合法') }}');
                return false;
            }

            myRequest("/admin/Control/fish_add/" + UserID, "post", data, function (res) {
                if (res.code == '200') {
                    layer.msg(res.msg)
                    setTimeout(function () {
                        parent.location.reload();
                    }, 1500)
                } else {
                    layer.msg(res.msg)
                }
            });
        }

        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
