@extends('layouts.app')
@section('title')统计-退货管理@endsection

@section('content')
    <div id="nav2">
        @component('rejected.menu')@endcomponent
        @component('rejected.search.menu')@endcomponent
    </div>
    <div class="container-fluid" id="list">
        <div id="form_div"></div>
        <span class="dropdown m-1">
            <button
                    class="btn btn-outline-dark btn-sm form-control-sm dropdown-toggle tooltipTarget"
                    data-toggle="dropdown" title="导出所有页将会以搜索条件得到的筛选结果，将其全部记录（每一页）导出">
                导出Excel
            </button>
            <div class="dropdown-menu">
                <a class="dropdown-item" @click="exportExcel(false)"
                   href="javascript:">导出勾选内容</a>
                <a class="dropdown-item" @click="exportExcel(true)"
                   href="javascript:">导出所有页</a>
            </div>
        </span>
        <table class="table table-striped table-sm table-bordered table-hover td-min-width-80" style="background: #fff;" id="table">
            <tr v-for="(rejectedBill,index) in rejectedBills " :data-id="rejectedBill.id" @click="selectTableRow(index,$event)">
                <td>
                    <input type="checkbox" :value="rejectedBill.id_owner">
                </td>
                <td class="text-muted" style="opacity:0.7">
                    <span>@{{ index+1 }}</span>
                </td>
                <td>
                    <span>@{{ rejectedBill.owner_name }}</span>
                </td>
                <td class="text-muted">
                    <span>@{{ rejectedBill.bounce_amount }}</span>
                </td>
                <td class="text-success font-weight-bold">
                    <span>@{{ rejectedBill.check_amount }}</span>
                </td>
                <td>
                    <span>@{{ rejectedBill.bounce_amount-rejectedBill.check_amount }}</span>
                </td>
                <td class="text-success font-weight-bold">
                    <span>@{{ rejectedBill.in_storage_count }}</span>
                </td>
                <td>
                    <span>@{{ rejectedBill.not_in_storage_count }}</span>
                </td>
            </tr>
        </table>
    </div>
@endsection

@section('lastScript')
    <script src="{{mix('js/queryForm/export.js')}}"></script>
    <script src="{{mix('js/queryForm/queryForm.js')}}"></script>
    <script src="{{mix('js/queryForm/header.js')}}"></script>{{--新版2--}}
    <script>
        let vue = new Vue({
            el:"#list",
            data:{
                rejectedBills : {!! $rejectedBills !!},
                sum : '{{count($rejectedBills)}}',
                owners:[
                    @foreach($owners as $owner)
                    {name:'{{$owner->id}}',value:'{{$owner->name}}'},
                    @endforeach
                ],
                selectTr:''
            },
            mounted:function(){
                $(".tooltipTarget").tooltip({'trigger':'hover'});
                $('#list').removeClass('d-none');
                let uncheck_check = [{name:'0',value:'未审核数为0'},{name:'1',value:'未审核数不为0'}];
                let not_in_storage_check = [{name:'0',value:'未入库数为0'},{name:'1',value:'未入库数为不为0'}];
                let data=[
                    [
                        {name:'created_at_start',type:'dateTime',tip:'选择显示指定日期的起始时间'},
                        {name:'owner_id',type:'select_multiple_select',tip:['输入关键词快速定位下拉列表，回车确定','选择要显示的客户'],
                            placeholder:['货主','定位或多选货主'],data:this.owners},
                        {name:'uncheck_amount',type:"select",data:uncheck_check,tip:'未审核数',placeholder:'未审核数'},
                        {name:'not_in_storage',type:"select",data:not_in_storage_check,tip:'未入库数',placeholder:'未入库数'},
                    ],[
                        {name:'created_at_end',type:'dateTime',tip:'选择显示指定日期的结束时间'},
                    ]
                ];
                this.form=new query({
                    el:"#form_div",
                    condition:data,
                    isPaginations:false,
                });
                this.form.init();
                let column = [
                    {name:'index',value: '序号', neglect: true},
                    {name:'owner_name',value: '货主', neglect: true},
                    {name:'bounce_amount',value: '退件数', neglect: true, class:'text-muted'},
                    {name:'check_amount',value: '审核数', neglect: true, class:'text-success font-weight-bold'},
                    {name:'bounce_amount_check_amount',value: '未审核数', neglect: true},
                    {name:'in_storage_count',value: '入库数', neglect: true, class:'text-success font-weight-bold'},
                    {name:'not_in_storage_count',value: '未入库数', neglect: true},
                ];
                new Header({
                    el: "table",
                    name: "analyze",
                    column: column,
                    data: this.rejectedBills,
                    fixedTop:($('#form_div').height())+2,
                }).init();
            },
            methods:{
                selectTableRow(id,e){
                    $('#headerParent tr[class=focusing]').removeClass('focusing');
                    if (id === this.selectTr) {
                        this.selectTr = '';
                        return;
                    }
                    this.selectTr = id;
                    $(e.target).parent('tr').addClass('focusing')
                },
                exportExcel:function(checkAllSign){
                    let url = '{{url('rejected/exportAnalyze')}}';
                    let token='{{ csrf_token() }}';
                    excelExport(checkAllSign,checkData,url,this.sum,token);
                },
            },
        });
    </script>
@endsection
