|
|
|
@ -9,29 +9,28 @@ |
|
|
|
prefix: '{{ formset.prefix }}', |
|
|
|
prefix: '{{ formset.prefix }}', |
|
|
|
formCssClass: 'dynamic-form', |
|
|
|
formCssClass: 'dynamic-form', |
|
|
|
}); |
|
|
|
}); |
|
|
|
var get_pair = function(model, class1, class2, name1, name2) { |
|
|
|
|
|
|
|
$('body').on('focusout', '.' + class1 + ' input', function() { |
|
|
|
var get_pair = function(model, class1, class2, param1, param2) { |
|
|
|
|
|
|
|
$('body').on('selectChoice change', '.' + class1 + ' input', function() { |
|
|
|
var $this = $(this); |
|
|
|
var $this = $(this); |
|
|
|
var $code_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input'); |
|
|
|
var this_val = $this.val(); |
|
|
|
var code_input_val = $code_input.val(); |
|
|
|
var $other_input = $this.closest('.row_tbl_items').find('.' + class2 + ' input'); |
|
|
|
|
|
|
|
|
|
|
|
$.get('/my/docs/ajax_get_pair/' + model + '/' + name1 + '/' + name2 + '/' + $this.val() + '/', function(data){ |
|
|
|
$.get('/my/docs/ajax_get_pair/' + model + '/' + param1 + '/' + param2 + '/' + this_val + '/', function(data) { |
|
|
|
if (data['val']) { |
|
|
|
if (data['val']) { |
|
|
|
$code_input.val(data['val']); |
|
|
|
$other_input.val(data['val']); |
|
|
|
if (($code_input.val() != '')&&(($code_input.val() != code_input_val))) { |
|
|
|
$this.css('color', 'black') |
|
|
|
$code_input.css('color', 'red') |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$code_input.css('color', 'black') |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
$this.css('color', 'black'); |
|
|
|
else { |
|
|
|
|
|
|
|
$other_input.val('-'); |
|
|
|
|
|
|
|
$this.css('color', 'red') |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
get_pair('Country', 'country_code', 'country_name', 'code', 'name'); |
|
|
|
{# model должна быть разрешена в docs.views.get_pair #} |
|
|
|
get_pair('Country', 'country_name', 'country_code', 'name', 'code'); |
|
|
|
get_pair('Country', 'country_name', 'country_code', 'name', 'code'); |
|
|
|
get_pair('Measure', 'units', 'units_kod', 'name', 'code'); |
|
|
|
get_pair('Measure', 'units', 'units_kod', 'name', 'code'); |
|
|
|
get_pair('Measure', 'units_kod', 'units', 'code', 'name'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#id_client').on('change', function() { |
|
|
|
$('#id_client').on('change', function() { |
|
|
|
var client_id = $(this).val(); |
|
|
|
var client_id = $(this).val(); |
|
|
|
|