
@extends('layouts.app')
@section('title')异常记录-包裹管理@endsection

@section('content')
    <span id="nav2">
        @component('weight.menu')@endcomponent
        @component('weight.weightExcepted.menu')@endcomponent
    </span>
    <div class="d-none" id="list">
        <div class="container-fluid">
            <div class="card">
                <div>
                    <form  method="GET" action="{{url('package/weightExcepted/'.$view)}}" id="optionSubmit">
                        <table class="table  table-sm table-bordered table-hover text-nowrap ">
                            <tr>
                                <td  style="width:200px;"> <div class="form-inline"><label style="margin-left: 2%" >页显示条数：</label>
                                    <select name="paginate" v-model="filterData.paginate" class="form-control-sm" @change="setPaginate">
                                        <option value="50">50行</option>
                                        <option value="100">100行</option>
                                        <option value="200">200行</option>
                                        <option value="500">500行</option>
                                        <option value="1000">1000行</option>
                                    </select></div></td>
                            </tr>
                            <tr>
                                <td >
                                    <label style="margin-left: 5px"> 操作选定记录：</label>
                                    <span class="dropdown">
                                        <button class="btn btn-sm form-control-sm dropdown-toggle tooltipTarget"
                                                data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果，将其全部记录（每一页）导出">
                                            导出Excel
                                        </button>
                                        <div class="dropdown-menu">
                                            <a class="dropdown-item" @click="weightExport(false)" href="javascript:">导出勾选内容</a>
                                            <a class="dropdown-item" @click="weightExport(true)" href="javascript:">导出所有页</a>
                                        </div>
                                    </span>
                                    <input hidden type="submit">
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            <div class="card-body">
                <table class="table table-striped table-sm text-nowrap td-min-width-80" id="table">
                    <tr v-for="(weightExcepted,i) in weightExcepteds" :style="weightExcepted.status=='上传异常'||weightExcepted.status=='下发异常'?'':color"
                        @click="selectTr===i+1?selectTr=0:selectTr=i+1" :class="selectTr===i+1?'focusing' : ''">
                        <td>
                            <input class="checkItem" type="checkbox" :value="weightExcepted.id">
                        </td>
                        <td><span>@{{ i+1 }}</span></td>
                        <td><span>@{{weightExcepted.logisticNumber}}</span></td>
                        <td><span>@{{weightExcepted.carrierName}}</span></td>
                        <td><span>@{{weightExcepted.batchNumber}}</span></td>
                        <td><span>@{{weightExcepted.batchRule}}</span></td>
                        @if($view=="indexIssued")
                            <td><span>@{{weightExcepted.ownerName}}</span></td>
                            <td><span>@{{weightExcepted.deliveryNumber}}</span></td>
                            <td class="text-muted"><span>@{{weightExcepted.createdAt}}</span></td>
                            <td><span>@{{weightExcepted.recipient}}</span></td>
                            <td><span>@{{weightExcepted.recipientMobile}}</span></td>
                        @else
                            <td><span>@{{weightExcepted.measuringMachineName}}</span></td>
                            <td class="text-muted"><span>@{{weightExcepted.weighedAt}}</span></td>
                            <td><span>@{{weightExcepted.weight}}</span></td>
                            <td><span>@{{weightExcepted.length}}</span></td>
                            <td><span>@{{weightExcepted.width}}</span></td>
                            <td><span>@{{weightExcepted.height}}</span></td>
                            <td><span>@{{weightExcepted.bulk}}</span></td>
                            <td><span>@{{weightExcepted.paperBoxName}}</span></td>
                            <td><span>@{{weightExcepted.status}}</span></td>
                        @endif
                    </tr>
                </table>
                <div class="text-info h5 btn btn">{{$weightExcepteds->count()}}/{{$weightExcepteds->total()}}</div>
                {{$weightExcepteds->links()}}
            </div>
        </div>
    </div>
    </div>
@endsection

