Files
zszq-trs/YLErpWeb/Views/margin_template/margin_templateEdit.cshtml
T
2024-05-09 14:06:26 +08:00

103 lines
4.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@model margin_template
@{
ViewBag.Title = "预付金模板 | 编辑";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
var pageObj = new
{
isNew = Model.id == 0
};
}
@section CSS{
<style>
.form-layout input, .form-layout select {
width: 220px;
}
</style>
}
@section JS{
<script src="~/Scripts/app/tradeHelper.js?v=@HtmlUtil.JsVersion"></script>
<script type="text/javascript">
const PercentFields = { InitialMarginRatio: '初始预付金率', PositionMarginRatio: '持仓预付金率' };
$(function () {
SetAceDropDown();
for (const [k, v] of Object.entries(PercentFields)) {
FastVue.numberInput(document.getElementById(k), { append: '%' });
}
$("#MarginType").change(function () {
if ($("#MarginType").val() == "5" || $("#MarginType").val() == "6") {
$("#PositionMarginRatio").attr("disabled", true);
$("#InitialMarginRatio").attr("disabled", true);
} else {
$("#PositionMarginRatio").attr("disabled", false);
$("#InitialMarginRatio").attr("disabled", false);
}
});
});
function checkSubmitData() {
var pass = $('#margin_templateEditForm').valid();
return pass;
}
function savemargin_template() {
if (!checkSubmitData()) return false;
var data = $("#margin_templateEditForm").serializeObject();
if (data.MarginType == "5" && data.MarginType == "6") {
for (let [k, v] of Object.entries(PercentFields)) {
if (!data[k]) {
throw '程序错误';
}
let number = parseFloat(data[k]);
if (isNaN(number)) {
errors.push(v + " 请输入正确的数值");
}
else if (number < 0) {
errors.push(v + " 不能小于0");
} else {
data[k] = data[k].endsWith('%') ? number / 100 : number;
}
}
}
main.post("/margin_template/margin_templateEditJson", data).done(function (res) { window.location.href = "/margin_template/margin_templateview?enid=" + res.obj.EncryptId; try { window.parent.reloadmargin_template(); } catch (e) { } });
}
function checkcor(obj) {
var codata = $(obj).val();
if (codata > 1 || codata < -1) {
main.message("请输入-1到1的相关性");
$(obj).focus();
return false;
}
}
</script>
}
@using (Html.BeginForm("margin_templateEdit", "margin_template", FormMethod.Post, new { id = "margin_templateEditForm" }))
{
<div class="form-layout">
@Html.HiddenFor(model => model.EncryptId)
<input type="hidden" value="@Model.id" name="id" id="id" />
@Html.MyTextFor(model => model.Name)
@Html.MyDropdownFor(model => model.MarginType, new List<SelectListItem>() { new SelectListItem() { Value = "2", Text = "按固定预付金率" }, new SelectListItem() { Value = "3", Text = "按浮动盈亏和初始名义本金" }, new SelectListItem() { Value = "4", Text = "按浮动盈亏和持仓名义本金" }, new SelectListItem() { Value = "5", Text = "Max0Span幅度估值)" }, new SelectListItem() { Value = "6", Text = "Max(初始预付金,Span幅度估值)" } }, appendBlank: false)
<div class="form-group col-md-6">
<label class="formlabel">初始预付金率</label>
<input class="text-box" type="text" value="@(Model.InitialMarginRatio.OtcFormatPercent())" name="InitialMarginRatio" id="InitialMarginRatio">
</div>
<div class="form-group col-md-6">
<label class="formlabel">持仓预付金率</label>
<input class="text-box" type="text" value="@(Model.PositionMarginRatio.OtcFormatPercent())" name="PositionMarginRatio" id="PositionMarginRatio">
</div>
@Html.MyTextFor(model => model.Comments)
</div>
<div class="form-buttons">
@MyControls.Btn("保存", "savemargin_template()")
@MyControls.Btn("关闭", "layer.closeMe()")
</div>
}