{% extends 'obj_form.html' %}
{% load i18n %}
{% load tj_filters %}
{% block css %}
{{ block.super }}
#obj_form .my-lb{
margin-left:0px;
padding-left:0px;
}
{% endblock %}
{% block js %}
{{ block.super }}
$('.btn-save').click(function(){
$.SubmitForm('#obj_form form','{{request.path}}');
});
{% if form.instance.id %}
$('#id_product').val('{{form.instance.product.id}}');
$('#label_product').val('{{form.instance.product.name}}');
{% endif %}
$('#product_label').autocomplete({
source: function(request, response) {
$.ajax({
url: '/obj/ajax/autocomplete/product/',
dataType: "json",
data: {
term: $("#mat_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;
}
});
$('#mat_label').autocomplete({
source: function(request, response) {
$.ajax({
url: '/obj/ajax/autocomplete/materials/',
dataType: "json",
data: {
term: $("#mat_label").val() ,//搜索栏里的内容
company_id: {{request.user.company_id}} ,//额外参数
},
success: function(data) {
response(data);
}
});
},
select: function (event, ui) {
$("#mat_id").val(ui.item.value);
$("#mat_label").val(ui.item.label);
return false;
}
});
$('#sem_label').autocomplete({
source: function(request, response) {
$.ajax({
url: '/obj/ajax/autocomplete/semifinishedgoods/',
dataType: "json",
data: {
term: $("#sem_label").val() ,//搜索栏里的内容
company_id: {{request.user.company_id}} ,//额外参数
},
success: function(data) {
response(data);
}
});
},
select: function (event, ui) {
$("#sem_id").val(ui.item.value);
$("#sem_label").val(ui.item.label);
return false;
}
});
$('#pkg_label').autocomplete({
source: function(request, response) {
$.ajax({
url: '/obj/ajax/autocomplete/packaging/',
dataType: "json",
data: {
term: $("#pkg_label").val() ,//搜索栏里的内容
company_id: {{request.user.company_id}} ,//额外参数
},
success: function(data) {
response(data);
}
});
},
select: function (event, ui) {
$("#pkg_id").val(ui.item.value);
$("#pkg_label").val(ui.item.label);
return false;
}
});
$('.add-mat').click(function(){
var id=$('#mat_id').val();
var label=$('#mat_label').val();
if(id==''){
toastr.error("请先选择原材料!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return;
}else{
var e=false;
$("#tb_mat tbody tr").each(function(){
if($(this).attr('mat_id') == id){
e=true;
return false;
}
});
if(e){
toastr.error(label+"已在原材料配比列表中!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return true;
}else{
var count = $('#tb_mat tbody tr').length;
var prefix='#id_bommaterials_bom-';
html='
'+
''+
''+
' | '+
''+label+' | '+
' | '+
''+$('#mat_unit').find("option:selected").text()+' | '+
'
';
$('#tb_mat tbody').append(html);
$(prefix+'TOTAL_FORMS').attr('value', (count+1));
}
};
});
$('.add-sem').click(function(){
var id=$('#sem_id').val();
var label=$('#sem_label').val();
if(id==''){
toastr.error("请先选择半成品材料!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return;
}else{
var e=false;
$("#tb_sem tbody tr").each(function(){
if($(this).attr('sem_id') == id){
e=true;
return false;
}
});
if(e){
toastr.error(label+"已在半成品材料配比列表中!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return true;
}else{
var count = $('#tb_sem tbody tr').length;
var prefix='#id_bomsemifinishedgoods_bom-';
//bomsemifinishedgoods_bom
html=''+
''+
''+
' | '+
''+label+' | '+
' | '+
''+$('#sem_unit').find("option:selected").text()+' | '+
'
';
$('#tb_sem tbody').append(html);
$(prefix+'TOTAL_FORMS').attr('value', (count+1));
}
};
});
$('.add-pkg').click(function(){
var id=$('#pkg_id').val();
var label=$('#pkg_label').val();
if(id==''){
toastr.error("请先选择包装材料!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return;
}else{
var e=false;
$("#tb_pkg tbody tr").each(function(){
if($(this).attr('pkg_id') == id){
e=true;
return false;
}
});
if(e){
toastr.error(label+"已在包装材料配比列表中!", "操作错误:",
{timeOut: 800, positionClass: "toast-center-center"}
);
return true;
}else{
var count = $('#tb_pkg tbody tr').length;
var prefix='#id_bompackaging_bom-';
html=''+
''+
''+
' | '+
''+label+' | '+
' | '+
''+$('#pkg_unit').find("option:selected").text()+' | '+
'
';
$('#tb_pkg tbody').append(html);
$(prefix+'TOTAL_FORMS').attr('value', (count+1));
}
};
});
{% endblock %}
{% block subtitle-1 %}
{% trans '物料信息' %}
{% endblock %}
{% block subtitle-2 %}
{% trans '物料清单' %}
{% endblock %}
{% block form_content %}
{{ block.super }}
{% endblock %}
{% block fmset %}
| {% trans '删除' %} |
{% trans '原材名称 ' %} |
{% trans '数量 ' %} |
{% trans '单位' %} |
{% for f in formset_m %}
{{f.id}}{{f.unit}}{{f.materials}}
| {{f.DELETE}} |
{{ f.instance.materials.name }} |
{{ f.qty }} |
{{ f.instance.unit.name }} |
{% endfor %}
{{ formset_m.management_form }}
| {% trans '删除' %} |
{% trans '半成品名称 ' %} |
{% trans '数量 ' %} |
{% trans '单位' %} |
{% for f in formset_s %}
{{f.id}}{{f.unit}}{{f.semifinishedgoods}}
| {{f.DELETE}} |
{{ f.instance.semifinishedgoods.name }} |
{{ f.qty }} |
{{ f.instance.unit.name }} |
{% endfor %}
{{ formset_s.management_form }}
| {% trans '删除' %} |
{% trans '包装材料名称 ' %} |
{% trans '数量 ' %} |
{% trans '单位' %} |
{% for f in formset_p %}
{{f.id}}{{f.unit}}{{f.packaging}}
| {{f.DELETE}} |
{{ f.instance.packaging.name }} |
{{ f.qty }} |
{{ f.instance.unit.name }} |
{% endfor %}
{{ formset_p.management_form }}
{% endblock %}