@section('lastScript')
    <script type="text/javascript" src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
    <script type="text/javascript" src="{{mix('js/queryForm/export.js')}}"></script>
    <script>
        let vue = new Vue({
            el:"#list",
            data:{
                weightExcepteds:[
                    @foreach($weightExcepteds as $weightExcepted)
                        @if($view=="indexIssued")
                            {id:'{{$weightExcepted->id}}',ownerName:'{{$weightExcepted->owner_name}}',logisticNumber:'{{$weightExcepted->logistic_number}}',
                            deliveryNumber:'{{$weightExcepted->delivery_number}}',createdAt:'{{$weightExcepted->created_at}}',
                            batchNumber:'{{$weightExcepted->batch_number}}', batchRule:'{{$weightExcepted->batch_rule}}',recipient:'{{$weightExcepted->recipient}}',
                            recipientMobile:'{{$weightExcepted->recipient_mobile}}',carrierName:'{{$weightExcepted->logistic_name}}'},
                        @else
                            {id:'{{$weightExcepted->id}}',logisticNumber:'{{$weightExcepted->logistic_number}}',carrierName:'{{$weightExcepted->logistic_name}}',
                            measuringMachineName:'{{$weightExcepted->measuringMachine_name}}',weighedAt:'{{$weightExcepted->weighed_at}}',
                            weight:'{{$weightExcepted->weight}}', length:'{{$weightExcepted->length}}',width:'{{$weightExcepted->width}}',height:'{{$weightExcepted->height}}',
                            bulk:'{{$weightExcepted->bulk}}',paperBoxName:'{{$weightExcepted->paperBox_name}}',status:'{{$weightExcepted->status}}',},
                        @endif
                    @endforeach
                ],
                filterData:{paginate:50},
                color:'color: red',
                sum:{!! $weightExcepteds->total() !!},
                selectTr:0
            },
           mounted:function(){
               this.initInputs();
               $(".tooltipTarget").tooltip({'trigger':'hover'});
               $('#list').removeClass('d-none');
               let column = [
                   {name:'index',value: '序号', neglect: true},
                   {name:'logisticNumber',value: '快递单号'},
                   {name:'carrierName',value: '物流公司'},
                   {name:'batchNumber',value: '波次号'},
                   {name:'batchRule',value: '波次规则'},
                   @if($view=="indexIssued"){name:'ownerName',value: '货主'},
                   {name:'deliveryNumber',value: '发货单号'},
                   {name:'createdAt',value: '下发时间', class:"text-muted"},
                   {name:'recipient',value: '收件人'},
                   {name:'recipientMobile',value: '收件人电话'},
                   @else{name:'measuringMachineName',value: '设备'},
                   {name:'weighedAt',value: '称重时间', class:"text-muted"},
                   {name:'weight',value: '重(KG)', neglect: true},
                   {name:'length',value: '长(CM)', neglect: true},
                   {name:'width',value: '宽(CM)', neglect: true},
                   {name:'height',value: '高(CM)', neglect: true},
                   {name:'bulk',value: '体积(CM³)', neglect: true},
                   {name:'paperBoxName',value: '纸箱'},
                   {name:'status',value: '异常类型'},@endif
               ];
               new Header({
                   el: "table",
                   name: "weightExcepted",
                   column: column,
                   data: this.weightExcepteds,
               }).init();
            },
            methods:{
                initInputs:function(){
                    let data=this;
                    let uriParts =decodeURI(location.href).split("?");
                    if(uriParts.length>1){
                        let params = uriParts[1].split('&');
                        params.forEach(function(paramPair){
                            let pair=paramPair.split('=');
                            let key = pair[0], val = pair[1];
                            $('input[name="'+key+'"]').val(val);
                            $('select[name="'+key+'"]').val(val);
                            decodeURI(data.filterData[key]=val);
                        });
                    }
                },
                setPaginate:function(e){
                    this.filterData.paginate=e.target.value;
                    var form = document.getElementById("optionSubmit");
                    form.submit();
                },
                weightExport(checkAllSign){
                    let url = '{{url('package/weightExcepted/export/'.$view)}}';
                    let token='{{ csrf_token() }}';
                    excelExport(checkAllSign,checkData,url,this.sum,token);
                }
            }
        });
    </script>
@endsection
