{% load i18n %}






<script type="text/javascript">
    $(document).ready(function(){  
       
       
        var table=$('#tb-dlg').DataTable({
            //"lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
            //"bLengthChange":true,
            dom: 'Bfrtip',
            autoWidth: false,
            buttons: [{extend:'excelHtml5',text:'导出到Excel'}],           
            language:lng,           
            destroy:true,
            data:{{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();
                }
            });
        });         

        $('#sel-status').on('change',function(){
            $('.btn-save').removeClass('disabled');
            if($(this).val()=='{{order.status.id}}'){
                $('.btn-save').addClass('disabled');
            }else{
                $('.btn-save').removeClass('disabled');
            }
        });
        

        $('#sel-status').val('{{order.status.id}}');
        $('.btn-save').click(function(){            
             $.ajax({
                type:'POST',
                data: {'status_id':$('#sel-status').val()},
                url:'/mes/edit/order_status/{{order.id}}/',
                success:function(data){   
                    $("#bg-modal").modal('hide');
                    $.RefreshContent($('#url_list_order').val());
                }                       
            });        
        });
    });
</script>
<div style='font-size:15px;'>
    <div>
        <span class='lbl_tt'>订单编号:</span>
        <span style='min-width:150px;display:inline-block;color:green;'>{{order.code}}</span>
        <span class='lbl_tt'>客户名称:</span>
        <span style='min-width:150px;display:inline-block;color:green;'>{{order.agent.name}}</span>    
    </div>
    <div>
        <span class='lbl_tt'>交货日期:</span>
        <span  style='min-width:150px;display:inline-block;color:green;'>{{order.dt_delivery}}</span>
        <span class='lbl_tt'>当前状态:</span>
        <span style='min-width:150px;display:inline-block;color:green;'>
            <select id="sel-status">
                {% for s in data.status %}
                    <option value='{{s.0}}'>{{s.1}}</option>         
                {% endfor %}
            </select>
            <a class='btn btn-sm btn-primary btn-save disabled' >保存</a>
        </span>    
    </div>
</div>

<div class="clearfix"></div>
<div id="inventory-list" class="table-responsive">
    <div class='x_panel'>    
    <table id="tb-dlg" class="table table-striped table-bordered dt-responsive" width="100%" >
        <thead>
            {% for c in data.clmns %}
                <th>{{c}}</th>
            {% endfor %}                    
        </thead>
        <tbody></tbody>
        <tfoot>
           {% for c in data.clmns %}
                <th><input type="text" placeholder="{{c}}"></th>            
            {% endfor %}   
        </tfoot>
    </table>   
    </div>
</div>
