Skip to content

Instantly share code, notes, and snippets.

@josejailton
Created March 9, 2020 20:15
Show Gist options
  • Save josejailton/96495ab770904a9bf01db2aeb9c2d729 to your computer and use it in GitHub Desktop.
Save josejailton/96495ab770904a9bf01db2aeb9c2d729 to your computer and use it in GitHub Desktop.
chave = $('#get_chave').val();
codigo_prod = $(this).attr("id");
cod_fabri = $(this).attr("data-cod-fabr");
$(document).on('keyup focus','#input_ean',function(e){
if($(this).val().length > 6 || $(this).val().length < 4){
$(this).addClass('is-invalid');
if(e.keyCode != 13){
$(this).popover({trigger:'focus',placement:'bottom',content:'O código EAN está maior ou menor que a quantidade padrao.'})
$(this).popover('show')
}
}else{
$('#input_ean').removeClass('is-invalid');
$('#input_ean').popover('dispose');
}
})
$(document).on('keyup focus','#input_cod_cadas',function(e){
if($(this).val().length > 5 || $(this).val().length < 1){
$(this).addClass('is-invalid');
if(e.keyCode != 13){
$(this).popover({trigger:'focus',placement:'bottom',content:'o código NCM limite permitido.'})
$(this).popover('show')
}
}else{
$(this).removeClass('is-invalid');
$(this).popover('dispose');
}
})
$(document).on('keyup focus','#input_nome',function(e){
if($(this).val().length > 50 || $(this).val().length < 10){
$(this).addClass('is-invalid');
if(e.keyCode != 13){
$(this).popover({trigger:'focus',placement:'bottom',content:'A quantidade de caracteres no nome do produto, estao na minima ou acima do limite permitido.'})
$(this).popover('show')
}
}else{
$(this).removeClass('is-invalid');
$(this).popover('dispose');
}
})
$('#modalExemplo_s .modal-title,#modalExemplo_s .modal-footer').html('&nbsp;');
$('#modalExemplo_s').modal('show');
$.ajax({
type:'GET',
url:'api_prod_cadas.php?ean='+codigo_prod+'&chave='+chave+'&cod_fabr='+cod_fabri,
dataType:'json',
beforeSend:function(xhr,opts){
$('#modalExemplo_s .modal-body').html('<center><span style="font-size:14px;font-family:helveticaneue, Arial, Tahoma, Sans-serif;">Carregando...</span></center>');
},
success:function(data){
var form;
form = '<form>'
+'<div class="form-row">'
+'<div class="form-group col-md-4">'
+'<label for="input_ean">EAN</label>'
+'<input type="text" class="form-control input_valid" id="input_ean" placeholder="EAN Código de Barras" value="'+codigo_prod+'">'
+'</div>'
+'<div class="form-group col-md-2">'
+'<label for="input_cod_cadas">Cód. Cad.</label>'
+'<input type="text" class="form-control input_valid" id="input_cod_cadas" value="'+data.xml.item.cod_prod+'" readonly>'
+'</div>'
+'<div class="form-group col-md-3">'
+'<label for="input_ncm">NCM</label>'
+'<input type="text" class="form-control" id="input_ncm" value="'+data.xml.item.ncm+'" readonly>'
+'</div>'
+'<div class="form-group col-md-3">'
+'<label for="input_und">Unidade</label>'
+'<select id="input_und" class="form-control">'
+'<option value="UND" selected>UND</option>'
+'<option value="MT">MT</option>'
+'<option value="LT">LT</option>'
+'</select>'
+'</div>'
+'</div>'
+'<div class="form-group">'
+'<label for="input_nome">Produto</label>'
+'<input type="text" class="form-control upper input_valid" id="input_nome" placeholder="Nome do Produto" value="'+data.xml.item.nome_prod+'">'
+'</div>'
+'<div class="form-row">'
+'<div class="form-group col-md-4">'
+'<label for="input_cod_prod">Cód. Prod. Fornec.</label>'
+'<input type="text" class="form-control" id="input_cod_prod" placeholder="" value="'+data.xml.item.cod_prod_fabr+'">'
+'</div>'
+'<div class="form-group col-md-8">'
+'<label for="input_fornecedor">Fornecedor</label><br>'
+'<select id="input_fornecedor" class="selectpicker with-ajax form-control" data-live-search="true">'
if(typeof data.xml.item.cod_forn != 'undefined'){
form = form +'<option value="'+data.xml.item.cod_forn+'" data-subtext="'+data.xml.item.cod_forn+'">'+data.xml.item.nome_forn+'</option>'
}
form = form +'</select>'
+'</div>'
+'</div>'
+'<div class="form-check">'
+'<input class="form-check-input" type="checkbox" id="gridCheck">'
+'<label class="form-check-label noselect" for="gridCheck">'
+'Desativar Produto (PDV)'
+'</label>'
+'</div>'
+'</form>';
$('#modalExemplo_s .modal-body').html(form);
$('#modalExemplo_s .modal-footer').html('<button id="'+codigo_prod+'" class="btn btn-primary btn-sm btn_inser_prod">Cadastrar</button> <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Fechar</button>');
$( ".input_valid" ).on( "keyup", function(e) {
console.log('campo: '+$(this).attr("id"));
});
var e = $.Event('keyup',{keyCode:13});
$('.input_valid').trigger(e);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment