@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="page-header">
                <h3 class="page-title">
                     <span class="page-title-icon bg-gradient-primary text-white mr-2">
                <i class="mdi mdi-wrench"></i>
              </span>
                    {{ __('auto.兑换商城管理') }}
                </h3>
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="#">{{ __('auto.兑换管理') }}</a></li>
                        <li class="breadcrumb-item active" aria-current="page">{{ __('auto.兑换商城管理') }}</li>
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-lg-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">{{ __('auto.兑换商城管理') }}</h4>
                            
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th>{{ __('auto.商品种类') }}</th>
                                    <th>{{ __('auto.商品') }}ID</th>
                                    <th>{{ __('auto.商品名称') }}</th>
                                    <th>{{ __('auto.兑换价格（红包券）') }}</th>
                                    <th>{{ __('auto.累计兑换') }}</th>
                                    <th>{{ __('auto.库存剩余') }}</th>
                                    <th>{{ __('auto.库存') }}</th>
                                    <th>{{ __('auto.每日限额') }}</th>
                                    <th>{{ __('auto.操作') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td style="width: 10%">{{ $v->GoodsType }}</td>
                                        <td style="width: 10%">{{ $v->ID }}</td>
                                        <td style="width: 15%">{{ $v->GoodsTitle}}</td>
                                        <td style="width: 14%">{{ $v->Ratio}}</td>
                                        <td style="width: 10%">{{ $v->UsedAmount}}</td>
                                        <td style="width: 10%">{{ $v->Surplus}}</td>
                                        <td style="width: 10%">
                                            <input id="TotalAmount{{$v->ID}}" type="text" value="{{ $v->TotalAmount}}"></td>
                                        </td>
                                        <td style="width: 10%">
                                            <input id="DayLimit{{$v->ID}}" type="text" value="{{ $v->DayLimit}}"></td>
                                        </td>
                                        
                                        <td style="width: 5%">
                                            <button type="button" class="btn btn-sm btn-gradient-dark btn-icon-text" onclick="publish({{ $v->ID }})">
                                                {{ __('auto.修改') }}
                                                <i class="mdi mdi-file-check btn-icon-append"></i>
                                            </button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }} <b>{{ $list->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function publish(id){
            myConfirm("{{ __('auto.是否继续') }}?",function(){
                var day_limit = document.getElementById("DayLimit"+id).value;
                var total_amount = document.getElementById("TotalAmount"+id).value;
                var data = {'day_limit':day_limit,'total_amount':total_amount};
                myRequest("/admin/goods/update/"+id,"post",data,function(res){
                    layer.msg(res.msg)
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                });
            });
        }
    </script>
@endsection
