{% load i18n %}


<style> 
    #tb .btn{
        margin-top:0px;
        margin-bottom:0px;
    }
    
    #tb tbody td span.r {
        color:red;
        font-weight:bold;
    }
    
    
</style>



<script type="text/javascript">
    $(document).ready(function(){ 
        var table;
        var clmns=[                 
            {'title':'batch_id', 'data':'batch_id'},  
            {'title':'公司名称', 'data':'factory'}, 
            {'title':'上传时间', 'data':'tm'},    
            {'title':'压缩文件名', 'data':'file_name'},             
            {'title':'大小(MB)', 'data':'file_size'},
            {'title':'txt总行数', 'data':'lines'}, 
            {'title':'实际写入', 'data':'cnt'},
            {'title':'操作人', 'data':'user'},
            {'title':'txt文件名', 'data':'txts'},            
            {'title':'备注说明', 'data':'remark'},
        ];
        var header='',footer='';
        for (var i in clmns){
            header=header+ '<th>'+clmns[i].title+'</th>';
            footer=footer+ '<th><input type="text" placeholder="'+clmns[i].title+'"></th> ';        
        };
        $('#tb heaer').html(header);
        $('#tb footer').html(footer);


        $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'});
        $('.datepicker').datepicker('setDate',new Date());
        setDatePickerZh();   

        function tbRefresh(){


            var cid=$('#sel-company').val();
            var dt_fr=$('#dt_fr').val();
            var dt_to=$('#dt_to').val();

            

            $.ajax({
                type:'GET',                           
                url:"/bottlecap/ajax/zip/uploadlog/?dt_fr="+dt_fr+"&dt_to="+dt_to,                
                dataType:'json',                
                success: function(d) {
                    if (d.e==''){
                        table=$('#tb').DataTable({
                            dom: 'Bfrtip',
                            autoWidth: true,
                            pageLength: 10,
                            buttons: [{extend:'excelHtml5',text: '导出到Excel'}],   
                            language:lng,	
                            columns:clmns,			
                            data:d.data,  
                            destroy:true,                            
                        });                         
    
                        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();
                                    }
                                });
                        }); 


                        // 隐藏batcg_id
                        $('#tb').DataTable().column(0).visible(false);
                        return false;
                        
                    }else{                        
                        toastr.error(
                            d.e,
                            "操作错误：",
                            {timeOut: 800, positionClass: "toast-center-center"}
                        );
                    }
                }
            });        
        };
        tbRefresh();
        $('.btn-qry').click(function(){
            tbRefresh();        
        });
        

        /*
        $('#tb').on("click",".btn-download",function(event){              
            var download_url=$(this).attr('href');  
            var tr=$(this).closest('tr');    
            var fn=$(tr).find('td:eq(5)').text();   

            $.ajax({
                type:'GET',                           
                url:download_url,               
                data: {filename: fn},
                xhrFields: {
                    responseType: 'blob'
                },
                success: function (data) {
                    var url = window.URL.createObjectURL(data);
                    var a = document.createElement('a');
                    a.href = url;
                    a.download = fn;
                    a.click();
                    window.URL.revokeObjectURL(url);                    
                }               
            });              

        });
        */

       
        
       
    });
</script>



<ol class="breadcrumb">
        <li>瓶盖码数据管理</li> 
        <li>绑定数据上传日志</li>            
</ol>




<div class='clear-fix'></div> 
<div class="x_panel">  
    <div class="form-inline" style='margin-bottom:15px;'>        
        <div class="col-sm-2 input-group">
            <span class="input-group-addon">{% trans "开始日期"%}</span>
            <input class="datepicker form-control" id="dt_fr" />
        </div>
        <div class="col-sm-2 input-group">
            <span class="input-group-addon">{% trans "结束日期"%}</span>
            <input class="datepicker form-control" id="dt_to" />
        </div>
        
        <div class='col-sm-2 input-group'>
            <button class='btn btn-primary btn-qry'  style='margin-top:3px;margin-left:20px'>查询</button>
        </div>
    </div>

    <div  class="table-responsive">
    <table id='tb'  class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
        <thead></thead>
        <tbody></tbody>
        <tfoot></tfoot>
    </table>
    </div>
    
</div>











