{% extends 'obj_form.html' %}
{% load i18n %}
{% load tj_filters %}

    {% block js %}
        {{ block.super }}    
        $('.btn-save').click(function(){
            $.SubmitForm('#obj_form form','{{request.path}}');
        });

        $('#product_label').autocomplete({            
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/product/',
                    dataType: "json",
                    data: {
                        term: $("#product_label").val() ,//搜索栏里的内容
                        company_id:{{request.user.company_id}} //额外参数
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                $("#id_product").val(ui.item.value);
                $("#product_label").val(ui.item.label);
                return false;
            }
        });
        $('#agent_label').autocomplete({            
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/agent/',
                    dataType: "json",
                    data: {
                        term: $("#agent_label").val() ,//搜索栏里的内容
                        company_id:{{request.user.company_id}} //额外参数
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                $("#id_agent").val(ui.item.value);
                $("#agent_label").val(ui.item.label);
                return false;
            }
        });
        $('#store_label').autocomplete({            
            source: function(request, response) {
                $.ajax({
                    url: '/obj/ajax/autocomplete/store/',
                    dataType: "json",
                    data: {
                        term: $("#store_label").val() ,//搜索栏里的内容
                        company_id:{{request.user.company_id}} //额外参数
                    },
                    success: function(data) {
                        response(data);
                    }
                });
            },
            select: function (event, ui) {
                $("#id_store").val(ui.item.value);
                $("#store_label").val(ui.item.label);
                return false;
            }
        });




    {% endblock %}


    {% block subtitle-1 %}
        {% trans "物流工具" %}
    {% endblock %}
    {% block subtitle-2 %}
        {% trans "销售启票" %}
    {% endblock %}

    <span style="margin-left:10px; color:green; ">
        {% block subtitle-3 %}
            {% if form.instance.id %}
                {% trans "修改" %}
            {% else %}
                {% trans "新建" %}
            {% endif %}
        {% endblock %}
    </span>



{% block form_content %}
    {{ block.super }}
    <div class="form-group ">
        <label class="col-sm-2 control-label ">订单号 </label>
        <div class="col-sm-10">{{form.order_no}}</div>
    </div>
    
    <div class="form-group ">
        <label class="col-sm-2 control-label ">产品名称 </label>
        <div class="col-sm-10"><input type="text" class="form-control" id="product_label"
            {% if form.instance.id %} value="{{form.instance.product.name}}" {% endif %} >
        </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">经销商 </label>
        <div class="col-sm-10"><input type="text" class="form-control" id="agent_label"
            {% if form.instance.id %} value="{{form.instance.agent.name}}" {% endif %} >
        </div>            
            
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">仓库名称 </label>
        <div class="col-sm-10"><input type="text" class="form-control"  id="store_label"
            {% if form.instance.id %}  value="{{form.instance.store.name}}" {% endif %} >
        </div>
    </div>
    <div class="form-group ">
        <label class="col-sm-2 control-label ">发货数量</label>
        <div class="col-sm-10">{{form.qty}}</div>
    </div>


    <div  style="margin-top:20px;">      
        <a type="button" class='btn btn-primary btn-save' style="float:right;">
            <span class='glyphicon glyphicon-floppy-disk' style='padding-right:5px;'></span>{% trans '保存' %}
        </a>
    </div>    
   
{% endblock %}
