@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 class="form-group">
                                    <label>签到天数</label>
                                    <input type="text" class="form-control" value="第 {{ $config->DayNumber }} 天" disabled>
                                    <small class="form-text text-muted">签到天数不可修改，只能删除后重新添加</small>
                                </div>
                                <div class="form-group">
                                    <label>* 奖励积分(单位:分)</label>
                                    <input type="number" class="form-control required" name="RewardScore" placeholder="请输入奖励积分" value="{{ $config->RewardScore }}" min="0">
                                    <small class="form-text text-muted">必填，非负整数</small>
                                </div>
                                <button type="button" onclick="commit({{ $config->DayNumber }})" 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(dayNumber){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/sign-in-reward/update/" + dayNumber, "post", data, function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                }, 1500)
            });
        }

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