@extends('base.base')
@section('base')
    <!-- 内容区域 -->
<style type="text/css">
    .table th{
      padding: 0.8375rem;
      vertical-align: top;
      border-top: 1px solid #ebedf2;
    }
    
</style>
    <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-settings"></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>
                            <form class="well form-inline margin-top-20" method="get" action='/admin/exchange/shop_goods'>
                                <span style="padding-left: 5px" >{{ __('auto.种类：') }}</span >
                                <select class="form-control" name="type" value="{{$type}}" style="color: black">
                                    <option value="">{{ __('auto.请选择种类') }}</option>
                                    @foreach($goods_type as $k=>$v)
                                        <option value="{{$k}}" @if($k===$type) selected @endif>{{$v}}</option>
                                    @endforeach
                                </select>
                                <input type="submit" class="btn btn-sm btn-gradient-dark btn-icon-text" value="{{ __('auto.搜索') }}"/>&nbsp;&nbsp;
                                <a href="/admin/exchange/shop_goods" class="btn btn-sm btn-gradient-warning btn-icon-text">{{ __('auto.清空') }}</a>&nbsp;&nbsp;
                                <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text" onclick="add()">
                                    <!-- <i class="mdi mdi-plus btn-icon-prepend"></i> -->
                                    {{ __('auto.新增') }}
                                </button>
                            </p>
                            </form>
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <th width="6%">{{ __('auto.商品种类') }}</th>
                                    <th width="4%">{{ __('auto.商品') }}ID</th>
                                    <th width="6%">{{ __('auto.商品名称') }}</th>
                                    <th width="6%">{{ __('auto.权重') }}</th>
                                    <th width="6%">{{ __('auto.商品价格（元）') }}</th>
                                    <th width="6%">{{ __('auto.兑换价格（福卡）') }}</th>
                                    <th width="6%">{{ __('auto.累计兑换') }}</th>
                                    <th width="6%">{{ __('auto.库存剩余') }}</th>
                                    <th width="6%">{{ __('auto.库存') }}</th>
                                    <th width="6%">{{ __('auto.每日限额') }}</th>
                                    <th width="6%">{{ __('auto.详情') }}</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($list as $k=>$v)
                                    <tr>
                                        <td>{{ $v->Type }}</td>
                                        <td>{{ $v->ID }}</td>
                                        <td>{{ $v->GoodsTitle }}</td>
                                        <td>{{ $v->GoodsShowIndex }}</td>
                                        <td>{{ $v->Money}}</td>
                                        <td>{{ $v->Ratio}}</td>
                                        <td>{{ $v->UsedAmount}}</td>
                                        <td>{{ $v->TotalAmount-$v->UsedAmount}}</td>
                                        <td>{{ $v->TotalAmount}}</td>
                                        <td>{{ $v->DayLimit}}</td>
                                        <td>
                                            <button type="button" class="btn btn-sm btn-gradient-success btn-icon-text" onclick="update({{ $v->ID }})">
                                            {{ __('auto.修改') }}
                                            </button>
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                            <div class="box-footer clearfix">
                                {{ __('auto.总共') }} <b>{{ $list->appends(['type'=>$type])->total() }}</b> {{ __('auto.条,分为') }}<b>{{ $list->lastPage() }}</b>{{ __('auto.页') }}
                                {!! $list->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function add(){
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.添加商品') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/shop_goods/add'
            });
        }
        function update(id){
            var page = layer.open({
                type: 2,
                title: '{{ __('auto.修改商品') }}',
                shadeClose: true,
                shade: 0.8,
                area: ['70%', '90%'],
                content: '/admin/shop_goods/update/'+id
            });
        }
        $('.menu-switch').click(function(){
            id = $(this).attr('id');
            state = $(this).attr('state');
            console.log(id)
            console.log(state)
            if(state == "on"){
                $('.pid-'+id).hide();
                $(this).attr("state","off")
                $(this).removeClass('mdi-menu-down').addClass('mdi-menu-right');
            }else{
                $('.pid-'+id).show();
                $(this).attr("state","on")
                $(this).removeClass('mdi-menu-right').addClass('mdi-menu-down');
            }
        })
    </script>
@endsection
