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

298 lines
12 KiB
Plaintext

@using YLErp;
@using YLErp.Model.Enum;
@{
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section CSS{
<link href="~/Style/Css/tradeConfirmList.css" rel="stylesheet" />
<style>
td {
text-align: center;
min-width: 120px;
}
</style>
}
@section JS{
<script>
function uploadDbfPosition() {
if (!checkData()) {
return false;
}
var formData = new FormData($("#form")[0]);
var url = '/RiskHedging/UploadPdfHedgePositions';
$.ajax({
url: url,
type: 'POST',
beforeSend: function () {
main.waitMe("show");
},
success: function (data) {
try {
if (data.result && data.result.length > 0
|| data.diffAccounts && data.diffAccounts.length > 0
|| data.unexistUmds && data.unexistUmds.length > 0) {
if (data.diffAccounts && data.diffAccounts.length > 0) {
var tip = "<div><span style='font-weight: bolder'>下列对冲账户未找到对应簿记账户:</span><span>" + data.diffAccounts.join(',') + "</span></div>";
$("#diffAccountTip").html(tip);
}
else {
$("#diffAccountTip").html("");
}
if (data.unexistUmds && data.unexistUmds.length > 0) {
var tip = "<div><span style='font-weight: bolder'>系统不存在下列标的信息:</span><span>" + data.unexistUmds.join(',') + "</span></div>";
$("#unexistUmdsTip").html(tip);
}
else {
$("#unexistUmdsTip").html("");
}
if (data.result && data.result.length > 0) {
var trhtml = "";
var tdtemplate = "<td>{0}</td>";
for (var i = 0; i < data.result.length; i++) {
trhtml += "<tr class='ui-widget-content jqgrow ui-row-ltr'>";
trhtml += tdtemplate.template(data.result[i].BookName);
trhtml += tdtemplate.template(data.result[i].SYMBOL);
trhtml += tdtemplate.template(data.result[i].CURQTY);
trhtml += tdtemplate.template(data.result[i].SystemNotional);
trhtml += "/<tr>";
}
$("#tbody").html(trhtml);
$("#diffPositionArea").show();
}
else {
$("#diffPositionArea").hide();
}
$(".ui-jqgrid-view").show();
}
else {
$(".ui-jqgrid-view").hide();
if (data.msg) {
main.alert(data.msg);
}
else {
main.alert("上传文件持仓和系统持仓并无差异!");
}
}
} catch (e) {
main.waitMe("hide");
} finally {
main.waitMe("hide");
}
},
error: function (data) {
main.waitMe("hide");
showmiddlemessage("导入检查失败:{0}".template(data.msg));
},
data: formData,
cache: false,
contentType: false,
processData: false,
complete() {
}
});
}
function uploadDbfPositionAddDiff() {
if (!checkData()) {
return false;
}
var formData = new FormData($("#form")[0]);
var url = '/RiskHedging/UploadDbfPositionAddDiff';
$.ajax({
url: url,
type: 'POST',
beforeSend: function () {
main.waitMe("show");
},
success: function (data) {
try {
$(".ui-jqgrid-view").hide();
$("#diffPositionArea").hide();
if (data.result && data.result.length > 0
|| data.diffAccounts && data.diffAccounts.length > 0
|| data.unexistUmds && data.unexistUmds.length > 0) {
if (data.diffAccounts && data.diffAccounts.length > 0) {
var tip = "<div><span style='font-weight: bolder'>下列对冲账户未找到对应簿记账户:</span><span>" + data.diffAccounts.join(',') + "</span></div>";
$("#diffAccountTip").html(tip);
$(".ui-jqgrid-view").show();
}
else {
$("#diffAccountTip").html("");
}
if (data.unexistUmds && data.unexistUmds.length > 0) {
var tip = "<div><span style='font-weight: bolder'>系统不存在下列标的信息:</span><span>" + data.unexistUmds.join(',') + "</span></div>";
$("#unexistUmdsTip").html(tip);
$(".ui-jqgrid-view").show();
}
else {
$("#unexistUmdsTip").html("");
}
if (data.result && data.result.length > 0) {
main.alert("持仓差异处理已完成!");
}
else {
main.alert("不存在可处理的持仓差异!");
}
}
else {
if (data.msg) {
main.alert(data.msg);
}
else {
main.alert("上传文件持仓和系统持仓并无差异!");
}
}
} catch (e) {
main.waitMe("hide");
} finally {
main.waitMe("hide");
}
},
error: function (data) {
main.waitMe("hide");
showmiddlemessage("导入检查失败:{0}".template(data.msg));
},
data: formData,
cache: false,
contentType: false,
processData: false,
complete() {
$('#openFile').val('');
}
});
}
function compareExchangedOptionPosition(type) {
var url = '/RiskHedging/CompareExchangedOptionPosition';
if (type === "CommodityFuture") {
url = '/RiskHedging/CompareCommodityFuturePosition';
}
$.ajax({
url: url,
type: 'POST',
beforeSend: function () {
main.waitMe("show");
},
success: function (data) {
try {
if (data.result && data.result.length > 0) {
if (data.result && data.result.length > 0) {
var trhtml = "";
var tdtemplate = "<td>{0}</td>";
for (var i = 0; i < data.result.length; i++) {
trhtml += "<tr class='ui-widget-content jqgrow ui-row-ltr'>";
trhtml += tdtemplate.template(data.result[i].BookName);
trhtml += tdtemplate.template(data.result[i].SYMBOL);
trhtml += tdtemplate.template(data.result[i].CURQTY);
trhtml += tdtemplate.template(data.result[i].SystemNotional);
trhtml += "/<tr>";
}
$("#tbody").html(trhtml);
$("#diffPositionArea").show();
}
else {
$("#diffPositionArea").hide();
}
$(".ui-jqgrid-view").show();
}
else if (data.message) {
$(".ui-jqgrid-view").hide();
main.alert(data.message);
}
else {
$(".ui-jqgrid-view").hide();
if (data.msg) {
main.alert(data.msg);
}
else {
main.alert("未找到差异!");
}
}
} catch (e) {
main.waitMe("hide");
} finally {
main.waitMe("hide");
}
},
error: function (data) {
main.waitMe("hide");
showmiddlemessage(data.msg);
},
cache: false,
contentType: false,
processData: false,
complete() {
}
});
}
function checkData() {
var fileName = $("#openFile").val();
if (fileName == '') {
main.alert("请选择需要上传的文件!");
return false;
}
let index = fileName.lastIndexOf(".");
let fileEx = index > 0 ? fileName.substr(index).toLowerCase() : '';
return fileEx === '.dbf' || main.alert("只能上传.dbf类型的文件!");
}
</script>
}
@if (ViewBag.IsStock)
{
<div class="well">
<form id="form" style="float: left;">
<strong>中信Cats持仓文件:</strong>
<input type="file" id="openFile" name="file" multiple accept=".dbf" />
</form>
<div style="float: left;">
@MyControls.Btn("持仓比对", "uploadDbfPosition()")
@MyControls.Btn("持仓差异处理", "uploadDbfPositionAddDiff()")
</div>
</div>
}
else
{
<div class="well">
<div style="float: left;">
@MyControls.Btn("商品期货持仓比对", "compareExchangedOptionPosition('CommodityFuture')")
@MyControls.Btn("场内期权持仓比对", "compareExchangedOptionPosition('ExchangedOption')")
</div>
</div>
}
<div class="ui-jqgrid-view" style="width: 1600px; margin-left: 20px; display: none;">
<div id="diffAccountTip"></div>
<div id="unexistUmdsTip"></div>
<div id="diffPositionArea" style="display: none;">
<div style="margin-top: 20px; font-weight: bolder"><span>持仓差异列表:</span></div>
<table class="ui-jqgrid-htable">
<thead>
<tr class="ui-jqgrid-labels">
<th class="ui-state-default ui-th-column ui-th-ltr">
簿记账户
</th>
<th class="ui-state-default ui-th-column ui-th-ltr">
代码
</th>
<th class="ui-state-default ui-th-column ui-th-ltr">
源持仓数
</th>
<th class="ui-state-default ui-th-column ui-th-ltr">
系统持仓数
</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
</div>
</div>