@extends('layouts.app')
@section('title')查询-自定义字段@endsection

@section('content')
    <span id="nav2">
        @component('rejected.menu')@endcomponent
        @component('rejected.customField.menu')@endcomponent
    </span>
    <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
                <table class="table table-striped table-sm" id="list">
                    <tr>
                        <th>ID</th>
                        <th>目标字段</th>
                        <th>字段显示名</th>
                        <th>对应权限</th>
                        <th>货主</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    <tr v-for="customField in customFields">
                        <td class="text-muted">@{{customField.id}}</td>
                        <td class="text-muted">@{{customField.field}}</td>
                        <td>@{{customField.present_name}}</td>
                        <td>@{{customField.authority_name}}</td>
                        <td>@{{customField.owner_name}}</td>
                        <td class="text-muted">@{{customField.created_at}}</td>
                        <td>
                            @can('自定义字段-编辑')
                            <button class="btn btn-sm btn-outline-primary" @click="edit(customField.id)">改</button> @endcan
                        </td>
                    </tr>
                </table>
                {{$customFields->links()}}
            </div>
        </div>
    </div>
@endsection

@section('lastScript')
    <script>
        new Vue({
            el:"#list",
            data:{
                customFields:[
                    @foreach( $customFields as $customField )
                    {id:'{{$customField->id}}',name:'{{$customField->name}}',code:'{{$customField->code}}',created_at:'{{$customField->created_at}}'},
                    @endforeach
                ],
            },
            methods:{
                edit:function(id){
                    location.href = "{{url('rejected/customField')}}/"+id+"/edit";
                },
            }
        });
    </script>
@endsection
