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

244 lines
10 KiB
Plaintext

@model UnderlyingMainContractViewModel
@{
ViewBag.Title = "报价合约管理";
Layout = "~/Views/Shared/_MainLayout.cshtml";
}
@section CSS{
<link href="~/Style/Css/UnderlyingMainContract.css?v=@HtmlUtil.JsVersion" rel="stylesheet" />
}
@section JS{
<script src="~/Statics/libs/sortable/Sortable.js?v=@(HtmlUtil.JsVersion)"></script>
<script type="text/javascript">
$(function () {
SetAceDropDown();
$("input[name=NeedQuote]").click(function () {
checkAllSelect();
});
checkAllSelect();
new Sortable($('#sortList').get(0), {
handle: '.handle',
animation: 150
});
});
function checkAllSelect() {
//检查所有checkbox是否被全选
var node = document.getElementsByName("NeedQuote");
var allchecked = true;
for (var x = 0; x < node.length; x++) {
allchecked = allchecked && node[x].checked;
}
$("#allSelect").prop("checked", allchecked);
}
function AllSelect(thisCheckBox) {
var node = document.getElementsByName("NeedQuote");
for (var x = 0; x < node.length; x++) {
node[x].checked = thisCheckBox.checked;
}
}
function Export() {
var nextfunc = function () {
main.post("/UnderlyingMainContract/ExportMainContract")
.done(function (res) {
debugger
if (res === '导出成功') {
main.message("报价合约列表导出成功");
} else {
main.message("导出失败");
}
location.reload();
});
}
Submit(nextfunc);
}
function Submit(nextfunc) {
var table = $("#tableData");
//var result = [];
var result = {};
result.Records = [];
result.EnableClientCalculation = $("#enableClientCalc")[0].checked;
result.EnableMobileQuotation = $("#enableMobileQuot")[0].checked;
result.EnableMobileVolQuote = $("#enableMobileVolQuote")[0].checked;
var isgoto = true;
var orderId = 0;
table.find('tbody tr').each(function () {
var thisItem = $(this);
orderId = orderId + 1;
var needQuote = thisItem.find(".NeedQuote")[0].checked;
var underlyingType = thisItem.find(".UnderlyingType")[0].innerText;
var underlyingCodeArr = [];
var marketCode = "";
var count = thisItem.find("select option:selected").length;
var minAmount = thisItem.find(".MinimumAmount")[0].value;
var strikeInv = thisItem.find(".StrikeInterval")[0].value;
var checked = thisItem.find("[type=checkbox]").prop("checked");
// if (checked)
if (checked && count <= 0) {
isgoto = false;
main.message("请设置" + underlyingType + "的【标的代码】");
return;
}
if (checked && minAmount != "" && minAmount <= 0) {
isgoto = false;
main.message("【" + underlyingType + "】的最小交易数量必须大于0");
return;
}
if (checked && strikeInv != "" && strikeInv <= 0) {
isgoto = false;
main.message("【" + underlyingType + "】的行权价间隔必须大于0");
return;
}
for (var i = 0; i < count; i++) {
var text = thisItem.find("select option:selected")[i].text;
marketCode = thisItem.find("select option:selected")[i].value;
underlyingCodeArr.push(text);
}
result.Records.push({
OrderId: orderId,
MarketCode: marketCode,
NeedQuote: needQuote,
UnderlyingType: underlyingType,
UnderlyingCode: underlyingCodeArr.join(),
MinimumAmount: minAmount,
StrikeInterval: parseInt(strikeInv)
});
});
if (isgoto) {
main.post("/UnderlyingMainContract/Submit/", { viewModel: result }).done(function (res) {
if (res === '更新成功') {
if (nextfunc) {
nextfunc()
}
else {
location.reload();
}
} else {
main.message(res.msg);
}
});
}
}
function up(obj) {
var objParentTR = $(obj).parent().parent();
var prevTR = objParentTR.prev();
var title = prevTR.attr("id");
if (title === "title") {
return;
}
if (prevTR.length > 0) {
prevTR.insertAfter(objParentTR);
}
}
function down(obj) {
var objParentTR = $(obj).parent().parent();
var nextTR = objParentTR.next();
if (nextTR.length > 0) {
nextTR.insertBefore(objParentTR);
}
}
function topt(obj) {
var objParentTR = $(obj).parent().parent();
var objparents = $(obj).parent().parent().parent();
if (objParentTR.index() == 0) {
alert("已经置顶!");
return false;
}
if (true) {
alert("操作完成")
objparents.prepend(objParentTR);
}
}
function bottom(obj) {
var objParentTR = $(obj).parent().parent();
var objparents = $(obj).parent().parent().parent();
var len = objparents.children().length;
if ((objParentTR.index() == len - 1)) {
alert("已经置底!");
return false;
}
if (true) {
alert("操作完成")
objparents.append(objParentTR);
}
}
$(".right").parent().addClass("select-input");
</script>
}
<div class="yc-panel">
<form action="@Url.Action("Submit")" method="post">
<table id="tableData" class="table table-bordered">
<colgroup>
<col span="1" width="50" />
<col span="1" width="100" />
<col span="1" width="200" />
<col span="1" width="400" />
<col span="1" width="200" />
<col span="1" width="200" />
</colgroup>
<thead>
<tr>
<th></th>
<th>需要报价</th>
<th>标的品种</th>
<th>标的代码</th>
<th>行权价间隔</th>
<th>最小交易数量</th>
<th style="width:600px">排序</th>
</tr>
</thead>
<tbody id="sortList">
@foreach (var item in Model.Records)
{
<tr>
<td><i class="fa fa-bars handle" title="拖动排序"></i></td>
<td><input type="checkbox" name="NeedQuote" class="NeedQuote" checked="@item.NeedQuote" /></td>
<td><span name="UnderlyingType" class="UnderlyingType">@item.UnderlyingType</span></td>
<td>
<select class="chosen-select UnderlyingCode" data-placeholder="请选择 " multiple="" name="UnderlyingCode">
@foreach (var item2 in item.UnderlyingCodeList)
{
<option value="@(item2.Value)" @(item2.Selected ? "selected" : "")>@item2.Text</option>
}
</select>
</td>
<td><input name="StrikeInterval" class="StrikeInterval" type="text" value="@(item.StrikeInterval)" /></td>
<td><input name="MinimumAmount" class="MinimumAmount" type="text" value="@(item.MinimumAmount)" /></td>
<td>
<a class="btn btn-sm btn-outline-danger" href="javascript:void(0)" onclick="up(this)">上移</a>
<a class="btn btn-sm btn-outline-danger" href="javascript:void(0)" onclick="down(this)">下移</a>
<a class="btn btn-sm btn-outline-danger" href="javascript:void(0)" onclick="topt(this)">置顶</a>
<a class="btn btn-sm btn-outline-danger" href="javascript:void(0)" onclick="bottom(this)">置底</a>
</td>
</tr>
}
</tbody>
</table>
</form>
</div>
@*<div style="text-align: center;padding: 10px 0px;">
<input type="button" style="margin-right:22px;" name="export" id="export" value="导出" class="btn btn-primary" onclick="Export()" />
</div>*@
<div class="yc-panel" style="text-align: center;">
<input type="checkbox" name="allSelect" id="allSelect" onclick="AllSelect(this)" />全选
<input type="checkbox" name="enableClientCalc" id="enableClientCalc" checked="@Model.EnableClientCalculation" title="允许客户在手机端试算期权价格" />开启客户自助定价计算
<input type="checkbox" name="enableMobileQuot" id="enableMobileQuot" checked="@Model.EnableMobileQuotation" />开启手机端实时报价
<input type="checkbox" name="enableMobileVolQuote" id="enableMobileVolQuote" checked="@Model.EnableMobileVolQuote" title="手机端展示报价对应的波动率" />开启波动率报价
<input type="button" name="submit" id="submit" value="确定" class="btn btn-primary" onclick="Submit()" />
</div>