@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" 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="{{$shop_data->GoodsTitle}}" 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="ratio" value="{{$shop_data->Ratio}}" 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="money" value="{{$shop_data->Money}}" placeholder="{{ __('auto.输入商品库存') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="exampleInputName1">*商品权重：</label>&nbsp;&nbsp;
                                        <input type="number" min="0" value="{{$shop_data->GoodsShowIndex}}" style="color: black;width: 500px;" class="form-control required" name="order" 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="total_amount" value="{{$shop_data->TotalAmount}}" placeholder="{{ __('auto.输入商品库存') }}">
                                    </div>
                                    <div class="form-inline" style="margin-top: 5px">
                                        <label for="DayLimit">*每日限额：</label>&nbsp;&nbsp;
                                        <input type="text" style="color: black;width: 500px;" class="form-control required" name="day_limit" value="{{$shop_data->DayLimit}}" placeholder="{{ __('auto.输入每日限额') }}">
                                    </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" value="{{$shop_data->EndDate}}" class="form-control required" />
                                    </div>

                                    <button type="button" onclick="commit({{$shop_data->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/shop_goods/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    if(res.code==200){
                        parent.location.reload();
                    }
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
