{% extends 'obj_form.html' %} {% load i18n %} {% load tj_filters %} {% block css %} {{ block.super }} {% endblock %} {% block js %} {{ block.super }} var cid='{{request.user.company_id}}'; $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'}); setDatePickerZh(); {% if form.instance.id %} $('#id_dt_delivery').val('{{form.instance.dt_delivery|date:"Y-m-d"}}'); $('#label_agent').val('{{form.instance.agent.name}}'); {% else %} $('.datepicker').datepicker('setDate',new Date()); {% endif %} $('#label_agent').autocomplete({ source: function(request, response) { $.ajax({ url: '/obj/ajax/autocomplete/agent/', dataType: "json", data: { term: $("#label_agent").val() ,//搜索栏里的内容 company_id: cid ,//额外参数 }, success: function(data) { response(data); } }); }, select: function (event, ui) { $("#id_agent").val(ui.item.value); $("#label_agent").val(ui.item.label); return false; } }); $('.btn-save').click(function(){ $("#tb tr").each(function(){ var me=this; var pid=$(me).find('.id_product').val(); if($.isEmpty(pid)){ $(me).find("[id$='-DELETE']").attr('checked', 'true'); }; }); $.SubmitForm('#obj_form form','{{request.path}}'); }); window.v_lb=''; window.v_id=''; $("#tb").on("focus",".label_product", function (event) { $(this).autocomplete({ source: function(request, response) { window.v_lb=$(this.element)[0]; window.v_id=$(window.v_lb).closest('td').find('.id_product'); $.ajax({ url: '/obj/ajax/autocomplete/product/', dataType: "json", data: { term: $(v_lb).val() ,//搜索栏里的内容 company_id: cid ,//额外参数 }, success: function(data) { response(data); } }); }, select: function (event, ui) { $(window.v_id).val(ui.item.value); $(window.v_lb).val(ui.item.label); return false; } }); }); $('.btn-add').click(function(){ var prefix='#id_orderdetails_set-'; var count = $('#tb tbody tr').length; var tmplMarkup = '
| {% trans '删除' %} | {% trans '产成品名称' %} | {% trans '数量 (以成品最小单位计数)' %} |
|---|---|---|
| {{f.DELETE}} | {{ f.product }} | {{ f.qty }} |