493 lines
16 KiB
JavaScript
493 lines
16 KiB
JavaScript
const inputFormatDouble2 = Object.freeze({ precision: 2, append: '' });
|
|
|
|
function deletetrade(id) { //无效化
|
|
main.confirm(page.ConfirmInfo, function () {
|
|
$.ajax({
|
|
type: "Post",
|
|
url: "/swaptrade2/deletetrade",
|
|
data: { id: id, d: new Date() },
|
|
success: function (data) {
|
|
alert(data.msg);
|
|
if (data.success) {
|
|
try { window.parent.reloadtrade(); }
|
|
catch (e) {
|
|
//
|
|
}
|
|
parent.parent.layer.closeAll();
|
|
}
|
|
},
|
|
error: function (msg) {
|
|
alert("error:" + msg);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
function editTrade(enid) {
|
|
window.location.href = `/swapTrade2/tradeEdit/?enid=${enid}`;
|
|
}
|
|
|
|
function editTradeRemarkInfo(enid) {
|
|
main.open("修改备注", "/trade/EditRemarkInfo?enid=" + enid, { area: ["700px", "500px"] });
|
|
}
|
|
function downloadFiles(files) {
|
|
if (files instanceof Array) {
|
|
if (files.length <= 0) {
|
|
return;
|
|
}
|
|
$.each(files,
|
|
function (index, val) {
|
|
if (val) {
|
|
setTimeout(function () { window.open(val); }, 500);
|
|
}
|
|
});
|
|
} else if (files) {
|
|
window.open(files);
|
|
}
|
|
}
|
|
function showSwapRate(timeRate, isMarginLeg) {
|
|
vueDetails.initSwapIntervalList(timeRate, isMarginLeg);
|
|
$("#swapIntervalModal").modal("show");
|
|
}
|
|
var layerIndex = -1;
|
|
var confirmFunc = function (id, additionalProcessing) {
|
|
var pData = { tradeids: id };
|
|
if (!main.isEmpty(additionalProcessing)) {
|
|
pData.additionalProcessing = additionalProcessing;
|
|
}
|
|
main.post("/trade/tradeConfirm", pData).done(function (data) {
|
|
if (!data.success) {
|
|
main.message(data.msg);
|
|
return;
|
|
}
|
|
if (data.obj && data.obj.proccessType === "AdditionalProcessing") {
|
|
if (data.obj.TrialDataId) {
|
|
var layerSetting = {
|
|
type: 2,
|
|
title: "提示",
|
|
shadeClose: false,
|
|
shade: 0.4,
|
|
area: ['800px', '500px'],
|
|
content: "/trade/showQuotaTrial?id=" + data.obj.TrialDataId,
|
|
yes: function (index) {
|
|
var obj = window["layui-layer-iframe" + index].page;
|
|
if (obj.Data.Remark && obj.Data.Remark.length > 0) {
|
|
main.post("/trade/SaveQuotaTrial", obj.Data, { async: false }).done(function (res) {
|
|
if (!res || !res.success) {
|
|
main.message(res.msg);
|
|
}
|
|
});
|
|
layer.close(layerIndex);
|
|
confirmFunc(id, "LackOfMoney");
|
|
return;
|
|
}
|
|
main.message("必须填写说明内容,才可以录入交易");
|
|
},
|
|
cancel: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
layer.close(layerIndex);
|
|
}
|
|
};
|
|
if (data.obj.type === "LackOfMoney") {
|
|
layerSetting.btn = [page.buttonStr, '取消'];
|
|
}
|
|
// 只展示“资金状况”的情况
|
|
if (data.obj.typecode === "FundStatus") {
|
|
layerSetting.btn = ["确认", '取消'];
|
|
}
|
|
|
|
layerIndex = layer.open(layerSetting);
|
|
}
|
|
else {
|
|
if (data.obj.message) {
|
|
main.message(data.obj.message);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
if (page.IsGenerateAmendDoc) {
|
|
if (data.obj && data.obj.generateChangeSuccess) {
|
|
main.downloadFiles(data.obj.url);
|
|
}
|
|
}
|
|
closetradeWindow();
|
|
});
|
|
};
|
|
function confirmTrade(id) {
|
|
///批量结算
|
|
main.confirm("确定确认交易吗?每条腿都会被确认", function () { confirmFunc(id); });
|
|
}
|
|
function terminationBackToConfirmed(enid) {
|
|
main.confirm("确定提前终止放弃吗?", function () {
|
|
main.post("/trade/TerminationBackToConfirmed", { enid: enid }).done(reloadData);
|
|
});
|
|
}
|
|
function closetradeWindow(reload) {
|
|
layer.closeMe(reload ? "reloadData" : "");
|
|
}
|
|
$(document).ready(function () {
|
|
$(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" });
|
|
});
|
|
$(document).keyup(function (event) {
|
|
switch (event.keyCode) {
|
|
case 27:
|
|
window.parent.layer.closeAll();
|
|
|
|
}
|
|
});
|
|
function fileManagement(tradeNumber) {
|
|
main.open("文件管理", "/trade/tradeFileManagement?tradeNumber=" + tradeNumber);
|
|
}
|
|
function contractManagement(tradeNumber) {
|
|
main.open("【{0}】文件管理".template(tradeNumber), "/trade/tradeContractManagement?tradeNumber=" + tradeNumber);
|
|
}
|
|
function tradeOperationHistory(encryptId) {
|
|
main.open("操作历史", "/swaptrade2/OperationHistory?enid=" + encryptId, { area: ["1000px", "600px"] });
|
|
}
|
|
|
|
function tradeTrialHistory(tradeId) {
|
|
main.open("试算历史", "/trade/quotaTrialHistory?TradeId=" + tradeId, { area: ["1200px", "600px"] });
|
|
}
|
|
|
|
function DownTradeFiles(tradeNumber) {
|
|
if (tradeNumber === "") {
|
|
main.message("交易编码不存在,请先在财务与报告页面生成交易确认书后再在此页面下载交易确认书");
|
|
return;
|
|
}
|
|
main.confirm("确定下载交易确认书?",
|
|
function () {
|
|
main.post("/trade/DownTradeFiles", { tradeNumber: tradeNumber }).done(function (res) {
|
|
if (res.length > 0) {
|
|
for (var i = 0; i < res.length; i++) {
|
|
window.open(res[i]);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
function unWindSwapTrade(id) {
|
|
var title = "交易平仓";
|
|
var srcurl = "/swaptrade2/SwapUnwind/?enid=" + id;
|
|
main.post("/swaptrade2/CheckEodTrade?enid=" + id).done(function (res) {
|
|
if (res.success) {
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["90%", "800px"],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
main.message(res.message);
|
|
}
|
|
});
|
|
}
|
|
function unWindSwap(id) {
|
|
var title = "收益结算";
|
|
var srcurl = "/swaptrade2/SwapIncome/?enid=" + id;
|
|
main.post("/swaptrade2/CheckEodTradeForIncome?enid=" + id).done(function (res) {
|
|
if (res.success) {
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["90%", "780px"],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
main.message(res.message);
|
|
}
|
|
});
|
|
}
|
|
function unWindSwapLongShort(id) {
|
|
var title = "交易平仓";
|
|
var srcurl = "/swaptrade2/SwapLongShortUnwind/?enid=" + id;
|
|
main.post("/swaptrade2/CheckEodTrade?enid=" + id).done(function (res) {
|
|
if (res.success) {
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["1300px", "780px"],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
main.message(res.message);
|
|
}
|
|
});
|
|
}
|
|
function unWindLongShortSwap(id) {
|
|
var title = "期间互换";
|
|
var srcurl = "/swaptrade2/SwapLongShortSwap/?enid=" + id;
|
|
main.post("/swaptrade2/CheckEodTrade?enid=" + id).done(function (res) {
|
|
if (res.success) {
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["1300px", "780px"],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
main.message(res.message);
|
|
}
|
|
});
|
|
}
|
|
function extensionTime(id) {
|
|
var title = "展期信息";
|
|
var srcurl = "/swaptrade2/ExtensionTime/?enid=" + id;
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["810px", "780px"],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function showCloseDetails(id,valueDate) {
|
|
var title = "平仓信息";
|
|
var srcurl = "/swaptrade2/CloseDetial/?enid=" + id + "&valueDate="+valueDate;
|
|
main.open(title,
|
|
srcurl,
|
|
{
|
|
area: ["1000px", "780px"]
|
|
});
|
|
}
|
|
function backTrade(enid) {
|
|
var tip = "是否回退";
|
|
if (page.Trade.Warning) {
|
|
tip = "该笔交易发生过除权除息,是否继续回退?";
|
|
}
|
|
main.confirm(tip,
|
|
function () {
|
|
var srcurl = "/swaptrade2/tradeBack?enid=" + enid;
|
|
main.open("交易回退", srcurl, {
|
|
area: ['26%', '40%'],
|
|
end: function () {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
} });
|
|
});
|
|
}
|
|
|
|
//生成交易确认书
|
|
function gJGenerateConfirmBook(id, hasGeneratedConfirmBook) {
|
|
|
|
if (hasGeneratedConfirmBook == "True") {
|
|
if (!confirm("确认覆盖已有的交易确认书?")) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
var tradeIds = [];
|
|
if (id) {
|
|
tradeIds.push(id);
|
|
}
|
|
if (tradeIds.length === 0) {
|
|
main.message("请选择交易");
|
|
return;
|
|
}
|
|
|
|
var htmlContent = '<form class="form-horizontal" role="form" style="padding:15px 12px 5px">' +
|
|
'<div class="form-group">' +
|
|
'<label class="col-sm-4 control-label">文档类型</label>' +
|
|
'<div class="btn-group col-sm-8" data-toggle="buttons">' +
|
|
'<label class="btn btn-sm btn-primary active" style="border:none"><input type="radio" checked name="docType" value="PDF"> PDF</label>' +
|
|
'<label class="btn btn-sm btn-primary" style="border:none"><input type="radio" name="docType" value="DOC"> DOC</label>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</form>';
|
|
|
|
var layerId = main.open2("生成交易确认书",
|
|
htmlContent,
|
|
{
|
|
area: ["300px", "165px"],
|
|
btn: ['生成', '取消'],
|
|
yes: function (index, layero) {
|
|
var docType = $('input[name="docType"]:checked').val();
|
|
main.post("/TradeConfirmBook/GJGenerateConfirmBook/", { tradeIds: tradeIds, docType: docType }).done(function (resp) {
|
|
if (resp.success) {
|
|
window.open(resp.obj);
|
|
} else {
|
|
main.alert(resp.msg.replace("\r\n", "<br/>"));
|
|
}
|
|
layer.close(layerId);
|
|
});
|
|
},
|
|
cancel: function (index, layero) {
|
|
layer.close(layerId);
|
|
},
|
|
success: function (layero, index) {
|
|
$(".btn-group").on("click",
|
|
".btn",
|
|
function (event) {
|
|
$('input[name="docType"]:checked').prop("checked", false);
|
|
$(this).children("input").prop("checked", true);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
function toPdf(id) {
|
|
main.post("/TradeConfirmBook/ToPdf/", { enid: id }).done(function (res) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
window.open(res);
|
|
reload();
|
|
});
|
|
}
|
|
|
|
function reload() {
|
|
main.waitMe();
|
|
window.location.reload();
|
|
}
|
|
(function (global) {
|
|
|
|
global.reloadData = function () {
|
|
main.waitMe();
|
|
window.location.reload();
|
|
main.parentReloadData();
|
|
};
|
|
|
|
}(window));
|
|
|
|
var vueDetails = new Vue({
|
|
el: "#swapIntervalModal",
|
|
data: {
|
|
SwapIntervalList:[],
|
|
isMarginLeg: false // 是否是保证金腿
|
|
},
|
|
created: function () {
|
|
},
|
|
methods: {
|
|
closeModal: function () {
|
|
$("#swapIntervalModal").modal("hide");
|
|
},
|
|
initSwapIntervalList(swapIntervals, isMarginLeg) {
|
|
var that = this;
|
|
that.isMarginLeg = isMarginLeg;
|
|
that.SwapIntervalList = [];
|
|
if (swapIntervals && swapIntervals.length>0) {
|
|
that.SwapIntervalList = JSON.parse(swapIntervals);
|
|
that.SwapIntervalList.forEach((item, index) => {
|
|
that.SwapIntervalList[index].Rate = otcformat.trading.marginRateP(item.Rate);
|
|
// 如果结算日期为空,默认等于观察日期
|
|
if (!item.SettlementDate) {
|
|
that.SwapIntervalList[index].SettlementDate = item.Date;
|
|
}
|
|
});
|
|
}
|
|
},
|
|
formatDate(time, formatStr) {
|
|
if (!formatStr) {
|
|
formatStr = "YYYY-MM-DD";
|
|
}
|
|
var momDate = new moment(time);
|
|
if (!momDate.isValid() || typeof time === "undefined") return "/";
|
|
return momDate.format(formatStr);
|
|
}
|
|
|
|
},
|
|
filters: {
|
|
},
|
|
components: {
|
|
'vue-datepicker': FastVue.vueDatePicker(),
|
|
'vue-number-input': FastVue.vueNumberInput()
|
|
}
|
|
});
|
|
function chkAll_onclick(obj) {
|
|
var chks = document.getElementsByName("sub");
|
|
for (var i = 0; i < chks.length; i++) {
|
|
chks[i].checked = obj.checked;
|
|
}
|
|
}
|
|
function chk_onclick(obj) {
|
|
var chks = document.getElementsByName("sub");
|
|
var chkAll = document.getElementsByName("all");
|
|
if (obj.checked == false)
|
|
chkAll[0].checked = false;
|
|
else {
|
|
var j = 1;
|
|
for (var i = 0; i < chks.length; i++) {
|
|
if (chks[i].checked == false) {
|
|
j = 2;
|
|
break;
|
|
}
|
|
}
|
|
if (j == 1)
|
|
chkAll[0].checked = true;
|
|
}
|
|
}
|
|
|
|
$(function () {
|
|
refreshEntryExit();
|
|
});
|
|
|
|
function refreshEntryExit() {
|
|
var opt = {
|
|
url: "/trade/entryexitListV2?tradeid=" + page.Trade.id,
|
|
data: { rid: page.id },
|
|
dataType: "Html",
|
|
success: function (data) {
|
|
$("#entryexitEditPopInner").html(data);
|
|
}
|
|
};
|
|
main.ajax(opt);
|
|
}
|
|
//限额试算
|
|
function quotaTrial(id) {
|
|
layer.open({
|
|
type: 2,
|
|
title: "提示",
|
|
shadeClose: false,
|
|
shade: 0.4,
|
|
area: ['800px', '500px'],
|
|
content: "/trade/quotaTrial?id=" + id,
|
|
btn: ['关闭'],
|
|
yes: function (index) {
|
|
layer.close(index);
|
|
}
|
|
});
|
|
}
|
|
//撤回 审批中 待复核
|
|
function traderevoke(id) {
|
|
var pData = {
|
|
enid: id,
|
|
};
|
|
main.post("/SwapTrade2/traderevoke", pData).done(function (res) {
|
|
if (window.parent && window.parent.reloadtrade) {
|
|
window.parent.reloadtrade();
|
|
}
|
|
reload();
|
|
});
|
|
|
|
}
|
|
function SubmissionFields(enid) {
|
|
let srcurl = "/trade/tradeSubmissionFields/?enid=" + enid;
|
|
main.open("报送相关字段填写", srcurl, { area: ['700px', '845px'], scrollbar: false });
|
|
}
|
|
|
|
function SubmissionFieldsHistory(enid) {
|
|
main.open("报送相关字段填写", "/trade/submissionFieldsHistory?encryptId=" + enid);
|
|
} |