att
This commit is contained in:
+20
-19
@@ -26,32 +26,21 @@ data-params="MyWidget.instance()">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 divEmitidoPor alertaCampo">
|
||||
<label>Emitido por <strong class="text-danger">*</strong></label>
|
||||
<label>Origem<strong class="text-danger">*</strong></label>
|
||||
|
||||
<select name="emitido_por" id="emitido_por" class="form-control">
|
||||
<option value="">Selecionar emissor</option>
|
||||
<option value="fornecedor">Fornecedor</option>
|
||||
<option value="colaborador">Colaborador</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 divEntidadeResponsavel alertaCampo">
|
||||
<label>Responsavel pela emissão <strong class="text-danger">*</strong></label>
|
||||
<label>Empresa emitente <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text" class="form-control"
|
||||
name="entidade_responsavel"
|
||||
id="entidade_responsavel"
|
||||
placeholder="Empresa ou colaborador">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label>E-mail do solicitante</label>
|
||||
|
||||
<input type="email"
|
||||
name="emailSolicitante"
|
||||
id="emailSolicitante"
|
||||
class="form-control"
|
||||
placeholder="email@empresa.com">
|
||||
placeholder="Nome da companhia">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -95,8 +84,10 @@ data-params="MyWidget.instance()">
|
||||
|
||||
<select name="tipo_documento" id="tipo_documento" class="form-control">
|
||||
<option value="">Selecionar</option>
|
||||
<option value="danfe">Nota Fiscal Mercadoria</option>
|
||||
<option value="nota_fiscal_servico">Nota Fiscal Servico</option>
|
||||
<option value="energia">Nota de Energia Elétrica</option>
|
||||
<option value="agua">Nota de Consumo de Água</option>
|
||||
<option value="internet">Nota de Uso de Internet</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -130,8 +121,8 @@ data-params="MyWidget.instance()">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-6 alertaCampo">
|
||||
<label>Numero do documento <strong class="text-danger">*</strong></label>
|
||||
<div class="form-group col-md-3 alertaCampo">
|
||||
<label>Número do documento <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text"
|
||||
name="numero_documento"
|
||||
@@ -140,7 +131,7 @@ data-params="MyWidget.instance()">
|
||||
placeholder="Numero da nota">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-3">
|
||||
<label>Valor do documento</label>
|
||||
|
||||
<div class="input-group">
|
||||
@@ -156,6 +147,16 @@ data-params="MyWidget.instance()">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-3 divautorizadorResponsavel alertaCampo">
|
||||
<label>Nome do Autorizador <strong class="text-danger">*</strong></label>
|
||||
|
||||
<input type="text" class="form-control"
|
||||
name="autorizador_responsavel"
|
||||
id="autorizador_responsavel"
|
||||
placeholder="Digite seu nome">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
+89
-3
@@ -50,6 +50,18 @@ var MyWidget = SuperWidget.extend({
|
||||
this.root.find("#cnpj").off("input").on("input", function () {
|
||||
this.value = self.mascaraCNPJ(this.value);
|
||||
});
|
||||
|
||||
this.root.find("#valor").off("input").on("input", function () {
|
||||
this.value = self.mascaraValorDocumento(this.value);
|
||||
});
|
||||
|
||||
this.root.find("#valor").off("blur").on("blur", function () {
|
||||
var currentValue = (this.value || "").toString().trim();
|
||||
if (!currentValue) {
|
||||
return;
|
||||
}
|
||||
this.value = self.formatMoneyDisplay(currentValue);
|
||||
});
|
||||
},
|
||||
|
||||
setupInitialValues: function () {
|
||||
@@ -146,6 +158,7 @@ var MyWidget = SuperWidget.extend({
|
||||
var cnpj = this.onlyDigits(this.value("#cnpj"));
|
||||
var numeroDocumento = this.value("#numero_documento");
|
||||
var valor = this.normalizeMoney(this.value("#valor"));
|
||||
var autorizadorResponsavel = self.value("#autorizador_responsavel");
|
||||
var documentoPessoa = tipoCadastro === "cpf" ? cpf : cnpj;
|
||||
var cpfField = tipoCadastro === "cpf" ? cpf : "";
|
||||
|
||||
@@ -164,6 +177,8 @@ var MyWidget = SuperWidget.extend({
|
||||
tipo_documento: self.value("#tipo_documento"),
|
||||
numero_documento: numeroDocumento,
|
||||
valor: valor,
|
||||
autorizador_responsavel: autorizadorResponsavel,
|
||||
autorizadorResponsavel: autorizadorResponsavel,
|
||||
justificativa: self.value("#justificativa")
|
||||
}
|
||||
};
|
||||
@@ -316,6 +331,7 @@ var MyWidget = SuperWidget.extend({
|
||||
if (!this.value("#entidade_responsavel")) ok = this.markRequired("#entidade_responsavel") && ok;
|
||||
if (!this.value("#tipo_cadastro")) ok = this.markRequired("#tipo_cadastro") && ok;
|
||||
if (!this.value("#numero_documento")) ok = this.markRequired("#numero_documento") && ok;
|
||||
if (!this.value("#autorizador_responsavel")) ok = this.markRequired("#autorizador_responsavel") && ok;
|
||||
if (!this.value("#justificativa")) ok = this.markRequired("#justificativa") && ok;
|
||||
|
||||
if (tipoCadastro === "cpf") {
|
||||
@@ -382,6 +398,47 @@ var MyWidget = SuperWidget.extend({
|
||||
return v;
|
||||
},
|
||||
|
||||
mascaraValorDocumento: function (value) {
|
||||
var raw = (value || "").toString().replace(/[^\d,]/g, "");
|
||||
if (!raw) return "";
|
||||
|
||||
var commaIndex = raw.indexOf(",");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (commaIndex >= 0) {
|
||||
inteiro = raw.substring(0, commaIndex).replace(/\D/g, "");
|
||||
decimal = raw.substring(commaIndex + 1).replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = raw.replace(/\D/g, "");
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
|
||||
if (commaIndex >= 0) {
|
||||
return inteiro + "," + decimal;
|
||||
}
|
||||
|
||||
return inteiro;
|
||||
},
|
||||
|
||||
formatMoneyDisplay: function (value) {
|
||||
var normalized = this.normalizeMoney(value);
|
||||
var parts = normalized.split(",");
|
||||
var inteiro = (parts[0] || "").replace(/\D/g, "");
|
||||
var decimal = (parts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
inteiro = inteiro.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
return inteiro + "," + decimal;
|
||||
},
|
||||
|
||||
onlyDigits: function (value) {
|
||||
return (value || "").replace(/\D/g, "");
|
||||
},
|
||||
@@ -389,9 +446,38 @@ var MyWidget = SuperWidget.extend({
|
||||
normalizeMoney: function (value) {
|
||||
var raw = (value || "").toString().trim();
|
||||
if (!raw) return "0,00";
|
||||
if (raw.indexOf(",") >= 0) return raw;
|
||||
if (raw.indexOf(".") >= 0) return raw.replace(".", ",");
|
||||
return raw + ",00";
|
||||
|
||||
var cleaned = raw.replace(/\s/g, "").replace(/[^\d,\.]/g, "");
|
||||
var inteiro = "";
|
||||
var decimal = "";
|
||||
|
||||
if (cleaned.indexOf(",") >= 0) {
|
||||
var commaParts = cleaned.split(",");
|
||||
inteiro = (commaParts.shift() || "").replace(/\D/g, "");
|
||||
decimal = commaParts.join("").replace(/\D/g, "").slice(0, 2);
|
||||
} else if (cleaned.indexOf(".") >= 0) {
|
||||
var dotParts = cleaned.split(".");
|
||||
var isDecimalDot = dotParts.length === 2 && dotParts[1].length > 0 && dotParts[1].length <= 2;
|
||||
|
||||
if (isDecimalDot) {
|
||||
inteiro = (dotParts[0] || "").replace(/\D/g, "");
|
||||
decimal = (dotParts[1] || "").replace(/\D/g, "").slice(0, 2);
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
decimal = "";
|
||||
}
|
||||
} else {
|
||||
inteiro = cleaned.replace(/\D/g, "");
|
||||
decimal = "";
|
||||
}
|
||||
|
||||
inteiro = inteiro.replace(/^0+(?=\d)/, "");
|
||||
if (!inteiro) inteiro = "0";
|
||||
|
||||
if (!decimal) decimal = "00";
|
||||
if (decimal.length === 1) decimal = decimal + "0";
|
||||
|
||||
return inteiro + "," + decimal;
|
||||
},
|
||||
|
||||
normalizeTipoCadastro: function (value) {
|
||||
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user