{% extends 'obj_form.html' %} {% load i18n %} {% load tj_filters %} {% block css %} {{ block.super }} {% endblock %} {% block js %} {{ block.super }} var cid='{{request.user.company_id}}'; $('.btn-save').click(function(){ $('#tb tr .company_id').val(cid); var store_fr_id=$('#id_store_fr').val(); var store_to_id=$('#id_store_to').val(); if(!$.isEmpty(store_fr_id)){ $('#tb tr .store_fr_id').val(store_fr_id); }; if(!$.isEmpty(store_to_id)){ $('#tb tr .store_to_id').val(store_to_id); }; $("#tb tr").each(function(){ var me=this; $(me).find('.vtype_id').val('{{form.instance.vtype_id}}'); var qty=$(me).find('.qty').val(); var unit=$(me).find('.unit').val(); if($.isEmpty(qty) || $.isEmpty(unit)){ $(me).find("[id$='-DELETE']").attr('checked', 'true'); }; }); {% if voucher.vendor_needed %} var vs=[]; $("#sel-vendor option").each(function (){ vs.push('{"id":'+$(this).val()+',"name":"'+$(this).text()+'"}'); }); $('#id_vendors').val('['+vs.join(',')+']'); {% endif %} $.SubmitForm('#obj_form form','{{request.path}}'); }); $('.select2_multiple').on('click','option',function(){ $(this).remove(); }); $('#label_order').autocomplete({ source: function(request, response) { $.ajax({ url: '/obj/ajax/autocomplete/mes_order/', dataType: "json", data: { term: $("#label_order").val() ,//搜索栏里的内容 company_id: {{request.user.company_id}} //额外参数 }, success: function(data) { response(data); } }); }, select: function (event, ui) { $("#id_order").val(ui.item.value); $("#label_order").val(ui.item.label); return false; } }); {% if voucher.customer_needed %} $('#id_customer').val('{{form.instance.customer_id}}'); $('#label_customer').val('{{form.instance.customer.name|default_if_none:""}}'); $('#label_customer').autocomplete({ source: function(request, response) { $.ajax({ url: '/obj/ajax/autocomplete/mes_customer/', dataType: "json", data: { term: $("#label_customer").val() ,//搜索栏里的内容 company_id: {{request.user.company_id}} //额外参数 }, success: function(data) { response(data); } }); }, select: function (event, ui) { $("#id_customer").val(ui.item.value); $("#label_customer").val(ui.item.label); return false; } }); {% endif %} {% if voucher.vendor_needed %} $('#label_vendor').autocomplete({ source: function(request, response) { $.ajax({ url: '/obj/ajax/autocomplete/mes_vendor/', dataType: "json", data: { term: $("#label_vendor").val() ,//搜索栏里的内容 company_id: {{request.user.company_id}} //额外参数 }, success: function(data) { response(data); } }); }, select: function (event, ui) { $("#id_vendor").val(ui.item.value); $("#label_vendor").val(ui.item.label); return false; } }); $('.add-vendor').click(function(){ var id=$('#id_vendor').val(); var label=$('#label_vendor').val(); if(id==''){ toastr.error("请先选择供应商!", "操作错误:", {timeOut: 800, positionClass: "toast-center-center"} ); return; }else{ var e=false; $("#sel-vendor option").each(function(){ if($(this).val() == id){ e=true; return false; } }); if(e){ toastr.error(label+"已在列表中!", "操作错误:", {timeOut: 800, positionClass: "toast-center-center"} ); return; }else{ $('#sel-vendor').append(""); } }; }); {% endif %} $('.datepicker').datepicker({dateFormat: 'yy-mm-dd'}); setDatePickerZh(); $('#id_dt_voucher').val('{{form.instance.dt_voucher|date:"Y-m-d"}}'); {% if form.instance.order %} $('#label_order').val('{{form.instance.order.code}}'); {% endif %} window.v_lb=''; window.v_id=''; $("#tb").on("focus",".mat_label", function (event) { $(this).autocomplete({ source: function(request, response) { window.v_lb=$(this.element)[0]; window.v_id=$(window.v_lb).closest('td').find('.mat_id'); $.ajax({ url: '/obj/ajax/autocomplete/materials/', 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; } }); }); $("#tb").on("focus",".pkg_label", function (event) { $(this).autocomplete({ source: function(request, response) { window.v_lb=$(this.element)[0]; window.v_id=$(window.v_lb).closest('td').find('.pkg_id'); $.ajax({ url: '/obj/ajax/autocomplete/packaging/', 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; } }); }); $("#tb").on("focus",".sem_label", function (event) { $(this).autocomplete({ source: function(request, response) { window.v_lb=$(this.element)[0]; window.v_id=$(window.v_lb).closest('td').find('.sem_id'); $.ajax({ url: '/obj/ajax/autocomplete/semifinishedgoods/', 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; } }); }); $("#tb").on("focus",".product_label", function (event) { $(this).autocomplete({ source: function(request, response) { window.v_lb=$(this.element)[0]; window.v_id=$(window.v_lb).closest('td').find('.fg_id'); $.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_stkdetails_set-'; var count = $('#tb tbody tr').length; var tmplMarkup = '
| {% trans '删除' %} | {{voucher.invtype_name}}名称 | {% trans '批次' %} | {% trans '数量 ' %} | {% trans '单位' %} | |||
|---|---|---|---|---|---|---|---|
| {{f.DELETE}} | {% ifequal voucher.invtype_id 2 %}{{ f.materials }} | {% endifequal %} {% ifequal voucher.invtype_id 3 %}{{ f.packaging }} | {% endifequal %} {% ifequal voucher.invtype_id 4 %}{{ f.semifinishedgoods }} | {% endifequal %} {% ifequal voucher.invtype_id 1 %}{{ f.product }} | {% endifequal %}{{ f.batch_no }} | {{ f.qty }} | {{ f.unit }} |