@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-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.渠道：') }}{{$channel}}</h4>
                            <form class="forms-sample form-ajax" action="/admin/channel/update_pay_config/{{$channel}}"
                                  method="post" id="form">
                                <div class="form-group">
                                    <label for="">{{ __('auto.总开关') }}:</label>
                                    @component("components.select", [
                                                    'name' => "switch",
                                                    'class' => $switch == 1 ? 'btn-primary' : 'btn-danger',
                                                    'options' => [
                                                        1 => __('auto.开启'),
                                                        0 => __('auto.关闭')
                                                    ],
                                                    'default' => $switch
                                                ])
                                    @endcomponent
                                </div>
                                <table class="table table-bordered">
                                    <thead>
                                        <th>{{ __('auto.名称') }}</th>
                                        <th>{{ __('auto.状态') }}</th>
                                        <th>{{ __('auto.排序/权重') }}</th>
                                    </thead>
                                    <tbody>
                                    @foreach($list as $k=>$v)
                                        <tr>
                                            <input type="hidden" name="items[{{$k}}][id]" value="{{$v->id}}">
                                            <td>{{$v->name}}</td>
                                            <td>
                                                @component("components.select", [
                                                    'name' => "items[$k][status]",
                                                    'class' => $v->Status == 1 ? 'btn-primary' : 'btn-danger',
                                                    'options' => [
                                                        1 => __('auto.开启'),
                                                        2 => __('auto.关闭')
                                                    ],
                                                    'default' => $v->Status
                                                ])
                                                @endcomponent
                                            </td>
                                            <td>{{ __('auto.排序：') }}<input type="number" name="items[{{$k}}][sort]" class="form-control" value="{{$v->Sort}}"></td>
                                        </tr>
                                        @foreach($v->channels as $k1 => $v1)
                                            <tr>
                                                <input type="hidden" name="items[{{$k}}][channels][{{$k1}}][id]" value="{{$v1->id}}">
                                                <td style="text-indent: 30px;">
                                                    {{$v1->name}}
                                                </td>
                                                <td>@component("components.select", [
                                                        'name' => "items[$k][channels][$k1][status]",
                                                        'class' => $v1->Status == 1 ? 'btn-primary' : 'btn-danger',
                                                        'options' => [
                                                           1 => __('auto.开启'),
                                                            2 => __('auto.关闭')
                                                        ],
                                                        'default' => $v1->Status
                                                    ])
                                                    @endcomponent
                                                </td>
                                                <td>
                                                    {{ __('auto.权重：') }}
                                                    <input type="text" class="form-control"
                                                           name="items[{{$k}}][channels][{{$k1}}][sort]" value="{{$v1->Sort}}"></td>
                                                </td>
                                            </tr>
                                        @endforeach
                                    @endforeach
                                    </tbody>
                                </table>
                                <button class="btn btn-sm btn-primary">{{ __('auto.提交') }}</button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
