@extends('layouts.app')
@section('title')编辑-承运商@endsection

@section('content')
    <div id="nav2">
        @component('maintenance.menu')
        @endcomponent
        @component('maintenance.logistic.menu')
                <li class="nav-item">
                    <a class="nav-link" href="{{URL::current()}}" :class="{active:isActive('edit',4)}">修改</a>
                </li>
        @endcomponent
    </div>
    <div class="container-fluid">
        <div class="card">
            <div class="card-body">
                @if(Session::has('successTip'))
                    <div class="alert alert-success h1">{{Session::get('successTip')}}！</div>
                @endif
                <form method="POST" action='{{url("maintenance/logistic/{$logistic->id}")}}'>
                    @csrf
                    @method('PUT')
                    <div class="form-group row">
                        <label for="type" class="col-2 col-form-label text-right">承运商类型 <b class="text-danger">*</b></label>
                        <div class="col-5">
                            <select id="type" name="type" class="form-control @error('type') is-invalid @enderror" value="@if(old('type')){{old('type')}}@else{{$logistic->type}}@endif" required>
                                <option value="快递">快递</option>
                                <option value="物流">物流</option>
                                <option value="全部">全部</option>
                            </select>
                            @error('type')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="name" class="col-2 col-form-label text-right">承运商名称 <b class="text-danger">*</b></label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('name') is-invalid @enderror"
                                   name="name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$logistic->name}}@endif" required>
                            @error('name')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="english_name" class="col-2 col-form-label text-right">承运商英文名称</label>
                        <div class="col-8">
                            <input id="english_name" type="text" class="form-control"
                                   name="english_name" autocomplete="off" value="@if(old('name')){{old('name')}}@else{{$logistic->name}}@endif" >
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="code" class="col-2 col-form-label text-right">承运商代码 <b class="text-danger">*</b></label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('code') is-invalid @enderror"
                                   name="code" autocomplete="off" value="@if(old('code')){{old('code')}}@else{{$logistic->code}}@endif" required>
                            @error('code')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="is_bunched" class="col-2 col-form-label text-right">是否子母单</label>
                        <div class="col-8">
                            <input id="is_bunched" type="checkbox" name="is_bunched" class="switch" @if(old('is_bunched') ?? $logistic->is_bunched=='Y') checked @endif>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="mobile" class="col-2 col-form-label text-right">承运商电话</label>
                        <div class="col-8">
                            <input id="mobile" type="text" class="form-control @error('mobile') is-invalid @enderror"
                                   name="mobile" autocomplete="off" value="@if(old('mobile')){{old('mobile')}}@else{{$logistic->mobile}}@endif" >
                            @error('mobile')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $errors->first('mobile') }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="delivery_fee" class="col-2 col-form-label text-right">送货费</label>
                        <div class="col-8">
                            <input id="delivery_fee" type="text" class="form-control @error('delivery_fee') is-invalid @enderror"
                                   name="delivery_fee" autocomplete="off" value="@if(old('delivery_fee')){{old('delivery_fee')}}@else{{$logistic->delivery_fee}}@endif" >
                            @error('delivery_fee')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $errors->first('delivery_fee') }}</strong>
                            </span>
                            @enderror
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="remark" class="col-2 col-form-label text-right">备注</label>
                        <div class="col-8">
                            <textarea id="remark" type="text" class="form-control "
                                      name="remark" autocomplete="off" >@if(old('remark')){{old('remark')}}@else{{$logistic->remark}}@endif</textarea>
                        </div>
                    </div>
                    <div class="form-group row">
                        <div class="col-8 offset-2">
                            <input type="submit" class="btn btn-outline-dark form-control">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
@endsection
