@extends('layouts.app')
@section('title')编辑-工作组@endsection

@section('content')
    <div id="nav2">
        @component('maintenance.menu')@endcomponent
        @component('maintenance.userWorkgroup.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 mt-3">
        <div class="card">
            <div class="card-body" id="list">
                <form method="POST" action='{{url("maintenance/userWorkgroup/{$userWorkgroup->id}")}}'>
                    @csrf
                    @method('PUT')
                    <div class="form-group row">
                        <label for="warehouse_id" class="col-2 col-form-label text-right">仓库名称</label>
                        <div class="col-8">
                            <select id="warehouse_id" type="text" v-model="userWorkgroup.warehouse_id" class="form-control" name="warehouse_id" autocomplete="off"  >
                                <option  v-for="warehouse in warehouses" :value="warehouse.id">@{{ warehouse.name }}</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="name" class="col-2 col-form-label text-right">工作组名称</label>
                        <div class="col-8">
                            <input type="text" class="form-control @error('name') is-invalid @enderror"
                                   name="name" autocomplete="off" :value="userWorkgroup.name" >
                            @error('name')
                            <span class="invalid-feedback" role="alert">
                                <strong>{{ $message }}</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">
                            <select id="remark" type="text" class="form-control @error('remark') is-invalid @enderror" name="remark" autocomplete="off"  >
                                <option :value="userWorkgroup.remark">@{{ userWorkgroup.remark }}</option>
                                <option value="是">是</option>
                                <option value="否" selected>否</option>
                            </select>
                            @error('remark')
                            <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                            @enderror
                        </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
@section('lastScript')
    <script>
        new Vue({
            el:'#list',
            data:{
                userWorkgroup:{
                    name:'{{old('name')?old('name'):$userWorkgroup->name}}',
                    warehouse_id:'{{old('warehouse_id')?old('warehouse_id'):$userWorkgroup->warehouse_id}}',
                    @if($userWorkgroup->signs)remark:'{{old('remark')?old('remark'):$userWorkgroup->signs['mark']}}',@endif
                },
                warehouses:[
                    @foreach($warehouses as $warehouse)
                    {id:'{{$warehouse->id}}',name:'{{$warehouse->name}}'},
                    @endforeach
                ],
            },
        });
    </script>
@endsection
