{% load i18n %}

<script type="text/javascript">
    $(document).ready(function(){    
        var page_length=10;    

        var table=$('#tb').DataTable({
            dom: 'Bfrtip',
            autoWidth: true,
            pageLength: page_length,
            buttons: [{extend:'excelHtml5',text: '导出到Excel'}],   
            language:lng,          
            data:{{data|safe}}
        });     
        table.columns().every( function () {                        
            var that = this;             
            $('input', this.footer() ).on( 'keyup change clear', function () {
                if ( that.search() !== this.value ) {
                    that.search( this.value ).draw();
                }
            });
        });       
       
        $('#tb').on('click','.btn-vw',function(){    
            var url='/inventory/ajax/geo/store/'+$(this).attr('cid')+'/';   
            var agt=$(this).closest('tr').find('.agt').text();
            $.OpenDlg(url,"经销商仓库位置："+agt,1100,700);
        });  

        $('#tb').on('click','.btn-ck',function(){    
            var me=$(this);
            var id=$(me).attr('sid');
            var sn=$(me).attr('sn');
            $.ajax({
                type:'POST',   
                url:'{{request.path}}',
                data:{'id':id},
                beforeSend: function(xhr,setting) {xhr.setRequestHeader("X-CSRFToken","{{ csrf_token }}")},
                success:function(d){
                    $(me).remove();
                    toastr.success(sn+"仓库核准成功！",{timeOut: 800, positionClass: "toast-center-center"});                    
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert('连接服务器失败');
                    return;
                }
            });            
        });              
    });
</script>

<ol class="breadcrumb"><li>{{subtt.0}}</li><li>{{subtt.1}}</li></ol>

<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div  class="table-responsive">
            <table id='tb'  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
            <thead>
                {% for c in clmns %}
                    <th>{{c}}</th>
                {% endfor %}
            </thead>
            <tbody></tbody>
            <tfoot>
                {% for c in clmns %}
                    <th><input type="text" placeholder="{{c}}"></th>            
                {% endfor %}            
            </tfoot>
            </table>
        </div>
    </div>
</div>
