@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>
                            {{--<p class="card-message">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                    <div class="form-inline">
                                        <label for="exampleInputName1">*奖品分类：</label>&nbsp;&nbsp;
                                        <select class="form-control" name="goods_type" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择种类') }}</option>
                                            @foreach($goods_type as $k=>$v)
                                                <option value="{{$k}}" @if($k==$list->Currency) selected @endif >{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*奖品名称：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="title" value="{{$list->BonusName}}" placeholder="{{ __('auto.输入奖品名称') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*奖品类型：</label>&nbsp;&nbsp;
                                        <select class="form-control" name="prop_type" style="color: black;width: 500px;">
                                            <option value="">{{ __('auto.请选择类型') }}</option>
                                            @foreach($prop_type as $k=>$v)
                                                <option value="{{$k}}" @if($k==$list->PropType) selected @endif >{{$v}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*奖品数量：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="reward_num" value="{{$list->RewardNum}}" placeholder="{{ __('auto.输入奖品数量') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*兑换限额：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="limit" value="{{$list->LimitCount}}" placeholder="{{ __('auto.输入奖品价格') }}({{ __('auto.道具类型为红包时必填，其余类型为') }}0)">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*奖品图片：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="pic_url" value="{{$list->BonusURL}}" placeholder="{{ __('auto.输入奖品图片地址') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*奖品描述：</label>&nbsp;&nbsp;
                                        <textarea style="color: black;width: 500px;" class="form-control required" name="describe" rows="4" placeholder="{{ __('auto.输入奖品描述') }}">{{$list->GoodsDesc}}</textarea>
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*结束时间：</label>&nbsp;&nbsp;
                                        <input type="datetime-local" style="color: black;width: 500px;" name="time" class="form-control required" value="{{$list->EndTime}}" />
                                    </div>
                                    <button type="button" onclick="commit({{$list->ID}})" 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(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/treasure_goods/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
