Я пытаюсь передать значения из представления в контроллер, используя Vue.js, но у меня проблема только с десятичными значениями.Когда я ввожу десятичные значения и отправляю их в контроллер, он получает NULL.
Примечание: только для десятичных значений, для целых или строковых значений все в порядке.
Вот мой код:
salvarProdutos: function () {
load();
this.$http.post(urlInit + '/Quotation/updateInfoComercial/', {
RefCotacao: this.refCotacao,
//InformaçoesComerciais//
Qtd: this.quantidade,
UnidadeMedida: this.unidadeMedida,
ValorUnitario: this.valorUnitarioProduto,
LoteMinimo: this.loteMinimo,
PrazoEntrega: this.prazoEntrega,
PorcentagemMaxVariacao: this.porcentagemVariacao
//--------------------------//
}).then((response) => {
unload();
if (response.data.worked) {
alert("Dados salvos com sucesso!");
}
else {
alert("Erro - Tente novamente mais tarde.");
}
});
}
<div class="col-md-6">
<div class="form-group label-floating">
<label class="control-label" for="porcentagemVariacao">
Porcentagem máxima de variação
</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">%</span>
</div>
<input type="number" min="1" step="0.1" class="form-control" id="porcentagemVariacao" v-model="porcentagemVariacao" required>
<span class="material-input"></span>
</div>
</div>
</div>
Вот мой контроллер:
[HttpPost]
public ActionResult updateInfoComercial(string refCotacao, InformacoesComerciais infoCF, string form)
{
var partNumber = infoCF.PartNumber;
var porcentagem = infoCF.PorcentagemMaxVariacao;
var message = "";
message = "OK";
return Json(new { message = message }, JsonRequestBehavior.AllowGet);
}
Вот моя модель:
public partial class InformacoesComerciais
{
public InformacoesComerciais() { }
[DatabaseGenerated(DatabaseGeneratedOption.None)]
//public int ID { get; set; }
public decimal? Qtd { get; set; }
[StringLength(8)]
public string UnidadeMedida { get; set; }
[Key]
[Column(Order = 1)]
[StringLength(20)]
public string RefCotacao { get; set; }
public decimal? ValorUnitario { get; set; }
public decimal? LoteMinimo { get; set; }
public decimal? PorcentagemMaxVariacao { get; set; }
//[Column(TypeName = "date")]
public string PrazoEntrega { get; set; }
}